Пример #1
0
  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);
  }
Пример #2
0
  /** 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();
  }
Пример #3
0
    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();
    }
Пример #4
0
 public void draw() {
   p.pushMatrix();
   p.translate(position.x, position.y);
   p.rotate(p.PI / 10);
   drawImage();
   p.popMatrix();
   // drawCollisionShapes();
 }
Пример #5
0
  // 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();
  }