net.nexttext.behaviour.dform
Class Throb

java.lang.Object
  extended by net.nexttext.behaviour.AbstractAction
      extended by net.nexttext.behaviour.dform.DForm
          extended by net.nexttext.behaviour.dform.Throb
All Implemented Interfaces:
Action

public class Throb
extends DForm

A DForm which throbs the TextObject.

Think of throb as a multiplication of the size of the object, which changes over time.

In order to improve interoperability with other DForms, the period of the throb is tracked as a frame count specific to each TextObjectGlyph. This way, each time the behaviour is called it modifies the control points of the Glyph by multiplying them by the appropriate factor, thus preserving any other modifications.

The following calculation defines throb with a period p and scale of s. Given a vector c from the center of the glyph to one of its control points, it's throbbed value for frame f is

p * ( ( s - 1 ) * ( ( cos( f / p * 2PI - PI ) ) + 1 ) + 1 ) 

XXXBUG: If the period or scale is changed after the behaviour has been started, then it will mess up any objects that are already throbbing. The way to correct this problem is to cache the period and scale along with the frame count, and only update them when a throb is completed.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.nexttext.behaviour.Action
Action.ActionResult
 
Constructor Summary
Throb(float scale, int period)
           
 
Method Summary
 Action.ActionResult behave(TextObjectGlyph to)
          DForms generally just make sense on TextObjectGlyphs.
 
Methods inherited from class net.nexttext.behaviour.dform.DForm
behave, getControlPoints
 
Methods inherited from class net.nexttext.behaviour.AbstractAction
behave, behave, complete, getDisplayName, getRequiredProperties, makeBehaviour, properties, setDisplayName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Throb

public Throb(float scale,
             int period)
Parameters:
scale - is amount the object's size will increase, as a multiplier.
period - is the period of the throb, in frames.
Method Detail

behave

public Action.ActionResult behave(TextObjectGlyph to)
Description copied from class: DForm
DForms generally just make sense on TextObjectGlyphs.

Specified by:
behave in class DForm