text.space code.

edited March 2017 in Questions about Code

Hi d like to have text.space code for processing. It was developped in java (action script 1) by Levitated (Jared Tarbell), but it haven been code in processing. Does someone have a similar sketch ? I m new to processing and i can't manage in coding time.space.

here s the link : http://levitated.net/daily/levTextSpaceFS.html

Thanks

regis

Tagged:

Answers

  • It was developped in java (action script 1)

    it's flash, by the look of things.

    start just by putting one bit of text in 3d space. use P3D in size. use a class with a String for the text and a PVector for the position.

  • hihi koogs, im n too newer in processing to do that.

  • void setup() {
      size(900, 800, P3D);
      textMode(SHAPE);
    }
    
    void draw() {
      background(0); 
      fill(255, 2, 0); 
      text("smooth", 444, 333, 133);
      fill(2, 255, 0); 
      text("nice", 144, 233, -5);
      fill(2, 255, 0); 
      text("nice", 450, 233, 315);
    }
    
  • Which is a start (thanks Chrisir) but really you need a class because hard coding those values like that will limit you.

  • edited March 2017
    import peasy.*;
    PeasyCam camera;
    
    
    ArrayList<TextIn3D> list = new ArrayList(); 
    
    void setup() {
      size(900, 800, P3D);
      textMode(SHAPE);
    
      // focus the cam on the center of the box
      camera = new PeasyCam(this, 425, 325, 411, 400);
    
      list.add( new TextIn3D("smooth", 444, 333, 133));
      list.add( new TextIn3D("nice", 144, 233, -5));
      list.add( new TextIn3D("wow", 480, 360, 633));
    }
    
    void draw() {
      background(0);
      avoidClipping();
    
      for (TextIn3D currentText : list) {
        currentText.display();
      }
    
      statusBar();
    }
    
    void mousePressed() {
      for (TextIn3D currentText : list) {
        if ( currentText.close() ) {
          currentText.textCol=color(2, 2, random(100, 255));
          return;
        }//if
      }//for
    }//func 
    
    // --------------------------------------------------------
    // Minor Functions 
    
    void statusBar() {
    
      // display a text in the corner
      camera.beginHUD();
      hint(DISABLE_DEPTH_TEST);
      noLights();
      textMode(MODEL);
    
      // the rect of the staus bar
      fill(111); // gray 
      noStroke(); 
      rect(0, height-19, width, 30);
    
      // the text 
      fill(0);
      textSize(12);
      textAlign(LEFT); 
      text("Click a word to make it random blue, "
        +"Mouse to rotate and pan camera (peasycam), "
        +"Mouse wheel to zoom+-, double click to reset camera, Esc to quit.  ", 
        3, height-4);
    
      // end HUD 
      hint(ENABLE_DEPTH_TEST);
      camera.endHUD();
    }
    
    void avoidClipping() {
      // avoid clipping : 
      // https : //
      // forum.processing.org/two/discussion/4128/quick-q-how-close-is-too-close-why-when-do-3d-objects-disappear
      perspective(PI/3.0, (float) width/height, 1, 1000000);
    }
    
    // ==================================================
    
    class TextIn3D {
    
      float x, y, z; 
      String text3D="";
      color textCol=color(random(100, 255), 2, 2); 
    
      float scrX, scrY; 
    
      //constr
      TextIn3D( String textTemp, 
        float xTemp, float yTemp, float zTemp) {
    
        x=xTemp; 
        y=yTemp;
        z=zTemp;
    
        text3D=textTemp;
      }//constr
    
      void display() {
        textAlign(CENTER);
        fill(textCol); 
        textMode(SHAPE);
        text(text3D, x, y, z);
    
        scrX=screenX( x, y, z);
        scrY=screenY( x, y, z);
        textAlign(LEFT);
      }
    
      boolean close() {
        return dist(mouseX, mouseY, scrX, scrY) < 44;
      }
    }//class
    // =============================================
    
  • Thanks a lot Chrisir. I m going to try it now.

    regis

Sign In or Register to comment.