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

imageWidth()

Description Returns the currently set width of the image drawn by an Animation. (Not the same as the BImage's original width; retrieve that using image().width .) To set this parameter, use setImageWidth().
Prototype

float imageWidth();

Parameters   (none)
Return float Currently set width of an Animation's image, in pixels.
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);
  else
     test.setImageWidth(10);

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