public class Head extends PigComponent {
public Head(PigComponent torso) {
super(torso.pos.copy().add(-torso.size.x/2, 0), new PVector(torso.size.y*.75f, torso.size.y*.75f), torso.p);
torso.children.add(this);
}
@Override
public void drawComponent() {
p.stroke(this.strokeColor);
p.fill(this.fillColor);
p.strokeWeight(this.strokeWeight);
// face
p.ellipse(pos.x, pos.y, size.x, size.y);
// nose or mouth
p.ellipse(pos.x, pos.y+size.x/5, size.x/3, size.x/5);
p.ellipse(pos.x - size.x/20, pos.y+size.x/5, size.x/20, size.x/20);
p.ellipse(pos.x + size.x/20, pos.y+size.x/5, size.x/20, size.x/20);
// eyes
p.ellipse(pos.x - size.x/5, pos.y-size.x/10, size.x/10, size.x/20);
p.ellipse(pos.x + size.x/5, pos.y-size.x/10, size.x/10, size.x/20);
}
@Override
public void computeBoundingBox() {
topLeft = new PVector(pos.x - size.x/2 - strokeWeight/2, pos.y - size.y/2 - strokeWeight/2);
bottomRight = new PVector(pos.x + size.x/2 + strokeWeight/2, pos.y + size.y/2 + strokeWeight/2);
}
}
Put this in your Head.java
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.