How to scale/translate a picture ?

Hi there ! Just new on Processing, i was wondering about how can i do to translate a picture, but on the Z-axis !! I can move it on X and Y, but it can't find out for the Z-axis :(

Here's my code :

PImage img3; float i = 1;

void setup(){

size(1000,1000,P3D); background(0,0,0); img3 = loadImage("logo.png");

} void draw(){

scale(1,1,i); imageMode(CENTER);
image(img3,width/2,height/2); i = i/2;

}

I'm sorry if it's an easy question, but i've tried a lot of things, like scale and translate : i just succeeded with some text, but i can't find out for a picture !

Thanks for your replies !!

Tagged:

Answers

  • _vk_vk
    Answer ✓

    Perhaps you want translate?

    PImage img3; 
    
    void setup() {
      size(1000, 1000, P3D); 
      background(0); 
      img3 = loadImage("http:"+"//propmark.com.br/static/upload/2015/12/5671e416a970a-5671e42366126-980x480.jpg");
    } 
    void draw() {
      background(0);
      pushMatrix();
      translate(width/2, height/2, -600);
      rotateY(radians(35));
      box(500);
      popMatrix();
    
      if (img3 != null) {
        imageMode(CENTER);
        translate(0, 0, frameCount*-1);
        image(img3, width/2, height/2);
      }
    }
    
  • Hi man, thanks so much for quickly replying ! And it actually works : my bad was to not really study the pushMatrix and popMatrix functions ! I'll study your code, but i'm pretty sure you found my solution :) Thx !

  • _vk_vk
    Answer ✓

    Push/popMatrix are used here to "isolate" the transformations meant to the cube. Try removing them and you will see. :)

  • oh ok you mean, what's inside the ***Matrix() functions is isolated from the rest of the code ? If i remove them, the rotation on Y-axis are applied to the whole code :D Thanks man you're awesome :)

  • translate works with x,y,z

    so use 0,0,z

    0,0,333

    but -333 is away from you into the screen

Sign In or Register to comment.