Пример #1
0
  @Override
  public void preRender(PApplet p) {
    super.preRender(p);

    p.rectMode(PApplet.CENTER);
    p.fill(getFillColor().getRGB());
    p.stroke(getStrokeColor().getRGB());
    p.strokeWeight(getStrokeWeight());
  }
Пример #2
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();
  }
  public void draw() {
    p.pushMatrix();
    p.pushStyle();
    p.fill(100, 100, 0);
    p.rect(0, 0, width, height);
    //  p.scale((float)ppHor, (float)ppVert);
    // p.translate(x, y);
    // p.sca
    // p.stroke(0);
    // p.strokeWeight(1.0f);
    p.noStroke();
    p.rectMode(PApplet.CORNER);

    // p.line(0, 0, 100, 100);

    // TODO: block on datset change here.
    if (d.getNumDatapoints() > minInd) {
      int which = 0;
      int i = minInd;
      for (; (i <= maxInd && i < d.getNumDatapoints()); i++) {
        Double v = d.getParam(i, myId);
        if (!v.isNaN()) {
          if (i >= minSelected && i <= maxSelected) {
            // p.stroke(0, 0, 256);
            p.noStroke();
            p.fill(hues[(int) d.getParam(i, myId)], 150, 256);
          } else {
            p.noStroke();
            p.fill(hues[(int) d.getParam(i, myId)], 256, 256);
          }
        } else {
          if (i >= minSelected && i <= maxSelected) {
            // p.stroke(0, 0, 256);
            p.noStroke();
            p.fill(200);
          } else {
            p.noStroke();
            p.fill(0);
          }
        }
        p.rect((ppHor * which++), 0, ppHor, height);
      }
    }

    p.popStyle();
    p.popMatrix();
  }
Пример #4
0
  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();
  }
Пример #5
0
  /**
   * 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();
      }
    }
  }