Examples of PGraphics


Examples of processing.core.PGraphics

    applet.translate(labelBottom.getLeft(), labelBottom.getTop());
    applet.rect(0, 0, labelBottom.getWidth(), labelBottom.getHeight());
    applet.popMatrix();

    // prepare for the 'clipping' (drawing  into an offline graphics port)
    PGraphics pg = applet.createGraphics(content.getWidth(), content.getHeight(), PConstants.JAVA2D);
    pg.beginDraw();
    // draw the graphs
    pg.noFill();
    pg.pushMatrix();
    pg.translate(0, content.getHeight() / 2);
    // iterate through all the graphs
    for (GraphData graph : graphs.values()) {
      pg.beginShape();
      pg.stroke(graph.color);
      for (int i=0; i<graph.data.length; ++ i) {
        pg.curveVertex(i, (float )graph.data[i]);
      }
      pg.endShape();
    }
    pg.popMatrix();
    // do the 'clipping' (copy the offline graphics port into the applet's graphics port)
    pg.endDraw();
    applet.image(pg, content.getLeft(), content.getTop());
   
    // draw all the graph's labels
    applet.pushMatrix();
    applet.translate(labelBottom.getLeft(), labelBottom.getTop());
View Full Code Here

Examples of processing.core.PGraphics

   * from the <code>draw</code> method of the Processing Development Environment. This
   * ensures that the horizon is updated periodically.
   */
  public void draw() {
    // prepare for 'clipping' (drawing  into an offline graphics port)
    PGraphics pg = applet.createGraphics((int )content.getWidth(), (int )content.getHeight(), PApplet.JAVA2D);
    pg.beginDraw();
   
    // get the current angles for pitch and roll and convert them to radian degrees
    double pitchAngle = Math.toRadians(pitch.getValue());
    double rollAngle = Math.toRadians(roll.getValue());
    // get the current values for elevator and aileron and convert them to angles (according to the maximum deflection for the flaps)
    double maxFlapDefelction = maxDeflection / 2; // max deflection in one direction
    double midElevator = elevator.getLow() + (elevator.getBandwidth() / 2);
    double elevatorVlaue = (elevator.getValue() - midElevator);
    double maxElevatorSignal = (elevator.getBandwidth()/2);
    double elevatorAngle =  Math.toRadians(maxFlapDefelction * elevatorVlaue / maxElevatorSignal);
    double midAileron = aileron.getLow() + (aileron.getBandwidth() / 2);
    double aileronVlaue = (aileron.getValue() - midAileron);
    double maxAileronSignal = (aileron.getBandwidth()/2);
    double aileronAngle =  Math.toRadians(maxFlapDefelction * aileronVlaue / maxAileronSignal);

    // initialize the graphics environment
    applet.fill(Colors.GRAY_BACKGROUND);
    applet.stroke(Colors.STROKE);
    applet.strokeWeight(1);

    // draw the horizon
    double radius = (content.getHeight() / 2);
    pg.pushMatrix();
    pg.translate(0, (float )radius);
    // draw the ground (background)
    pg.fill(COLOR_GROUND);
    pg.rect(0, (float )-radius, content.getWidth(), content.getHeight());
    // draw the sky (pitch input)
    pg.fill(COLOR_SKY);
    if (Math.cos(pitchAngle) > 0) {
      pg.rect(0, (float )(Math.sin(pitchAngle) * radius), content.getWidth(), -content.getHeight());
    }
    else {
      pg.rect(0, (float )-(Math.sin(pitchAngle) * radius), content.getWidth(), content.getHeight());
    }
    pg.popMatrix();
   
    // draw the indicator (elevator and aileron input)
    double elevatorOffset = Math.sin(elevatorAngle) * radius;
    int wingLength = content.getWidth() / 4;
    int rudderHeight = wingLength / 2;
    int indicatorOversize = wingLength / 4;
    int fuselageRadius = wingLength / 3;
    pg.fill(COLOR_INDICATOR);
    pg.stroke(COLOR_INDICATOR);
    pg.pushMatrix();
    pg.translate(content.getWidth() / 2, content.getHeight() / 2 + (float )elevatorOffset);
    pg.rotate((float )aileronAngle);
    pg.strokeWeight(3);
    pg.line(-wingLength - indicatorOversize, 0, wingLength + indicatorOversize, 0);
    pg.line(0, 0, 0, - (rudderHeight + indicatorOversize));
    pg.strokeWeight(1);
    pg.ellipse(0, 0, fuselageRadius, fuselageRadius);
    pg.popMatrix();

    // draw the airplane (roll input)
    pg.fill(COLOR_PLANE);
    pg.stroke(COLOR_PLANE);
    pg.pushMatrix();
    pg.translate(content.getWidth() / 2, content.getHeight() / 2);
    pg.rotate((float )rollAngle);
    pg.strokeWeight(3);
    pg.line(-wingLength, 0, wingLength, 0);
    pg.line(0, 0, 0, - rudderHeight);
    pg.strokeWeight(1);
    pg.ellipse(0, 0, fuselageRadius, fuselageRadius);
    pg.popMatrix();

    // do the 'clipping' (copy the offline graphics port into the applet's graphics port)
    pg.endDraw();
    applet.image(pg, content.getLeft(), content.getTop());

    // draw a frame around the whole component
    applet.noFill();
    applet.strokeWeight(1);
View Full Code Here

Examples of processing.core.PGraphics

                    .withWordPadding(4)
                    .withPlacer(Placers.centerClump());

            ImageConfiguration imageConfig = parseArgs(args, wordCram);

            PGraphics image = processing.createGraphics(imageConfig.width, imageConfig.height, JAVA2D);
            try {
                wordCram.withCustomCanvas(image);

                image.beginDraw();
                wordCram.drawAll();
                image.endDraw();

                image.save(imageConfig.fileName);

            } finally {
                image.dispose();
            }

            processing.stop();
            System.exit(0);
View Full Code Here

Examples of processing.core.PGraphics

  }

  static void save(OutputStream stream, String name) {

    if (GLOBAL.sketchChairs.getCurChair() != null) {
      PGraphics saveImg = GLOBAL.sketchChairs.getCurChair()
          .renderToFile();

      if (saveImg.width > 0 && saveImg.height > 0)
        saveImg.save(name + ".png");

    }

  }
View Full Code Here

Examples of processing.core.PGraphics

    // System.out.println("out: Y world " + minY + ": "+maxY + ":"+height);
    // System.out.println("out: Y model " + minY2 + ": "+maxY2 +
    // ":"+height2);

    // System.out.println(currentWorldTransform.origin.x);
    PGraphics saveImg = GLOBAL.applet.createGraphics((int) width,
        (int) height, PConstants.P3D);
    saveImg.beginDraw();
    saveImg.ortho(-(width / 2), (width / 2), -(height / 2), (height / 2),
        -1000, 10000);
    //saveImg.hint(PApplet.DISABLE_STROKE_PERSPECTIVE);

    saveImg.ambientLight(200, 200, 200);
    saveImg.directionalLight(69, 69, 69, 0, 0, -1);
    saveImg.lightFalloff(1, 0, 0);

    saveImg.smooth(8);

    saveImg.background(255);

    saveImg.pushMatrix();
    // this.applyTranslationMatrix(g);

    saveImg.translate(-minX + border, -minY + border);
    saveImg.translate(width / 2, height / 2, -(this.getWidth() / 4));
    saveImg.rotateX(rotateX);
    saveImg.rotateY(rotateY);
    saveImg.translate(-width / 2, -height / 2, (this.getWidth() / 4));
    this.render(saveImg);
    // this.renderSilhouette(saveImg);

    saveImg.popMatrix();
    saveImg.endDraw();
    GLOBAL.screenshot = false;

    GLOBAL.rotateModelsY = rememberY;
    GLOBAL.rotateModelsX = rememberX;
    return saveImg;
View Full Code Here

Examples of processing.core.PGraphics

    int OPENGL = 2;
    int SUNFLOW = 3;

    int renderMode = OPENGL;

    PGraphics diagramImg = null;
    //P5SunflowAPIAPI sunflow = null;

    float scale = 1f;
    w = (int) (w * scale);
    h = (int) (h * scale);

    float minX = this.getSlicePlanesY().getMinX();
    float minY = this.getSlicePlanesY().getMinY();
    float maxX = this.getSlicePlanesY().getMaxX();
    float maxY = this.getSlicePlanesY().getMaxY();

    float width = Math.abs(maxX - minX);
    float height = Math.abs(maxY - minY);

    float widthDelta = w / width;
    float heightDelta = h / height;

    float delta = Math.min(widthDelta, heightDelta);

    //glewIsSupported("GL_EXT_framebuffer_multisample");
    /*
   
    GL gl = ((PGraphicsOpenGL) GLOBAL.applet.g).gl;
    GLState state = new GLState(gl);
    */
    //boolean useVBO = true;//state.vbosAvailable;

    if (renderMode == P3D)
      diagramImg = GLOBAL.applet.createGraphics(w, h, GLOBAL.applet.P3D);

    if (renderMode == OPENGL)
      diagramImg = GLOBAL.applet.createGraphics(w, h, GLOBAL.applet.OPENGL);


    /*
    if (renderMode == SUNFLOW) {
      diagramImg = GLOBAL.applet.createGraphics(w, h,
          "sunflowapiapi.P5SunflowAPIAPI");
      sunflow = (P5SunflowAPIAPI) diagramImg;
      // set shader
      //sunflow.setDiffuseShader();
    }
*/
    diagramImg.beginDraw();
    //diagramImg.background(255,255,255,1);
    diagramImg.ortho(-(w / 2), (w / 2), -(h / 2), (h / 2), -1000, 10000);
    //diagramImg.hint(PApplet.DISABLE_STROKE_PERSPECTIVE);

    diagramImg.pushMatrix();
    diagramImg.smooth(8);

    if (useCurrentView) {

      diagramImg.translate(w / 2, h / 2, 0);

      if (rotateX == -1 && rotateY == -1) {
        diagramImg.rotateX(GLOBAL.rotateModelsX);
        diagramImg.rotateY(GLOBAL.rotateModelsY);
      } else {
        diagramImg.rotateX(rotateX);
        diagramImg.rotateY(rotateY);
      }
      diagramImg.scale((float) GLOBAL.getZOOM());
      diagramImg.scale(scale);

      //we scaled up so now we need to scale the window width move
      diagramImg.translate((-(w / scale) / 2) + (float)(GLOBAL.CAM_OFFSET_X),
          (-(h / scale) / 2) + (float)(GLOBAL.CAM_OFFSET_Y));

      //this.applyTranslationMatrix(diagramImg);

    } else {
      diagramImg.translate(w / 2, h / 2, 0);

      if (rotateX == -1 && rotateY == -1) {
        diagramImg.rotateX(GLOBAL.rotateModelsX);
        diagramImg.rotateY(GLOBAL.rotateModelsY);
      } else {
        diagramImg.rotateX(rotateX);
        diagramImg.rotateY(rotateY);
      }

      diagramImg.scale((float) GLOBAL.getZOOM());
      diagramImg.scale(scale);

      //this.applyTranslationMatrix(diagramImg);

      this.centreFillWindow(diagramImg, w, h, scale);

    }
    //g.translate(-minX , -minY);
    //g.translate(-minX , -minY);
    ///g.translate(((width/2)) , ((height/2)) );
    //g.rotateX(45);
    //g.translate(-((width/2)) , -((height/2)) );
    //g.translate(x/delta,y/delta);
    //RENDER_3D_PREVIW

    // if(GLOBAL.jBullet.physics_on)
    this.slicePlanesY.setRenderMode(Sketch.RENDER_3D_DIAGRAM);
    this.slicePlanesY.render(diagramImg);
    this.slicePlanesSlatSlices.setRenderMode(Sketch.RENDER_3D_DIAGRAM);
    this.slicePlanesSlatSlices.render(diagramImg);

    //this.slicePlanesX.render(g);

    diagramImg.popMatrix();
    diagramImg.endDraw();

    /*
    if (renderMode == SUNFLOW) {
      sunflow.setPathTracingGIEngine(8);
      sunflow.render();
View Full Code Here

Examples of processing.core.PGraphics

    float height = Math.abs(maxY - minY) + +(imgBorder * 2);

    float width2 = Math.abs(maxX2 - minX2) + (imgBorder * 2);
    float height2 = Math.abs(maxY2 - minY2) + (imgBorder * 2);

    PGraphics saveImg = GLOBAL.applet.createGraphics((int) width,
        (int) height, PConstants.P3D);
    saveImg.beginDraw();
    saveImg.ortho(-(width / 2), (width / 2), -(height / 2), (height / 2),
        -1000, 10000);
    //saveImg.hint(PApplet.DISABLE_STROKE_PERSPECTIVE);

    saveImg.smooth(8);
    saveImg.pushMatrix();

    saveImg.translate(-minX + border, -minY + border);
    this.renderSilhouette(saveImg);

    saveImg.popMatrix();
    saveImg.endDraw();
    return saveImg;

  }
View Full Code Here

Examples of processing.core.PGraphics

     }

    
    //GLGraphics renderer = (GLGraphics)g;
    PGraphics renderer = (PGraphics)g;

    //if(useGLGRAPHICS)
      //renderer.beginGL();
   
   
    //if not in focus don't worry about running the draw loop
    if(!focused && !GLOBAL.skchAutomatic.hasChairToProcess() && !firstLoop && !startingApp){
      frameRate(1);
    //  return;
    }else{
      frameRate(120);
    }
   
    if(SETTINGS.autoReset && millis() - lastMouseMove > (SETTINGS.autoResetSeconds*1000)){
      GLOBAL.uiTools.reset(null);
      lastMouseMove = millis();
    }
     
    if(mouseX != pmouseX || mouseY != pmouseY)
    lastMouseMove = millis();

    GLOBAL.gui.update();
   
   

   
    //SKetchGlobals
    if ((GLOBAL.rotateModelsX != 0 || GLOBAL.rotateModelsY != 0))
      GLOBAL.SketchGlobals.renderVolume = true;
    else
      GLOBAL.SketchGlobals.renderVolume = false;

    GLOBAL.SketchGlobals.physicsEngineScale = GLOBAL.jBullet.scale;
    GLOBAL.SketchGlobals.mousePressed = mousePressed;
   
   
   
    if(width != GLOBAL.windowWidth || height != GLOBAL.windowHeight)
    resize();
    //renderer.noSmooth();

    //make sure we always have a chair to edit
    if (GLOBAL.sketchChairs.getCurChair() == null) {
      SketchChair curChair = new SketchChair();
      GLOBAL.sketchChairs.add(curChair);
    }

    //tittle images
    if (GLOBAL.tittleImg != null || GLOBAL.myMovie != null) {
      background(250, 250, 250);
      renderer.imageMode(CENTER);

      if (GLOBAL.myMovie != null) {
        renderer.pushMatrix();
        renderer.scale(1.6f);
        //   image(GLOBAL.myMovie,width/3.2f,height/3.2f);
        renderer.popMatrix();
        renderer.image(GLOBAL.clickToStart, width / 2, height - 25);

      } else {
        renderer.image(GLOBAL.tittleImg, width / 2, height / 2);
      }
      renderer.imageMode(CORNER);
      renderer.image(UITools.SELECT_TOOL_CURSOR, mouseX - 10, mouseY - 8);
      //mouse clicked
      //if(mousePressed && !this.mouseDown && millis() > 1000){
      if (pmouseX != mouseX && millis() - GLOBAL.inativeCounter > 3000) {
        GLOBAL.tittleImageNum++;

        if (GLOBAL.myMovie != null) {
          //if(functions.fileExists("./introVideos/" + GLOBAL.tittleImageNum + ".mov"))
          //  GLOBAL.myMovie = new FasterMovie(this,"./introVideos/"+GLOBAL.tittleImageNum+".mov");
          //else
          //  GLOBAL.myMovie = null;

        } else {
          if (functions.fileExists("./tittleImage/"
              + GLOBAL.tittleImageNum + ".jpg"))
            GLOBAL.tittleImg = loadImage("./tittleImage/"
                + GLOBAL.tittleImageNum + ".jpg");
          else
            GLOBAL.tittleImg = null;
        }
        //reset the timeout counter
        GLOBAL.inativeCounter = millis();
      }

      if (mousePressed)
        this.mouseDown = true;
      else
        this.mouseDown = false;

      return;
    }

    if (mouseY != pmouseY || mouseX != pmouseX)
      GLOBAL.inativeCounter = millis();

    //if (millis() - GLOBAL.inativeCounter > GLOBAL.timeoutCounter) {
      /*
      setup();
      GLOBAL.tittleImageNum = 0;
      GLOBAL.inativeCounter = millis();
      GLOBAL.myMovie = new FasterMovie(this,"./introVideos/"+GLOBAL.tittleImageNum+".mov");
      GLOBAL.myMovie.loop();
      //GLOBAL.tittleImg = loadImage("./tittleImage/" + GLOBAL.tittleImageNum + ".jpg"); 
       */

    //}

    GLOBAL.windowWidth = width;
    GLOBAL.windowHeight = height;

    if (!GLOBAL.performanceMode) {

    }

    UI.toggleButtons();
 
      float cameraY = (float) (height/2.0);
      float fov = (width) * PI/2;
      float cameraZ = 0;
      float aspect = (width)/(height);
      if (mousePressed) {
        aspect = (float) (aspect / 2.0);
      }
     
     
    
    //LOGGER.info(width + "width");
    //renderer.ortho();
    /*
    if(useGLGRAPHICS){
    ortho(-(int)(width / 2), (int)(width / 2), -(int)(height / 2), (int)(height / 2),
        -1000, 1000);
      //renderer.translate((width /2), (height / 2));
    //renderer.ortho();
    }else{
    renderer.ortho(-(int)(width / 2), (int)(width / 2), -(int)(height / 2), (int)(height / 2),
        -1000, 10000);
    }
    */
      renderer.ortho(-(int)(width / 2), (int)(width / 2), -(int)(height / 2), (int)(height / 2),
          -10000, 10000);
      //renderer.hint(PApplet.DISABLE_STROKE_PERSPECTIVE);

     //frustum();
    //camera();
    //perspective();
   
    //GLOBAL.uiTools.pickBuffer.background(255);
    renderer.noFill();
    renderer.strokeWeight(2)
     
    //GLOBAL.uiTools.update();
    UI.updateMouse(mouseX, mouseY, pmouseX, pmouseY, mousePressed,
        mouseButton);

View Full Code Here

Examples of processing.core.PGraphics

    }
   
        }

  void renderSunflow() {
    PGraphics gSun = createGraphics(width, height, "hipstersinc.P5Sunflow");

    //P5Sunflow sunflow = new P5Sunflow();
    //sunflow.setParent(this);

    // sunflow.width = width;
    //sunflow.height = height;
    // sunflow.allocate();

    // gSun.camera();

    gSun.loadPixels();
    gSun.beginDraw();
    gSun.ortho(-(width / 2), (width / 2), -(height / 2), (height / 2),
        -1000, 10000);

    applyWorldTranslation(gSun);
    GLOBAL.sketchChairs.render(gSun);

    gSun.updatePixels();
    gSun.endDraw();
    gSun.save("render.png");
    //P5Sunflow sunflow = (P5Sunflow) g;

  }
View Full Code Here

Examples of processing.core.PGraphics

  boolean clickStartedOn = false;
  public boolean renderOnUpdate = true; //only render components when they're updated or mouse is over.
  public boolean rebuildStencilBuffer = true;
  public static PImage makeImgDown(float w, float h, PImage img) {

    PGraphics pg = appletStatic.createGraphics((int) w, (int) h,
        PApplet.JAVA2D);
    pg.smooth();
    pg.beginDraw();
   
    pg.noStroke();
    pg.background(255);
    pg.rect(0,0,w,h);
   
   
    pg.smooth();
    pg.stroke(200, 200, 200);
    pg.fill(194, 217, 216);

    pg.strokeWeight(1);

    roundrect(pg, 0, 0, w + 4, h + 4, 4);

    //pg.strokeWeight(2);
    //pg.stroke(100, 100, 100);

    //roundrectLeft(pg, 2, 2, w - 4, h - 4, 4);

    int offsetX = (int) ((w - img.width) / 2);
    int offsetY = (int) ((h - img.height) / 2);
    pg.image(img, (int)offsetX, (int)offsetY);
    pg.endDraw();
    return pg;

  }
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.