public void display(PApplet theApplet, Controller theController) { theApplet.translate(_myRadius, _myRadius); theApplet.pushMatrix(); theApplet.pushStyle(); theApplet.ellipseMode(PApplet.CENTER); theApplet.noStroke(); theApplet.fill(color().colorBackground); theApplet.ellipse(0, 0, _myRadius * 2, _myRadius * 2); theApplet.popMatrix(); theApplet.pushMatrix(); if (displayStyle == LINE) { theApplet.rotate(myAngle); theApplet.stroke(color().colorForeground); theApplet.line(0, 0, _myRadius, 0); } else if (displayStyle == ELLIPSE) { theApplet.rotate(myAngle); theApplet.noStroke(); theApplet.fill(color().colorForeground); theApplet.ellipse(_myRadius * 0.75f, 0, _myRadius * 0.2f, _myRadius * 0.2f); } else if (displayStyle == ARC) { theApplet.noStroke(); theApplet.fill(color().colorForeground); theApplet.arc(0, 0, _myRadius * 1.8f, _myRadius * 1.8f, startAngle, myAngle); theApplet.fill(color().colorBackground); theApplet.ellipse(0, 0, _myRadius * 1.2f, _myRadius * 1.2f); } theApplet.popMatrix(); theApplet.pushMatrix(); theApplet.rotate(startAngle); if (isShowTickMarks) { float step = range / _myTickMarksNum; theApplet.stroke(color().colorForeground); theApplet.strokeWeight(myTickMarkWeight); for (int i = 0; i <= _myTickMarksNum; i++) { theApplet.line(_myRadius + 2, 0, _myRadius + myTickMarkLength + 2, 0); theApplet.rotate(step); } } else { if (isShowRange) { theApplet.stroke(color().colorForeground); theApplet.strokeWeight(myTickMarkWeight); theApplet.line(_myRadius + 2, 0, _myRadius + myTickMarkLength + 2, 0); theApplet.rotate(range); theApplet.line(_myRadius + 2, 0, _myRadius + myTickMarkLength + 2, 0); } } theApplet.noStroke(); theApplet.popStyle(); theApplet.popMatrix(); }
@Override public void preRender(PApplet p) { super.preRender(p); p.rectMode(PApplet.CENTER); p.fill(getFillColor().getRGB()); p.stroke(getStrokeColor().getRGB()); p.strokeWeight(getStrokeWeight()); }
// Drawing the box void display() { // We look at each body and get its screen position Vec2 pos = box2d.getBodyPixelCoord(body); // Get its angle of rotation float a = body.getAngle(); parent.rectMode(PConstants.CENTER); parent.pushMatrix(); parent.translate(pos.x, pos.y); parent.rotate(-a); parent.fill(127); parent.stroke(0); parent.strokeWeight(2); parent.rect(0, 0, w, h); parent.popMatrix(); }
public void draw(final PApplet p, final Game g, final PlasmaFluid fluid) { p.pushStyle(); p.stroke(255); p.strokeWeight(3); p.fill(150, 150); p.ellipseMode(PApplet.CENTER); p.rectMode(PApplet.CORNER); if (g.mode == Game.PREGAME_WAIT || g.mode == Game.JUST_SCORED || g.mode == Game.JUST_SCORED_WAIT) { int numcircles = 0; final int count = g.modeFrameCountdown; if (count > (Const.PREGAME_WAIT_COUNT * 2 / 3)) { numcircles = 3; } else if (count > (Const.PREGAME_WAIT_COUNT / 3)) { numcircles = 2; } else { numcircles = 1; } final float stepsize = width / 8; final float size = width / 9f; if (numcircles > 2) { p.ellipse(stepsize * 2, height / 2, size * 0.75f, size * 0.75f); p.ellipse(stepsize * 6, height / 2, size * 0.75f, size * 0.75f); } if (numcircles > 1) { p.ellipse(stepsize * 5, height / 2, size * 0.9f, size * 0.9f); p.ellipse(stepsize * 3, height / 2, size * 0.9f, size * 0.9f); } p.ellipse(stepsize * 4, height / 2, size, size); if (numcircles == 2 && numcircles != lastnum) { fluid.addForce( p, (stepsize * 2) / width, 0.5f, -forceval * (1 + r.nextFloat()), 0, Const.OTHER_OFFSET, colorval); fluid.addForce( p, (stepsize * 6) / width, 0.5f, forceval * (1 + r.nextFloat()), 0, Const.OTHER_OFFSET, colorval); } if (numcircles == 1 && numcircles != lastnum) { fluid.addForce( p, (stepsize * 5) / width, 0.5f, 0, forceval * (1 + r.nextFloat()), Const.OTHER_OFFSET, colorval); fluid.addForce( p, (stepsize * 3) / width, 0.5f, 0, -forceval * (1 + r.nextFloat()), Const.OTHER_OFFSET, colorval); } // if (numcircles == 1 && count == 0) { // fluid.addForce(p, (stepsize*4.2f)/width, 0.5f, 0, forceval*(1+r.nextFloat()), // Const.OTHER_OFFSET, colorval); // fluid.addForce(p, (stepsize*3.8f)/width, 0.5f, 0, -forceval*(1+r.nextFloat()), // Const.OTHER_OFFSET, colorval); // } lastnum = numcircles; } else if (g.mode == Game.GAME_OVER) { p.stroke(255); p.fill(255); p.rect(width / 2, height / 2, g.modeFrameCountdown * 3, 30); } p.popStyle(); }
/** * Draws the histogram * * @param plotBasePoint the histogram base point in the plot reference system */ public void draw(GPoint plotBasePoint) { if (visible) { // Calculate the baseline for the histogram float baseline = 0; if (plotBasePoint.isValid()) { baseline = (type == GPlot.VERTICAL) ? plotBasePoint.getY() : plotBasePoint.getX(); } // Draw the rectangles parent.pushStyle(); parent.rectMode(CORNERS); parent.strokeCap(SQUARE); for (int i = 0; i < plotPoints.getNPoints(); i++) { if (plotPoints.isValid(i)) { // Obtain the corners float x1, x2, y1, y2; if (type == GPlot.VERTICAL) { x1 = plotPoints.getX(i) - leftSides.get(i); x2 = plotPoints.getX(i) + rightSides.get(i); y1 = plotPoints.getY(i); y2 = baseline; } else { x1 = baseline; x2 = plotPoints.getX(i); y1 = plotPoints.getY(i) - leftSides.get(i); y2 = plotPoints.getY(i) + rightSides.get(i); } if (x1 < 0) { x1 = 0; } else if (x1 > dim[0]) { x1 = dim[0]; } if (-y1 < 0) { y1 = 0; } else if (-y1 > dim[1]) { y1 = -dim[1]; } if (x2 < 0) { x2 = 0; } else if (x2 > dim[0]) { x2 = dim[0]; } if (-y2 < 0) { y2 = 0; } else if (-y2 > dim[1]) { y2 = -dim[1]; } // Draw the rectangle float lw = lineWidths[i % lineWidths.length]; parent.fill(bgColors[i % bgColors.length]); parent.stroke(lineColors[i % lineColors.length]); parent.strokeWeight(lw); if (Math.abs(x2 - x1) > 2 * lw && Math.abs(y2 - y1) > 2 * lw) { parent.rect(x1, y1, x2, y2); } else if ((type == GPlot.VERTICAL && x2 != x1 && !(y1 == y2 && (y1 == 0 || y1 == -dim[1]))) || (type == GPlot.HORIZONTAL && y2 != y1 && !(x1 == x2 && (x1 == 0 || x1 == dim[0])))) { parent.rect(x1, y1, x2, y2); parent.line(x1, y1, x1, y2); parent.line(x2, y1, x2, y2); parent.line(x1, y1, x2, y1); parent.line(x1, y2, x2, y2); } } } parent.popStyle(); // Draw the labels if (drawLabels) { drawHistLabels(); } } }
// draw method for all of the parts of the lamp public void draw(float zoom, float color, boolean shadeDraw, boolean partsDraw) { myParent.background(100, 100, 100); if (shadeDraw) { myParent.pushMatrix(); myParent.translate(0, 0, zoom); for (int j = 0; j < shade.edges.size(); j++) { DCHalfEdge edge = shade.edges.get(j); float edgeStartX = (float) (edge.start.getX()); float edgeStartY = (float) (edge.start.getY()); float edgeEndX = (float) (edge.end.getX()); float edgeEndY = (float) (edge.end.getY()); myParent.stroke(color); myParent.strokeWeight(3); myParent.line(edgeStartX, edgeStartY, edgeEndX, edgeEndY); } myParent.popMatrix(); } if (partsDraw) { myParent.pushMatrix(); myParent.translate(myParent.width / 2 - 350, myParent.height / 2, zoom); for (int j = 0; j < rib.edges.size(); j++) { DCHalfEdge edge = rib.edges.get(j); float edgeStartX = (float) (edge.start.getX()); float edgeStartY = (float) (edge.start.getY()); float edgeEndX = (float) (edge.end.getX()); float edgeEndY = (float) (edge.end.getY()); myParent.stroke(color); myParent.strokeWeight(3); if (edge.inner) { myParent.stroke(255, 0, 0); } myParent.line(edgeStartX, edgeStartY, edgeEndX, edgeEndY); } myParent.popMatrix(); myParent.pushMatrix(); myParent.translate(100, 40, zoom); for (int j = 0; j < bottomBase.edges.size(); j++) { DCHalfEdge edge = bottomBase.edges.get(j); float edgeStartX = (float) (edge.start.getX()); float edgeStartY = (float) (edge.start.getY()); float edgeEndX = (float) (edge.end.getX()); float edgeEndY = (float) (edge.end.getY()); myParent.stroke(color); myParent.strokeWeight(3); if (edge.inner) { myParent.stroke(255, 0, 0); } myParent.line(edgeStartX, edgeStartY, edgeEndX, edgeEndY); myParent.stroke(255, 0, 0); } myParent.popMatrix(); myParent.pushMatrix(); myParent.translate(100, myParent.height - 150, zoom); for (int j = 0; j < topBase.edges.size(); j++) { DCHalfEdge edge = topBase.edges.get(j); float edgeStartX = (float) (edge.start.getX()); float edgeStartY = (float) (edge.start.getY()); float edgeEndX = (float) (edge.end.getX()); float edgeEndY = (float) (edge.end.getY()); myParent.stroke(color); myParent.strokeWeight(3); if (edge.inner) { myParent.stroke(255, 0, 0); } myParent.line(edgeStartX, edgeStartY, edgeEndX, edgeEndY); myParent.stroke(255, 0, 0); } myParent.popMatrix(); } }