RiTa
index
Name RiText
Description RiTa's text display object. Wraps an instance of RiString to provide utility methods for typography, display, animation, text-to-speech, and audio playback.

Note: by default, RiText objects, once created, will draw themselves to the screen at each frame until they are either a) deleted (via RiText.delete(myRiText);) or b) hidden (via myRiText.setVisible(false);). To disable this behavior (and draw the objects manually), one can call disableAutoDraw().

An example usage:

     import rita.*;
     
     void setup() {
       // start in the upper left corner
       RiText rt = new RiText(this, "hello", 0, 10);
       
       // measure the width of the text
       float tw = rt.textWidth();
 
       // move to the lower right over 2 sec
       rt.moveTo(width-tw, height, 2);    
     }
     
     void draw() {
       // draw the bg every frame
       background(255);
     }
 
Constructors
RiText(pApplet);
RiText(pApplet, text);
RiText(pApplet, character);
RiText(pApplet, startXPos, startYPos);
RiText(pApplet, character, startXPos, startYPos);
RiText(pApplet, text, startXPos, startYPos);
RiText(pApplet, text, startXPos, startYPos, font);
RiText(pApplet, text, xPos, yPos, alignment);
RiText(pApplet, text, xPos, yPos, alignment, theFont);
Fields
sample   Current Sample object for this text

x   Current x-position of this text

y   Current y-position of this text

Methods
addBehavior()   Add a new behavior to this RiText's run queue

boundingBoxFill()  

boundingBoxStroke()  

boundingBoxStrokeWeight()   Set the current bgstroke weight for this object

contains()   Checks if the input point is inside the bounding box

copy()   Returns a field for field copy of this object

createFont()   Creates (and caches) the font for this object from a System font (via PApplet.createFont()). Note: this is not a good idea for web-applets as the user's machine must have the specified font.

distanceTo()   Returns the distance between the center points of the two RiTexts.

fadeColor()   Transitions to 'color' (rgba) over 'seconds' starting at 'startTime' seconds in the future

fadeIn()   Fades in current text over seconds starting at startTime. Interpolates from the current color {r,g,b,a} to {r,g,b,255}.

fadeOut()   Fades out current text over seconds starting at startTime. Interpolates from the current color {r,g,b,a} to {r,g,b,0}.

fadeToText()   Fades out the current text and fades in the newText over seconds starting at 'startTime' seconds in the future

fill()   Set the text fill for this object (same as setColor())

getBoundingBox()   Returns a rectangle representing the current screen position of the bounding box

getFont()   Return the current font for this object

getImageHeight()   Returns the height of the image associated with this RiText

getImageWidth()   Returns the width of the image associated with this RiText

getMotionType()   Returns the motionType for this object,

getPos()   Returns the part-of-speech tags, one per word, separated by WORD_BOUNDARY, using the default Tokenizer & Poart-of-speech tagger. See rita.RiString#getPos(java.lang.String)

getSample()   Returns the RiSample object associated with this RiText

getText()   Returns the current text

getX()   Gets the current x-position of the RiText

getY()   Gets the current y-position of the RiText

isOffscreen()   Returns true if the object is offscreen

isVisible()   Returns true if the objects is not hidden

length()   Returns number of characters in the contained String

loadFont()   Returns the font specified after loading it and setting the current font size.

loadSample()   Loads a sample file and returns the appropriate type of RiSample object according to the library specified in playerType (defaults to Minim). Starts the sample looping if setLooping is true

matches()   See rita.RiString#matches(java.lang.String)

moveBy()   Move to new position by x,y offset over the duration specified by 'seconds', starting at 'startTime' seconds in the future



moveTo()   Move to new absolute x,y (or x,y,z) position over 'time' seconds

Note: uses the current motionType for this object, starting at 'startTime' seconds in the future

replace()   See rita.RiString#replace(java.lang.String, java.lang.String)

rotate()   Rotate the object via affine transform. This is same as rotateZ, but for 2D

scale()   Uniformly scales the object on all dimensions (x,y,z)

scaleTo()   Scales object to {scaleX, scaleY, scaleZ} over 'time' seconds, starting at 'startTime' seconds in the future.

Returns the Id of the RiTextBehavior object used for the scale. Note: uses linear interpolation unless otherwise specified.

setAlpha()   Set the current alpha trasnparency for this object (0-255))

setMotionType()   Sets the animation motionType for this for moveTo() or moveBy() methods on this object, set via one of the following constants:
  • RiText.LINEAR
  • RiText.EASE_IN
  • RiText.EASE_OUT
  • RiText.EASE_IN_OUT
  • RiText.EASE_IN_OUT_CUBIC
  • RiText.EASE_IN_CUBIC
  • RiText.EASE_OUT_CUBIC;
  • RiText.EASE_IN_OUT_QUARTIC
  • RiText.EASE_IN_QUARTIC
  • RiText.EASE_OUT_QUARTIC;
  • RiText.EASE_IN_OUT_SINE
  • RiText.EASE_IN_SINE
  • RiText.EASE_OUT_SINE


setMouseDraggable()   Sets the object's draggable state (default=false)

setPosition()   Sets the position for the current RiText

setText()   Sets the current text to this String

setVisible()   Sets boolean flag to show or hide the object

setX()   Sets the x-position of the current RiText

setY()   Sets the y-position of the current RiText

showBoundingBox()   Sets the visibility of the objects bounding box (default=false)

textAlign()   Sets text mode for RiText object.

textFont()   Sets the font and size for this object's text

textHeight()   Returns the height for the current font in pixels (including ascendors and descendors)

textMode()   Sets text mode for RiText object.

textSize()   Sets the object to this size

textWidth()   Returns the current text width in pixels

RiText.createDefaultFont()   Sets the default font for all RiTexts to be created (via PApplet.createFont(String)).

Note: this is not a good idea for web-applets as the user's machine must have the specified font.

Note: same PApplet#createDefaultFont(String, float) but also returns the created font.

RiText.createLetters()   Creates an array of RiTexts, one per letter, with appropriate x and y positions for each (using the default 'font'), starting at 'xStart' and 'yStart'.

RiText.createLines()   Creates an array of RiText, one per line from the input String, and lays it out according to the rectangle specified.



RiText.createLinesFromFile()   Creates an array of RiTexts, one per line from the input file, and lays it out according to the rectangle specified.



RiText.createWords()  

RiText.delete()   Deletes all objects in the array (and the array itself)

RiText.deleteAll()   Deletes all current instances.

RiText.disableAutoDraw()   Disables auto-drawing of subsequently created RiTexts.
Note: draw() must be explicitly called on these objects.

RiText.fadeAllIn()   Fades in all RiText objects over the specified duration

RiText.fadeAllOut()   Fades all visible RiText objects.

RiText.getInstances()   Returns all existing instances of RiText objects in an array

RiText.getPicked()   Returns all RiTexts that contain the point x,y or null if none do.

Note: this will return an array even if only one item is picked, therefore, you should generally use it as follows:

   RiText picked = null;
   RiText[] rts = RiText.getPicked(mx, my);
   if (rts != null)
 picked = rts[0];
 
 


RiText.loadStrings()   Creates an array of RiText from a file, by delegating to PApplet.loadStrings(), then creating one array element per line (including blanks).

RiText.setDefaultAlignment()   Sets the default alignment for all RiTexts to be created. This does not affect already created RiText objects - for this, use textMode().

RiText.setDefaultBBoxFill()   Set the bounding box fill color for all RiTexts to be created;

RiText.setDefaultBBoxStroke()   Set the bounding box fill color for all RiTexts to be created;

RiText.setDefaultBBoxStrokeWeight()   Set the default bounding box strokeweight for all RiTexts to be created. Set to 0 if you wish to assign a background color with no stroke.

RiText.setDefaultColor()   Sets the default color for all RiTexts to be created. This does not affect already created RiText objects.

RiText.setDefaultFont()   Sets the default font for all RiTexts to be created (via PApplet.loadFont(String)).

Returns the PFont in case it is needed.

Usage Web & Application