Loading...
Logo
Processing Forum

P3D text

in Programming Questions  •  2 months ago  

size(400, 400, P3D);//P3D
textSize(55);

fill(255,0,0);//the red one
text("word", 12, 75,10); //behind!!! // if i want to change that, i have to display
//this word AFTER the other, but changing the z value has no effect, except to change the size, as normal.
fill(0, 102, 153, 204);
text("word", 12, 45, -30);//blue : forwards
pushMatrix();
translate(width/2, height/2, 100);
fill(0,255,0);// the green sphere: forwards
sphere(40);
popMatrix();

pushMatrix();
translate(width/2, height/2, -100);
fill(0,0,255); //the blue one:: behind
sphere(100);
popMatrix();


//AND NOW with OPENGL, the same stupid code

import processing.opengl.*;


size(400, 400, OPENGL);//P3D
textSize(55);

fill(255,0,0);//the red one
text("word", 12, 75,10); //before!!!
fill(0, 102, 153, 204);
text("word", 12, 45, -30);//blue : behind
pushMatrix();
translate(width/2, height/2, 100);
fill(0,255,0);// the green sphere: forwards
sphere(40);
popMatrix();

pushMatrix();
translate(width/2, height/2, -100);
fill(0,0,255); //the blue one:: behind
sphere(100);
popMatrix();

//question:i dont understand ZAxis for text with P3D

Replies(1)

Re: P3D text

2 months ago
Try this:

Copy code
  1. void setup(){
  2. size(600, 600, P3D);//P3D
  3. lights();
  4. }

  5. void draw(){
  6.   background(128);
  7.   noStroke();
  8. textSize(55);

  9. if ( mousePressed ){
  10.     // behind
  11.     fill(255,0,0);//the red one
  12.     text("reddd-behind", 12, 75,10); //behind!!! // if i want to change that, i have to display
  13.     //this word AFTER the other, but changing the z value has no effect, except to change the size, as normal.
  14.     fill(0, 102, 153, 204);
  15.     text("blueeeeeee", 12, 65, 30);//blue : forwards
  16. }
  17. else{
  18.    
  19.     fill(255,0,0);//the red one
  20.     text("reddd-infront", 12, 75,40); // in front
  21.     
  22.     fill(0, 102, 153, 204);
  23.     text("blueeeeeee", 12, 65, 30);//blue : forwards
  24.   
  25. }
  26. stroke(1);
  27. pushMatrix();
  28. translate(width/2, height/2, 100);
  29. fill(0,255,0);// the green sphere: forwards
  30. sphere(40);
  31. popMatrix();

  32. pushMatrix();
  33. translate(width/2, height/2, -100);
  34. fill(0,0,255); //the blue one:: behind
  35. sphere(100);
  36. popMatrix();

  37. }




Also in Processing 2, "OPENGL" and "P3D" are synonyms and refer to same implementation. They were different in Processing 1.5.1