Package org.mt4j.util

Examples of org.mt4j.util.MTColor


  /**
   * Instantiates a new style info.
   */
  public StyleInfo(){
    this(
        new MTColor(255,255,255,255),
        new MTColor(255,255,255,255),
        true,
        false,
        false,
        1.0f,
        GL.GL_TRIANGLE_FAN,
View Full Code Here


        nextSceneWindow = new MTSceneTexture(app,0, 0, nextScene);

        lastSceneRectangle = new MTRectangle(0,0, app.width, app.height, app);
        lastSceneRectangle.setGeometryInfo(lastSceneWindow.getGeometryInfo());
        lastSceneRectangle.setTexture(lastSceneWindow.getTexture());
        lastSceneRectangle.setStrokeColor(new MTColor(0,0,0,255));

        nextSceneRectangle = new MTRectangle(0,0, app.width, app.height, app);
        nextSceneRectangle.setGeometryInfo(nextSceneWindow.getGeometryInfo());
        nextSceneRectangle.setTexture(nextSceneWindow.getTexture());
        nextSceneRectangle.setStrokeColor(new MTColor(0,0,0,255));

        getCanvas().addChild(lastSceneRectangle);
        getCanvas().addChild(nextSceneRectangle);

        nextSceneRectangle.translateGlobal(new Vector3D(app.width,0,0));
View Full Code Here

        nextSceneWindow = new MTSceneTexture(app,0, 0, nextScene);

        lastSceneRectangle = new MTRectangle(0,0, app.width, app.height, app);
        lastSceneRectangle.setGeometryInfo(lastSceneWindow.getGeometryInfo());
        lastSceneRectangle.setTexture(lastSceneWindow.getTexture());
        lastSceneRectangle.setStrokeColor(new MTColor(0,0,0,255));

        nextSceneRectangle = new MTRectangle(0,0, app.width, app.height, app);
        nextSceneRectangle.setGeometryInfo(nextSceneWindow.getGeometryInfo());
        nextSceneRectangle.setTexture(nextSceneWindow.getTexture());
        nextSceneRectangle.setStrokeColor(new MTColor(0,0,0,255));

        getCanvas().addChild(lastSceneRectangle);
        getCanvas().addChild(nextSceneRectangle);

        nextSceneRectangle.rotateY(nextSceneRectangle.getCenterPointGlobal(), 270, TransformSpace.GLOBAL);
View Full Code Here

     
      //NOTE: if noFill() and noStroke()->absolutely nothing will be drawn-even when texture is set
      if (this.isNoFill()) 
        pa.noFill();
      else{
        MTColor fillColor = this.getFillColor();
        pa.fill(fillColor.getR(), fillColor.getG(), fillColor.getB(), fillColor.getAlpha());
      }
     
      if (this.isNoStroke())  
        pa.noStroke();
      else{
        MTColor strokeColor = this.getStrokeColor();
        pa.stroke(strokeColor.getR(), strokeColor.getG(), strokeColor.getB(), strokeColor.getAlpha());
      }
     
      //Set the tint values
      MTColor fillColor = this.getFillColor();
      pa.tint(fillColor.getR(), fillColor.getG(), fillColor.getB(), fillColor.getAlpha())

      //handles the drawing of the vertices with the texture coordinates
      //try doing a smoothed poly outline with opengl
//      if (
////          ConstantsAndSettings.getInstance().isOpenGlMode()  &&
//        this.isDrawSmooth() &&
//        !this.isNoStroke()
//      ){
//        pa.noStroke();
//        pa.noSmooth();
//       
//        //draw insided of polygon, without smooth or stroke
//        this.drawWithProcessing(pa, this.getVerticesObjSpace(), PApplet.TRIANGLES, true);
//
//        pa.smooth();
//        pa.noFill();
//        pa.stroke(this.getStrokeRed(), this.getStrokeGreen(), this.getStrokeBlue(), this.getStrokeAlpha());
//
//        // DRAW SMOOTHED THE OUTLINE SHAPE OF THE POLYGON WIHTOUT FILL OR TEXTURE
////        drawWithProcessing(pa);
//       
//        for (Vertex[] outline : this.outlineContours){
//          this.drawWithProcessing(pa, outline, PApplet.LINE, false);
//        }
//      }else{
      if (!this.isNoStroke()){
        pa.noFill();
        MTColor strokeColor = this.getStrokeColor();
        pa.stroke(strokeColor.getR(), strokeColor.getG(), strokeColor.getB(), strokeColor.getAlpha());
        pa.strokeWeight(2);
       
        if (this.isDrawSmooth())
          pa.smooth();
       
View Full Code Here

   */
  public MTSceneWindow(final Iscene scene, float borderWidth, float borderHeight, final MTApplication applet, int fboWidth, int fboHeight) {
//    super(0-borderWidth, 0-borderHeight, applet.width+2*borderWidth, applet.height+2*borderHeight, applet);
    super(0-borderWidth, 0-borderHeight, 0, MT4jSettings.getInstance().getWindowWidth()+2*borderWidth, MT4jSettings.getInstance().getWindowHeight()+2*borderHeight, 30, 30, applet);
   
    this.setStrokeColor(new MTColor(0,0,0));
   
    sceneTexture = new MTSceneTexture(applet,0, 0, fboWidth, fboHeight, scene);
    sceneTexture.setStrokeColor(new MTColor(0,0,0));
    this.addChild(sceneTexture);
   
    //Add the scene to the scene list in the Application
    //FIXME add the scene later to the MTApplication because if we add the scene
    //before any other scene is added it becomes the active scene which we dont want
View Full Code Here

    cam = new MTCamera(app);
   
    e = new HoldEllipse(app, new Vector3D(0, 0), 35, 35, 50);
    e.setPickable(false);
    e.unregisterAllInputProcessors();
    e.setStrokeColor(new MTColor(240,50,50,200));
    e.setStrokeWeight(4);
    e.setNoFill(true);
    e.setDepthBufferDisabled(true);
    e.attachCamera(cam);
    e.setVisible(false);
View Full Code Here

      if (d >= 350){ //FIXME HACK to display the circle really closed before the end
        d = 360;
        e.setDegrees(d);
        e.recreate(true);
       
        MTColor stroke = e.getStrokeColor();
        e.setStrokeColor(new MTColor(stroke.getR(), stroke.getG(), stroke.getB(), 255));
      }else{
      e.setDegrees(d);
      e.recreate(false);
     
      MTColor stroke = e.getStrokeColor();
      e.setStrokeColor(new MTColor(stroke.getR(), stroke.getG(), stroke.getB(), a));
      }
      break;
    case TapAndHoldEvent.GESTURE_ENDED:
      e.setVisible(false);
      parent.removeChild(e);
View Full Code Here

    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(){
      public void actionPerformed(ActionEvent ae) {
        switch (ae.getID()) {
        case TapEvent.BUTTON_CLICKED:{
          if (colorWidget.isVisible()){
            colorWidget.setVisible(false);
          }else{
            colorWidget.setVisible(true);
            colorWidget.sendToFront();
          }       
        }break;
        default:
          break;
        }
      }
        });
       
        //Add a slider to set the brush width
        MTSlider slider = new MTSlider(0, 0, 200, 38, 0.05f, 2.0f, pa);
        slider.setValue(1.0f);
        frame.addChild(slider);
        slider.rotateZ(new Vector3D(), 90, TransformSpace.LOCAL);
        slider.translate(new Vector3D(-7, 325));
        slider.setStrokeColor(new MTColor(0,0,0));
        slider.setFillColor(new MTColor(220,220,220));
        slider.getKnob().setFillColor(new MTColor(70,70,70));
        slider.getKnob().setStrokeColor(new MTColor(70,70,70));
        slider.addPropertyChangeListener("value", new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent p) {
        drawingScene.setBrushScale((Float)p.getNewValue());
      }
    });
        //Add triangle in slider to indicate brush width
        MTPolygon p = new MTPolygon(new Vertex[]{
            new Vertex(2 + slider.getKnob().getWidthXY(TransformSpace.LOCAL), slider.getHeightXY(TransformSpace.LOCAL)/2f, 0),
            new Vertex(slider.getWidthXY(TransformSpace.LOCAL)-3, slider.getHeightXY(TransformSpace.LOCAL)/4f +2, 0),
            new Vertex(slider.getWidthXY(TransformSpace.LOCAL)-1, slider.getHeightXY(TransformSpace.LOCAL)/2f, 0),
            new Vertex(slider.getWidthXY(TransformSpace.LOCAL)-3, -slider.getHeightXY(TransformSpace.LOCAL)/4f -2 + slider.getHeightXY(TransformSpace.LOCAL), 0),
            new Vertex(2, slider.getHeightXY(TransformSpace.LOCAL)/2f, 0),
        }, pa);
        p.setFillColor(new MTColor(150,150,150, 150));
        p.setStrokeColor(new MTColor(160,160,160, 190));
        p.unregisterAllInputProcessors();
        p.setPickable(false);
        slider.getOuterShape().addChild(p);
        slider.getKnob().sendToFront();
       
View Full Code Here

    this.brushWidthHalf = drawShape.getWidthXY(TransformSpace.LOCAL)/2f;
    this.brushHeightHalf = drawShape.getHeightXY(TransformSpace.LOCAL)/2f;
    this.stepDistance = brushWidthHalf/2.5f;
    */
   
    this.brushColor = new MTColor(0,0,0);
    this.brushScale = 1.0f;
    this.dynamicBrush = true;
//    this.stepDistance = 5.5f;
   
    this.cursorToLastDrawnPoint = new HashMap<InputCursor, Vector3D>();
View Full Code Here

              new Vertex(newPos.getX(), newPos.getY(), newPos.getZ())},
          pa);
      polygon.setPickable(true);
      polygon.setNoStroke(false);
      polygon.setNoFill(false);
      polygon.setFillColor(new MTColor(100, 150, 250, 55));
//      polygon.setStrokeColor(150,150,250,255);
      polygon.setStrokeColor(new MTColor(0,0,0,255));
      polygon.setStrokeWeight(1.5f);
      polygon.setDrawSmooth(true);
      polygon.setUseDirectGL(true);
      polygon.setLineStipple((short)0xBBBB);
      polygon.setName("SelectPoly");
View Full Code Here

TOP

Related Classes of org.mt4j.util.MTColor

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.