Examples of PGraphics


Examples of processing.core.PGraphics

  /**
   * Draws the on the PGraphics canvas.
   */
  public void draw() {
    PGraphics pg = getInnerPG();
    pg.beginDraw();

    // Clears canvas (set to transparency, to not smudge previous map on panning)
    pg.clear();
    if (bgColor != null) {
      // Set background color if given (can also be transparent)
      pg.background(bgColor);
    }

    // translate and scale, from the middle
    pg.pushMatrix();
    pg.translate((float) innerOffsetX, (float) innerOffsetY);
    if (pg.is3D()) {
      pg.applyMatrix(innerMatrix);
    } else {
      pg.applyMatrix(innerMatrix.m00, innerMatrix.m01, innerMatrix.m03, innerMatrix.m10, innerMatrix.m11,
          innerMatrix.m13);
    }

    Vector visibleKeys = getVisibleKeys(pg);

    if (visibleKeys.size() > 0) {
      Coordinate previous = (Coordinate) visibleKeys.get(0);
      pg.pushMatrix();
      pg.scale(1.0f / PApplet.pow(2, previous.zoom));

      for (int i = 0; i < visibleKeys.size(); i++) {
        Coordinate coord = (Coordinate) visibleKeys.get(i);
        if (coord.zoom != previous.zoom) {
          pg.popMatrix();
          pg.pushMatrix();
          pg.scale(1.0f / PApplet.pow(2, coord.zoom));
        }

        if (images.containsKey(coord)) {
          PImage tile = (PImage) images.get(coord);

          float x = coord.column * TILE_WIDTH;
          float y = coord.row * TILE_HEIGHT;

          // REVISIT For transparency, do not paint image (why no transparent imgs?)
          pg.image(tile, x, y, TILE_WIDTH, TILE_HEIGHT);

          if (recent_images.contains(tile)) {
            recent_images.remove(tile);
          }
          recent_images.add(tile);
        }
      }
      pg.popMatrix();
    }

    pg.popMatrix();
    pg.endDraw();

    postDraw();

    cleanupImageBuffer();
  }
View Full Code Here

Examples of processing.core.PGraphics

    return GeoUtils.getCentroid(locations);
  }

  @Override
  public void draw(UnfoldingMap map) {
    PGraphics pg = map.mapDisplay.getOuterPG();

    List<MapPosition> mapPositions = new ArrayList<MapPosition>();

    for (Location loc : getLocations()) {
      float[] xy = map.mapDisplay.getObjectFromLocation(loc);
View Full Code Here

Examples of processing.core.PGraphics

  private static final int TILE_HEIGHT = 256;

  // Create debug tile, and draw it on top of the loaded tile
  public static PImage getDebugTile(Coordinate coord, PImage tileImage, PApplet p, boolean showDebugBorder,
      boolean showTileCoordinates) {
    PGraphics pg = p.createGraphics(TILE_WIDTH, TILE_HEIGHT, PApplet.P2D);
    pg.beginDraw();

    if (tileImage != null) {
      pg.image(tileImage, 0, 0);
    } else {
      pg.background(250);
      pg.stroke(0);
      pg.rect(0, 0, pg.width, pg.height);
      pg.ellipse(pg.width / 2, pg.height / 2, pg.width - 5, pg.height - 5);
    }

    if (showTileCoordinates) {
      pg.fill(0);
      String infoText = (int) coord.column + ", " + (int) coord.row + "\nz: " + (int) coord.zoom;
      pg.text(infoText, pg.width / 2 - pg.textWidth(infoText) / 2, pg.height / 2 - 10);
    }

    if (showDebugBorder) {
      pg.strokeWeight(2);
      pg.stroke(255, 0, 0, 100);
      pg.noFill();
      pg.rect(0, 0, pg.width, pg.height);
    }

    pg.endDraw();
    return pg.get();
  }
View Full Code Here

Examples of processing.core.PGraphics

    }
    offscreenCutoffPG.endDraw();

    // Transforms (outer) map pane, and draws inner map + marker onto canvas
    // This cuts off marker at the border.
    PGraphics canvasPG = papplet.g;
    canvasPG.pushMatrix();
    canvasPG.translate(offsetX, offsetY);
    if (canvasPG.is3D()) {
      canvasPG.applyMatrix(matrix);
    } else {
      canvasPG.applyMatrix(matrix.m00, matrix.m01, matrix.m03, matrix.m10, matrix.m11, matrix.m13);
    }
    if (mapDisplayShader != null) {
      mapDisplayShader.shadeWithMarkers(canvasPG);
    }
    canvasPG.pushStyle();
    canvasPG.image(offscreenCutoffPG, 0, 0);
    canvasPG.popStyle();
    canvasPG.popMatrix();
    // canvasPG.resetShader();
  }
View Full Code Here

Examples of processing.core.PGraphics

    thumbnail = getCircularImage(thumbnail, 200, 5);
  }

  // By amnon.owed, http://forum.processing.org/topic/extract-circle-texture-from-background-with-alpha-channel
  public PImage getCircularImage(PImage img, int radius, int feather) {
    PGraphics temp = p.createGraphics(img.width, img.height, PConstants.JAVA2D);
    temp.beginDraw();
    temp.smooth();
    temp.translate(temp.width / 2, temp.height / 2);
    temp.imageMode(PConstants.CENTER);
    temp.image(img, 0, 0);
    temp.endDraw();
    PImage saveArea = p.createImage(temp.width, temp.height, PConstants.ARGB);
    for (int y = 0; y < saveArea.height; y++) {
      for (int x = 0; x < saveArea.width; x++) {
        int index = y + x * saveArea.width;
        float d = PApplet.dist(x, y, radius, radius);
View Full Code Here

Examples of processing.core.PGraphics

    thumbnail = getCircularImage(thumbnail, 200, 5);
  }

  // By amnon.owed, http://forum.processing.org/topic/extract-circle-texture-from-background-with-alpha-channel
  public PImage getCircularImage(PImage img, int radius, int feather) {
    PGraphics temp = p.createGraphics(img.width, img.height, PConstants.JAVA2D);
    temp.beginDraw();
    temp.smooth();
    temp.translate(temp.width / 2, temp.height / 2);
    temp.imageMode(PConstants.CENTER);
    temp.image(img, 0, 0);
    temp.endDraw();
    PImage saveArea = p.createImage(temp.width, temp.height, PConstants.ARGB);
    for (int y = 0; y < saveArea.height; y++) {
      for (int x = 0; x < saveArea.width; x++) {
        int index = y + x * saveArea.width;
        float d = PApplet.dist(x, y, radius, radius);
View Full Code Here

Examples of processing.core.PGraphics

    // Stores information of the current state of the map
    this.location = map.getCenter();
    this.zoomLevel = map.getZoomLevel();

    // Stores image data of the current map
    PGraphics pg = map.mapDisplay.getOuterPG();
    thumbnail = pg.get();
  }
View Full Code Here

Examples of processing.core.PGraphics

    }
  }

  private void extendCentreImage(){
    int tl = (int)trackLength;
    PGraphics pg = winApp.createGraphics(tl, centre.height, JAVA2D);
    int rem = tl % centre.width;
    int n = tl / centre.width;
    n = (rem == 0) ? n : n + 1;
    int px = (tl - centre.width * n)/2;
    pg.beginDraw();
    pg.background(winApp.color(255,0));
    pg.imageMode(CORNER);

    while(px < tl){
      pg.image(centre, px, 0);
      px += centre.width;
    }

    pg.endDraw();
    centre = pg;
  }
View Full Code Here

Examples of processing.core.PGraphics

    }

    if (lastPressed != null && triangleOnSelected)
    {
      MenuItem i = lastPressed;
      PGraphics pg = canvas.g;
      int alpha = (int) (menu.alpha * 255);
      Color c = menu.style.strokeColor;
      pg.fill(menu.canvas.color(c.getRed(), c.getGreen(), c.getBlue(),
          alpha));

      float height = i.getWidth() / 8;
      switch (rotation.rot)
      {
        case (LEFT):
          float cy = i.getY() + i.getHeight() / 2;
          float cx = inset + menu.style.padX;
          pg.triangle(cx, cy + height, cx, cy - height, cx + height,
              cy);
          i.setPosition(i.getX() + height, i.getY());
          break;
        case (RIGHT):
          cy = i.getY() + i.getHeight() / 2;
          cx = canvas.width - inset - menu.style.padX;
          pg.triangle(cx, cy + height, cx, cy - height, cx - height,
              cy);
          i.setPosition(i.getX() - height, i.getY());
          break;
        case (TOP):
          cy = inset + menu.style.padY;
          cx = i.getX() + i.getWidth() / 2;
          pg.triangle(cx + height, cy, cx - height, cy, cx, cy
              + height);
          i.setPosition(i.getX(), i.getY() + height);
          break;
        case (BOTTOM):
          cy = canvas.width - inset - menu.style.padY;
          cx = i.getX() + i.getWidth() / 2;
          pg.triangle(cx + height, cy, cx - height, cy, cx, cy
              - height);
          i.setPosition(i.getX(), i.getY() - height);
          break;
      }
    }
View Full Code Here

Examples of processing.core.PGraphics

    }

    void positionItem(MenuItem item, float pos)
    {
      DockItem d = (DockItem) item;
      PGraphics pg = canvas.g;
      switch (rot)
      {
        case (LEFT):
          d.setPosition(inset, pos);
          break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.