Package processing.core

Examples of processing.core.PImage


        //Create the scene in which we actually draw
        drawingScene = new DrawSurfaceScene(pa, "DrawSurface Scene");
        drawingScene.setClear(false);
      
        //Create texture brush
        PImage brushImage = getMTApplication().loadImage(imagesPath + "brush1.png");
    textureBrush = new MTRectangle(brushImage, getMTApplication());
    textureBrush.setPickable(false);
    textureBrush.setNoFill(false);
    textureBrush.setNoStroke(true);
    textureBrush.setDrawSmooth(true);
    textureBrush.setFillColor(new MTColor(0,0,0));
    //Set texture brush as default
    drawingScene.setBrush(textureBrush);
   
    //Create pencil brush
    pencilBrush = new MTEllipse(pa, new Vector3D(brushImage.width/2f,brushImage.height/2f,0), brushImage.width/2f, brushImage.width/2f, 60);
    pencilBrush.setPickable(false);
    pencilBrush.setNoFill(false);
    pencilBrush.setNoStroke(false);
    pencilBrush.setDrawSmooth(true);
    pencilBrush.setStrokeColor(new MTColor(0, 0, 0, 255));
    pencilBrush.setFillColor(new MTColor(0, 0, 0, 255));
   
        //Create the frame/window that displays the drawing scene through a FBO
//        final MTSceneTexture sceneWindow = new MTSceneTexture(0,0, pa, drawingScene);
    //We have to create a fullscreen fbo in order to save the image uncompressed
    final MTSceneTexture sceneTexture = new MTSceneTexture(pa,0, 0, pa.width, pa.height, drawingScene);
        sceneTexture.getFbo().clear(true, 255, 255, 255, 0, true);
        sceneTexture.setStrokeColor(new MTColor(155,155,155));
        frame.addChild(sceneTexture);
       
        //Eraser button
        PImage eraser = pa.loadImage(imagesPath + "Kde_crystalsvg_eraser.png");
        MTImageButton b = new MTImageButton(eraser, pa);
        b.setNoStroke(true);
        b.translate(new Vector3D(-50,0,0));
        b.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent ae) {
        switch (ae.getID()) {
        case TapEvent.BUTTON_CLICKED:{
//          //As we are messing with opengl here, we make sure it happens in the rendering thread
          pa.invokeLater(new Runnable() {
            public void run() {
              sceneTexture.getFbo().clear(true, 255, 255, 255, 0, true);           
            }
          });
        }break;
        default:
          break;
        }
      }
        });
        frame.addChild(b);
       
        //Pen brush selector button
        PImage penIcon = pa.loadImage(imagesPath + "pen.png");
        final MTImageButton penButton = new MTImageButton(penIcon, pa);
        frame.addChild(penButton);
        penButton.translate(new Vector3D(-50f, 65,0));
        penButton.setNoStroke(true);
        penButton.setStrokeColor(new MTColor(0,0,0));
       
        //Texture brush selector button
        PImage brushIcon = pa.loadImage(imagesPath + "paintbrush.png");
        final MTImageButton brushButton = new MTImageButton(brushIcon, pa);
        frame.addChild(brushButton);
        brushButton.translate(new Vector3D(-50f, 130,0));
        brushButton.setStrokeColor(new MTColor(0,0,0));
        brushButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent ae) {
        switch (ae.getID()) {
        case TapEvent.BUTTON_CLICKED:{
          drawingScene.setBrush(textureBrush);
          brushButton.setNoStroke(false);
          penButton.setNoStroke(true);
        }break;
        default:
          break;
        }
      }
        });
       
        penButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent ae) {
        switch (ae.getID()) {
        case TapEvent.BUTTON_CLICKED:{
          drawingScene.setBrush(pencilBrush);
          penButton.setNoStroke(false);
          brushButton.setNoStroke(true);
        }break;
        default:
          break;
        }
      }
        });
       
        //Save to file button
        PImage floppyIcon = pa.loadImage(imagesPath + "floppy.png");
        final MTImageButton floppyButton = new MTImageButton(floppyIcon, pa);
        frame.addChild(floppyButton);
        floppyButton.translate(new Vector3D(-50f, 260,0));
        floppyButton.setNoStroke(true);
        floppyButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent ae) {
        switch (ae.getID()) {
        case TapEvent.BUTTON_CLICKED:{
//          pa.invokeLater(new Runnable() {
//            public void run() {
//              drawingScene.getCanvas().drawAndUpdateCanvas(pa.g, 0);
//              pa.saveFrame();
//              clear(pa.g);
//            }
//          });
          drawingScene.registerPreDrawAction(new IPreDrawAction() {
            public void processAction() {
              //drawingScene.getCanvas().drawAndUpdateCanvas(pa.g, 0);
              pa.saveFrame();
            }
            public boolean isLoop() {
              return false;
            }
          });
        }break;
        default:
          break;
        }
      }
        });
       
        /////////////////////////
        //ColorPicker and colorpicker button
        PImage colPick = pa.loadImage(imagesPath + "colorcircle.png");
//        final MTColorPicker colorWidget = new MTColorPicker(0, pa.height-colPick.height, colPick, pa);
        final MTColorPicker colorWidget = new MTColorPicker(0, 0, colPick, pa);
        colorWidget.translate(new Vector3D(0f, 135,0));
        colorWidget.setStrokeColor(new MTColor(0,0,0));
        colorWidget.addGestureListener(DragProcessor.class, new IGestureEventListener() {
      public boolean processGestureEvent(MTGestureEvent ge) {
        if (ge.getId()== MTGestureEvent.GESTURE_ENDED){
          if (colorWidget.isVisible()){
            colorWidget.setVisible(false);
          }
        }else{
          drawingScene.setBrushColor(colorWidget.getSelectedColor());
        }
        return false;
      }
    });
        frame.addChild(colorWidget);
        colorWidget.setVisible(false);
       
        PImage colPickIcon = pa.loadImage(imagesPath + "ColorPickerIcon.png");
        MTImageButton colPickButton = new MTImageButton(colPickIcon, pa);
        frame.addChild(colPickButton);
        colPickButton.translate(new Vector3D(-50f, 195,0));
        colPickButton.setNoStroke(true);
        colPickButton.addActionListener(new ActionListener(){
View Full Code Here


    centerCircleInner.setStrokeColor(new MTColor(150,150,150));
    centerCircleInner.setStrokeWeight(0.5f);
    physicsContainer.addChild(centerCircleInner);
   
    //Create the paddles
    PImage paddleTex = mtApplication.loadImage(imagesPath + "paddle.png");
    redCircle = new Paddle(app, new Vector3D(mtApplication.width - 60, mtApplication.height/2f), 50, world, 1.0f, 0.3f, 0.4f, scale);
    redCircle.setTexture(paddleTex);
    redCircle.setFillColor(new MTColor(255,50,50));
    redCircle.setNoStroke(true);
    redCircle.setName("red");
    redCircle.setPickable(false);
    physicsContainer.addChild(redCircle);
   
    blueCircle = new Paddle(app, new Vector3D(80, mtApplication.height/2f), 50, world, 1.0f, 0.3f, 0.4f, scale);
    blueCircle.setTexture(paddleTex);
    blueCircle.setFillColor(new MTColor(50,50,255));
    blueCircle.setNoStroke(true);
    blueCircle.setName("blue");
    blueCircle.setPickable(false);
    physicsContainer.addChild(blueCircle);
   
    //Create the ball
    ball = new HockeyBall(app, new Vector3D(mtApplication.width/2f, mtApplication.height/2f), 38, world, 0.5f, 0.005f, 0.70f, scale);
//    MTColor ballCol = new MTColor(0,255,0);
//    ball.setFillColor(ballCol);
    PImage ballTex = mtApplication.loadImage(imagesPath + "puk.png");
    ball.setTexture(ballTex);
//    ball.setFillColor(new MTColor(160,160,160,255));
    ball.setFillColor(new MTColor(255,255,255,255));
    ball.setNoStroke(true);
    ball.setName("ball");
View Full Code Here

      this.y = y;
      this.w = width;
      this.h = height;
//      this.c = c;
     
      this.cpImage = new PImage( w, h );
      this.calcColors();
     
      this.setTexture(cpImage);
     
      this.init();
View Full Code Here

      }
    });
   
   
    //Close button
    PImage closeButtonImage = app.loadImage(MT4jSettings.getInstance().getDefaultImagesPath() +
    "closeButton64.png");
    closeButton = new MTImageButton(closeButtonImage, app);
    closeButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent r) {
        switch (r.getID()) {
View Full Code Here

TOP

Related Classes of processing.core.PImage

Copyright © 2018 www.massapicom. 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.