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); }
/** Draws the histogram labels */ protected void drawHistLabels() { parent.pushStyle(); parent.textMode(MODEL); parent.textFont(font); parent.textSize(fontSize); parent.fill(fontColor); parent.noStroke(); if (type == GPlot.VERTICAL) { if (rotateLabels) { parent.textAlign(RIGHT, CENTER); for (int i = 0; i < plotPoints.getNPoints(); i++) { if (plotPoints.isValid(i) && plotPoints.getX(i) >= 0 && plotPoints.getX(i) <= dim[0]) { parent.pushMatrix(); parent.translate(plotPoints.getX(i), labelsOffset); parent.rotate(-HALF_PI); parent.text(plotPoints.getLabel(i), 0, 0); parent.popMatrix(); } } } else { parent.textAlign(CENTER, TOP); for (int i = 0; i < plotPoints.getNPoints(); i++) { if (plotPoints.isValid(i) && plotPoints.getX(i) >= 0 && plotPoints.getX(i) <= dim[0]) { parent.text(plotPoints.getLabel(i), plotPoints.getX(i), labelsOffset); } } } } else { if (rotateLabels) { parent.textAlign(CENTER, BOTTOM); for (int i = 0; i < plotPoints.getNPoints(); i++) { if (plotPoints.isValid(i) && -plotPoints.getY(i) >= 0 && -plotPoints.getY(i) <= dim[1]) { parent.pushMatrix(); parent.translate(-labelsOffset, plotPoints.getY(i)); parent.rotate(-HALF_PI); parent.text(plotPoints.getLabel(i), 0, 0); parent.popMatrix(); } } } else { parent.textAlign(RIGHT, CENTER); for (int i = 0; i < plotPoints.getNPoints(); i++) { if (plotPoints.isValid(i) && -plotPoints.getY(i) >= 0 && -plotPoints.getY(i) <= dim[1]) { parent.text(plotPoints.getLabel(i), -labelsOffset, plotPoints.getY(i)); } } } } parent.popStyle(); }
/** * Updates the particle view. This should be called on each draw cycle in order to update the * positions of all nodes and edges in the viewer. If you need to update the positions of * particles without drawing it (e.g. to speed up movement, call updateParticles() instead. */ public void draw() { parent.pushStyle(); parent.pushMatrix(); zoomer.transform(); updateCentroid(); centroid.tick(); parent.translate(width / 2, height / 2); parent.scale(centroid.getZ()); parent.translate(-centroid.getX(), -centroid.getY()); if (!isPaused) { updateParticles(); } // Ensure that any selected element is positioned at the mouse location. if (selectedNode != null) { Particle p = nodes.get(selectedNode); p.makeFixed(); float mX = (zoomer.getMouseCoord().x - (width / 2)) / centroid.getZ() + centroid.getX(); float mY = (zoomer.getMouseCoord().y - (height / 2)) / centroid.getZ() + centroid.getY(); p.position().set(mX, mY, 0); } // Draw edges if we have positive stroke weight. if (parent.g.strokeWeight > 0) { parent.stroke(0, 180); parent.noFill(); for (Map.Entry<E, Spring> row : edges.entrySet()) { E edge = row.getKey(); Spring spring = row.getValue(); Vector3D p1 = spring.getOneEnd().position(); Vector3D p2 = spring.getTheOtherEnd().position(); edge.draw(parent, p1.x(), p1.y(), p2.x(), p2.y()); } } // Draw nodes. parent.noStroke(); parent.fill(120, 50, 50, 180); for (Map.Entry<N, Particle> row : nodes.entrySet()) { N node = row.getKey(); Vector3D p = row.getValue().position(); node.draw(parent, p.x(), p.y()); } parent.popMatrix(); parent.popStyle(); }
public void drawJunction() { parent.pushMatrix(); if (stroke_color[0] != -1) { int[] rgb = RecursiveTower.hsvToRgb(stroke_color[0], stroke_color[1], stroke_color[2]); parent.stroke(rgb[0], rgb[1], rgb[2]); } else { parent.noStroke(); } if (fill_color[0] != -1) { int[] rgb = RecursiveTower.hsvToRgb(fill_color[0], fill_color[1], fill_color[2]); parent.fill(rgb[0], rgb[1], rgb[2]); } else { parent.noFill(); } switch (tower_orientation) { case 0: // moving in +x direction // +x becomes +y, +y becomes +z, +z becomes +x parent.translate(z, x, y); parent.box(z_dim, x_dim, y_dim); break; case 1: // moving in -x direction // +x becomes +y, +y becomes +z, +z becomes -x parent.translate(-z, x, y); parent.box(z_dim, x_dim, y_dim); break; case 2: // moving in +y direction // x stays the same, +y becomes +z, +z becomes +y parent.translate(x, z, y); parent.box(x_dim, z_dim, y_dim); break; case 3: // moving in -y direction // x stays the same, +y becomes +z, +z becomes -y parent.translate(x, -z, y); parent.box(x_dim, z_dim, y_dim); break; case 4: // moving in +z direction // xyz coordinates stay the same parent.translate(x, y, z); parent.box(x_dim, y_dim, z_dim); break; } parent.popMatrix(); }
/** @param theApplet PApplet */ @ControlP5.Invisible public void draw(PApplet theApplet) { theApplet.pushMatrix(); theApplet.translate(position.x, position.y); _myControllerView.display(theApplet, this); theApplet.popMatrix(); }
public void draw() { p.pushMatrix(); p.translate(position.x, position.y); p.rotate(p.PI / 10); drawImage(); p.popMatrix(); // drawCollisionShapes(); }
public void drawJunction() { parent.pushMatrix(); parent.translate(x, y, z); parent.stroke(255, 255, 255); parent.fill(255); // 0, 0, 0, 0); parent.box(x_dim, y_dim, z_dim); parent.popMatrix(); }
public void display(PApplet theApplet, Controller<?> theController) { _myHeight = _myLabel.getHeight(); theApplet.fill(_myBackgroundColor, _myAlpha); theApplet.rect(0, 0, getWidth() + _myBorder * 2, _myHeight + _myBorder * 2); theApplet.pushMatrix(); if (_myAlignH == ControlP5.RIGHT) { theApplet.translate(6, 0); } else { theApplet.translate(getWidth() - 6, 0); } theApplet.triangle(0, 0, 4, -4, 8, 0); theApplet.popMatrix(); int a = (int) (PApplet.map(_myAlpha, 0, _myMaxAlpha, 0, 255)); _myLabel.setColor( a << 24 | (_myColor >> 16) << 16 | (_myColor >> 8) << 8 | (_myColor >> 0) << 0); _myLabel.draw(theApplet, 0, 0, theController); }
public void draw() { PVector v = getBezierPoint3D(); p.stroke(color, 50); p.pushMatrix(); p.translate(v.x, v.y, v.z); p.sphere(2); p.popMatrix(); }
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(); }
/** * @exclude * @param theApplet PApplet */ @ControlP5.Invisible public final void draw(PApplet theApplet) { if (isVisible) { theApplet.pushMatrix(); theApplet.translate(position.x, position.y); preDraw(theApplet); drawControllers(theApplet); postDraw(theApplet); if (_myValueLabel != null) { _myValueLabel.draw(theApplet, 2, 2, this); } theApplet.popMatrix(); } }
// 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(); }
/** * Draws the control where if should be drawn * * @param p */ public void draw() { p.pushMatrix(); p.pushStyle(); p.translate(x, y); p.fill(textColor); // AlignUtils.positionText(p, width, height, xAlign, yAlign); p.textAlign(PApplet.LEFT, PApplet.CENTER); p.text(name, 0, height / 2); // p.text(name, 0, 0); p.popStyle(); p.popMatrix(); }
// 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(); } }
private void doTransformation(float _x, float _y) { // applet.translate(layer.x + _x, layer.y + _y, layer.z); // This, with the changes in draw, seems to work better applet.translate(_x, _y, layer.z); applet.scale(layer.scale, layer.scale, 1); }