PigComponent for MyPig project

public abstract class PigComponent { Sketch p; PVector pos, size; float strokeWeight; int fillColor, strokeColor; ArrayList<PigComponent> children; //bounding box PVector topLeft, bottomRight; public PigComponent(PVector initPos, PVector initSize, Sketch initP) { //given values this.pos = initPos; this.size = initSize; this.p = initP; //default values this.fillColor = p.color(255); //white this.strokeColor = p.color(0); //black this.strokeWeight = 5; this.children = new ArrayList<>(); //JAVA 8 's ArrayList instatiation computeBoundingBox(); } public void draw() { drawComponent(); if (p.debugging) drawBoundingBox(); for (PigComponent c : children) { c.draw(); } } public void drawBoundingBox() { p.stroke(255,0,0,100); p.noFill(); p.strokeWeight(1); p.rectMode(p.CORNERS); p.rect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); } public abstract void drawComponent(); public abstract void computeBoundingBox(); }
Put this code in your PigComponent.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.