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, image, startXPos, startYPos);
RiText(pApplet, image);
RiText(pApplet, text);
RiText(pApplet, character);
RiText(pApplet, startXPos, startYPos);
RiText(pApplet, character, startXPos, startYPos);
RiText(pApplet, text, startXPos, startYPos);
RiText(pApplet, text, xPos, yPos, alignment);
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 the RiText's run queue

addFeature()   Adds a feature (a key-value pair) to the RiText.

align()   Sets text mode for this RiText object.

appendFeature()   See rita.support.feature.Featured#appendFeature(java.lang.String, java.lang.String)

boundingBoxFill()   Set the bounding-box (or background) color for this object

boundingBoxPadding()   Sets min padding (in pixels) around all sides of text in bounding box (default=1)

boundingBoxSelectedFill()   Set the current boundingBoxFill color for this object, applicable only when showBoundingBox(true) has been called.

boundingBoxSelectedStroke()   Set the selected boundingBoxStroke color for this object, applicable only when showBoundingBox(true) has been called.

boundingBoxStroke()   Set the stroke color for the bounding-box of this object, assuming is has been set to visible.

boundingBoxStrokeWeight()   Set the current bgstroke weight for this object

characterPosition()   Returns the x-position (in pixels) for the character at 'charIdx' in the current object.

charAt()   Returns the character at the specified index

clearFeatures()   Clears all the features (key-value pairs) for the RiText

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

contains3D()   Checks if the input point is inside the object's bounding box after converting its x,y,z coordinates to screen x & y.

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 objects.

fadeColor()  

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 immediately

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

fillHex()   Takes a String

getAlpha()   Returns the fill alpha value (transparency)

getAvailableFeatures()   Returns a Set of all the available feature keys for the RiText

getBoundingBox()   Returns a new bounding box object (Rectangle2D.Float) representing the current screen position

getBoundingBoxFill()   Returns the current bounding box fill color for this object

getBoundingBoxStroke()   Returns the current bounding box stroke color for this object

getColor()   Returns the current text color for this object

getFeature()   Returns the String value for the given feature

getFeatures()   Returns a Map of all the features (key-value pairs) exists for this RiText

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

getLiveBehaviorCount()   Returns the # of running (non-completed) Behaviors in the RiText's run queue

getMotionType()   Returns the motionType for this object,

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

getPosArr()   See rita.RiString#getPos()

getPosAt()   See rita.RiString#getPosAt(int)

getPosition()   returns a 3-dimensional array with the objects x,y,z position

getSample()   Returns the RiSample object associated with this RiText

getSelectedColor()   Returns the fill color for this object when it is selected

getText()   Returns the current text

getTextAlignment()   Returns the current alignment (default=LEFT)

getWordAt()   See rita.RiString#getWordAt(int)

getWordCount()   See rita.RiString#getWordCount()

getWordOffset()   Returns the pixel x-position for the word at the given index.



getWords()   See rita.RiString#getWords()

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

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

hasFeature()   Checks whether the named feature (key-value pair) exists for this RiText

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

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

insertAt()   Inserts the 'toInsert' String at 'idx'. If the specified 'idx' is less than zero, or beyond the length of the current text, there will be no effect. Returns true if the insertion was made

insertCharAt()   Inserts the character at 'idx'. If the specified 'idx' is less than zero, or beyond the length of the current text, there will be no effect. Returns true if the insertion was made

insertWordAt()   See rita.RiString#insertWordAt(java.lang.String, int)

isBoundingBoxVisible()   Returns the visibility of the objects bounding box (default=false)

isMouseDraggable()   Returns true if the object has been set to be draggable by the mouse

isOffscreen()   Returns true if the object is offscreen

isSelected()   Returns whether the object is currently selected.

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()  

moveBy3D()   Move to new position by x,y,z offset over the duration specified by 'seconds'.

Note: uses the current motionType for this object.

moveTo()  

moveTo3D()  

pauseBehaviors()   Pauses (or unpauses) all Behaviors in the RiText's run queue

removeBehavior()   Remove a Behavior from the RiText's run queue

removeBehaviors()   Remove all Behaviors from the RiText's run queue

removeCharAt()   Deletes the character at 'idx'. If the specified 'idx' is less than xero, or beyond the length of the current text, there will be no effect. Returns true if the deletion was successful, else false

removeFeature()   Clears the entry for the named feature (a key-value pair)

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

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

replaceCharAt()   Replaces the character at 'idx' with 'replaceWith'. If the specified 'idx' is less than xero, or beyond the length of the current text, there will be no effect. Returns true if the replacement was made.

replaceWordAt()   See rita.RiString#replaceWordAt(java.lang.String, int)

rotate()   this is same as rotateZ, but for 2D

rotateX()  

rotateY()  

rotateZ()  

scale()  

scaleImage()   Scales the bg image by scalePercent

scaleX()  

scaleY()  

scaleZ()  

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

setColor()   Set the text color for this object

setFeatures()   Replaces all the features (key-value pairs) for the RiText with those in features

setImage()   Sets the bg image for the object

setImageHeight()   Sets height for the bg {@link #image}

setImageOffset()   Sets the relative position of the bgImage

setImageVisible()   Sets the relative position of the bgImage

setImageWidth()   Sets width for the bg {@link #image}

setLocation()   Sets the location of the current RiText

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)

setSelected()   Manually sets the objects 'selected' field

setSelectedColor()   Set the selected color for this object when selected

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)

split()   Splits this object into an array of RiTexts, one per word, with correct x-positions.

Note: uses String.split(String) to split on the regex.

splitLetters()   Splits the current object into an array of RiTexts, one per letter, maintaining the x and y position of each. Note: If desired, the original RiText should be deleted explicitly (via RiText.delete(originalRiText)).

splitWords()   Splits this object into an array of RiTexts, one per word, with correct x and y-positions.

Note: If desired, the original RiText should be deleted explicitly (via RiText.delete(originalRiText)).

subSequence()   Returns a new character sequence that is a subsequence of this sequence.

An invocation of this method of the form

 str.subSequence(begin, end)
behaves in exactly the same way as the invocation
 str.substring(begin, end)


textAlign()   Sets text mode for RiText object.

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

textHeight()   Returns the current text height in pixels

textMode()   Sets text mode for RiText object.

textSize()   Sets the object to this size

textWidth()   Returns the current text width in pixels

RiText.clearSelected()   Clears the selected flag for all RiTexts

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.

RiText.createLetters()  

RiText.createLines()   Creates an array of RiText, one per line of input text, constrained to the maxChars specified, starting with upper left corner at startX and startY

RiText.createLinesFromFile()  

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.disableBehaviorWarnings()  

RiText.drawAll()   Draws all (visible) RiText 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.getNumInstances()   Returns the number of existing RiTexts

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, in this case, you can use it as follows:
   RiText picked = null;
   RiText[] rts = RiText.getPicked(mx, my);
   if (rts != null) 
     picked = rts[0];


RiText.getSelected()   Returns all selected RiTexts or null if none are selected

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.pauseAllBehaviors()   Immediately pauses all Behaviors in the RiText's run queue

RiText.regexMatch()   Utility method to test whether a String partially matches a regex pattern.

RiText.regexReplace()   Utility method to do regex replacement on a String

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.setDefaultBBoxStrokeWeight()   Set the bounding box strokeweight for all existing RiTexts; set to 0 if you wish to assign a background color with no stroke.

RiText.setDefaultBBoxVisibility()   Sets the default behavior regarding whether newly created RiTexts are to display their bounding boxes
Note: this does not affect already created RiText objects

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))

RiText.setDefaultMotionType()   Sets the default motion type for all RiTexts to be created. This does not affect already created RiText objects - for this, use setMotionType().

RiText.setDefaultMouseDraggable()   Sets the default behavior regarding whether newly created RiTexts are to be mouse-draggable
Note: this does not affect already created RiText objects

Usage Web & Application