Animation Overview - News - Installation - Reference - Examples - FAQ  
 

setImageWidth()

Description Sets the width, in pixels, of the BImage an Animation draws.
Prototype

setImageWidth(width);

Parameters width The width, in pixels, of the drawn BImage.
Return   (none)
Example

 

Animation test;
BFont font;

void setup()
{
  size(400,100);
  font = loadFont("RotisSanSer.vlw.gz");
  textFont(font, 20);
 
  test = new Animation(this, loadImage("image.gif"), 100,40, 200,40);
  test.showRectangle();
}

void loop()
{
  background(127);
  
  if (test.currentRepetition() % 2 == 1)
    test.setImageWidth(30); // make image 30px wide
  else
     test.setImageWidth(10); // make image 10px wide

  test.draw();
  float img_width = test.imageWidth();
  text("Image width is " + img_width + " pixels.", 25, 25);    
}