Thursday, June 27, 2013

Image commands and concepts

Image commands


Pimage img = loadImage("file.png")
image(img, pos-x, pos-y, size-x, size-y)imageMode(CORNER);
    // CORNER -- Top left of image at pos-x, pos-y
    // CENTER -- Center of image at pos-x, pos-y



Layout Concepts

  • margin
  • layout in columns or rows
// Assuming imageMode(CENTER)
image(img, width/2, margin)
posX = width/2 - margin - img.width/2;   posY = height/2 + margin + img.height/2;
image(img, posX, posY)

Animation Concepts

  • pausing -- use a boolean flag "playing"
boolean playing = false
playing = !playing;  // toggles playing state

Program Template

// Declarations
Pimage [] images; 
int currentPosition = 0;

// void setup()
images = loadImages("Animation_data/movie", ".jpg", 134);
size(images[0].width, images[0].height);

// void draw()
image(images[currentPosition], 0, 0);  // draw the current image

currentPosition += 1;                  // move to the next image
if(currentPosition >= images.length) 
   currentPosition = 0;                // when you get to the end, loop


No comments:

Post a Comment