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(); }
public void draw(PApplet canvas, float scale) { PVector orient = PVector.fromAngle(orientation); orient.mult(scale * getRadius()); float x = (float) position.x * scale; float y = (float) position.y * scale; float diameter = getRadius() * 2 * scale; canvas.fill(teamColor); canvas.stroke(0); canvas.ellipse(x, y, diameter, diameter); canvas.line(x, y, x + (float) orient.x, y + (float) orient.y); // Delegate Decoration to Robot float heading = orient.heading(); float drawScale = 100f / scale * getRadius(); canvas.translate(x, y); canvas.rotate(heading); canvas.scale(drawScale); // TODO: How to resolve scale, so that teams don't have to mind it also... decorateRobot(canvas); canvas.scale(1f / drawScale); canvas.rotate(-heading); canvas.translate(-x, -y); }
public void draw() { if (!logic) { myParent.stroke(line_color); } for (int x = 1; x < dim[0]; x++) { if (logic) { if (values[x] > (resolution / 2)) { myParent.stroke(logic_colors[1]); } else { myParent.stroke(logic_colors[0]); } myParent.line(pos[0] + dim[0] - x - 2, pos[1], pos[0] + dim[0] - x - 2, pos[1] + dim[1]); } else { myParent.line( pos[0] + dim[0] - x, pos[1] + dim[1] - getY(values[x - 1]) - 1, pos[0] + dim[0] - x, pos[1] + dim[1] - getY(values[x]) - 1); } } }
public void drawLegend(PApplet pg, int posX, int posY, int length, int mouseX, int mouseY) { this.posX = posX; this.posY = posY; this.length = length; this.pg = pg; // Save previous drawing style pg.pushStyle(); // color filling for (int i = posX; i <= posX + length; i++) { float inter = pg.map(i, posX, posX + length, 0, 1); int c = pg.lerpColor(fromColor, toColor, inter); pg.stroke(c); pg.line(i, posY, i, posY + 25); } // border pg.stroke(0); pg.rect(posX, posY, length, 25, 0); // title pg.fill(0); pg.textAlign(pg.CENTER); pg.text(title, posX + length / 2, posY - 10); // min and max values pg.text(minValue, posX, posY - 10); pg.text(maxValue, posX + length, posY - 10); // corresponding value shown below the color box if (isInLegend(mouseX, mouseY)) { float inter = pg.map((float) mouseX, (float) posX, (float) posX + length, minValue, maxValue); pg.fill(0); pg.text(inter, mouseX, posY + 40); } // Restore previous drawing style pg.popStyle(); }
public void draw() { // Iterate over all elements for (int i = 1; i < elementNum; i++) { // Set color p.stroke(elementColors[i]); if (i == 1) { } else { p.stroke(elementColors[i]); p.line( elements[i].x, elements[i].y, elements[i].z, elements[i - 1].x, elements[i - 1].y, elements[i - 1].z); p.noStroke(); } } }
// draw center line public void drawBounds() { myParent.stroke(bounds_color); myParent.line(pos[0], pos[1] + (dim[1] / 2), dim[0], pos[1] + (dim[1] / 2)); }
/** * 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(); } }