One of my favorite things are robots, so I used the processing java library to draw a robot head.
package robotHead;
import processing.core.PApplet;
public class RobotHead extends PApplet {
public static void main(String[] args) {
PApplet.main("robotHead.RobotHead");
}
public void settings() {
size(700, 800);
}
public void setup() {
background(255, 255, 255);
}
public void draw() {
// where you actually draw the stuff
// top left corner is (0, 0)
face(100, 300);
}
public void face(float xPos, float yPos) {
fill(0, 149, 185); // fill color blue
rect(xPos, yPos, 500, 300); // 500 pixels wide and 300 pixels tall at given coordinates
fill(0, 0, 0);
rect(xPos +150, yPos -200, 200, 200);
rect(xPos+100, yPos-50, 50, 50);
rect(xPos+350, yPos-50, 50, 50);
eyes(xPos + 100, yPos + 100);
mouth(xPos + 150, yPos + 200);
leftEar(xPos - 25, yPos + 100);
rightEar(xPos + 500, yPos + 100);
}
public void eyes(float eyesX, float eyesY) {
fill(255, 255, 255); // fill color white
ellipse(eyesX, eyesY, 100, 100); // left eye, make width and height equal for a circle
ellipse(eyesX + 300, eyesY, 100, 100); // right eye
fill(0, 0, 0);
ellipse(eyesX + 300, eyesY, 50, 50);
fill(0, 0, 0);
ellipse(eyesX, eyesY, 50, 50);
fill(0, 0, 255);
rect(eyesX+130, eyesY+10, 50, 50);
}
public void mouth(float mouthX, float mouthY) {
fill(255, 0, 0);
triangle(mouthX, mouthY, mouthX + 250, mouthY, mouthX + 100, mouthY + 75); // triangle(x1, y1, x2, y2, x3, y3);
fill(150, 0, 0);
ellipse(mouthX+110, mouthY+30, 100, 60);
}
public void leftEar(float earX, float earY){
fill(244, 121, 0); // fill color orange
rect(earX, earY, 25, 100);
rect(earX - 25, earY + 12, 25, 75);
rect(earX - 50, earY + 24, 25, 50);
// antenna code
line(earX - 38, earY + 25, earX - 38, earY - 200);
fill(0,255, 0);
ellipse(earX - 38, earY - 200, 30, 30);
}
public void rightEar(float earX, float earY){
fill(244, 121, 0); // fill color orange
rect(earX, earY, 25, 100);
rect(earX + 25, earY + 12, 25, 75);
rect(earX + 50, earY + 24, 25, 50);
// antenna code
line(earX + 62, earY + 25, earX + 62, earY - 200);
fill(0, 255, 0);
ellipse(earX + 62, earY - 200, 30, 30);
}
}