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

setRegistrationPoint()

Description

Sets a registration point for an Animation's BImage or nested Animation. A reg point is the point from which a graphic is drawn; the default reg point is at the top-left corner of the animation-rectangle. (defined as (0,0).) Setting the registration point to a different point will draw the image in a different location.

This parameter's current value can be retrieved using currentRegistrationPointX() and currentRegistrationPointY().

Prototype

setRegistrationPoint(x, y);

Parameters x x-component of desired reg point.
y y-component of desired reg point.
Return   (none)
Example

 

 

Animation a_normal;
Animation a_regpointed;
BImage img;
BFont font;

void setup()
{
  size(450,250);
  font = loadFont("RotisSanSer.vlw.gz");
  textFont(font, 20);
  img = loadImage("image.gif");
  
  // setup a_normal
  a_normal = new Animation(this, img, 50,50, 100, 50);
  a_normal.setStep("BOX");
  a_normal.setDuration(5000);
  a_normal.showRectangle();
  
  // setup a_regpointed
  a_regpointed = new Animation(this, img, 50,150, 100,50);
  a_regpointed.setStep("BOX");
  a_regpointed.setDuration(5000);
  a_regpointed.showRectangle();
  
  // set registration point to the middle of the image.
  a_regpointed.setRegistrationPoint(img.width/2, img.height/2);
}

void loop()
{
  background(127);
  fill(255);
  text("Normal animation (registration point at image's top-left corner).", 25, 40);
  text("Animation with registration point at image's center.", 25, 140);
  noFill();
  a_normal.draw();
  a_regpointed.draw();
}