Class Definitions

The software entities defined by the FancyPants JavaScript API are categorized and presented in the following subsections.

Terminology used in document:

  1. Construction method, or constructor, refers to any method from the Fp class that returns an object of any type. For example, fp.animator(), fp.timer(), fp.image(), fp.text(). The Fp methods “animator”, “timer”, “image”, “text” are constructors of the corresponding type of objects.

  2. Object's construction parameter refers to the input parameter of a constructor that returns only the type of FpObject (or its subtype). For example, in the call to fp.image({size:{w:300}, file:”img.png”}), the {size:{w:300}, file:”img.png”} is the object's construction parameter.

  3. Field refers to a field within a JavaScript table, or structure. In the example from (2) above, “size” and “name” are fields in object's construction parameter, while “w” is a field within the “size” table.

  4. Property refers to the predefined property of an object, they are listed in each of the class definition subsections. Property can be retrieved via get() method, or by treating them as class variables and retrieve them as obj.xxx, they can only be modified via the set() method however, and updating a property through obj.xxx syntax is invalid. Not all properties are readable and writable, some are read-only, while some are write-only, please refer to the relevant section for detail.

Unless the document explicitly specifies:

Fp Class

Extends: none

An instance of this class must be obtained to perform any UI operations using the FancyPants library.

Constructor

The constructor of the Fp class takes no argument.

If running in the browser environment the use:

<object name="fancypants" type="application/fancypants-plugin" width="720" height="360">
</object>

<script>
fp = document.fancypants;
</script>

If running in the standalone environment use the global API fp_init() to acquire an instance of FancyPants class as follows:

fp = fp_init();

Class Variables

The following class variables are read-only and can be retrieved by fp.w or fp.h.

Variable Name Type Description
h integer Height of FancyPants canvas, this is determined by the FP_EMULATE environment variable
w integer Width of FancyPants canvas, this is determined by the FP_EMULATE environment variable

Properties

None

Events

None

General Methods


Method Name: begin
  1. Description: Begins the FancyPants main loop
  2. Environment: For the standalone envitronment only

Method Name: get
  1. Description: Gets the property value
  2. Return Type: Property specific type
  3. Input Parameters:
    propertyName: string
  4. Examples: Get the on-screen size of an object
    var size = obj.get("size");

Method Name: set
  1. Description: Sets the value of a property
  2. Input Parameters:
    propertyName: string, propertyValue: value
    The propertyValue is specific to the property.
  3. Examples:
    // Se the object size to be 100x200
    obj.set("size", { w: 100, h: 200 });
    // Get the x and y coordinates of an object and change them
    var coord = obj.get("coord");
    var x = coord.x;
    var y = coord.y;
    // Move the object 10% to the right
    x *= 1.1;
    obj.set( "coord", { x: x } });

Method Name: set
  1. Description: Sets multiple properties. “propertyName” is the name of the property listed in the Properties section, “propertyValue” is the value to be set. The type of the “propertyValue” is dependent on the associated properties, please refer to Properties section for details
  2. Input Parameters:
    {
     propertyName: string, propertyValue: value,
     propertyName: string, propertyValue: value,
     ...
    }
    The propertyValue is specific to the property.

Method Name: toString
  1. Description: Returns the string “Fp” indicating that the object is a type of Fp class
  2. Return Type: string

Method Name: quit
  1. Description: Exit the FancyPants main loop (returns from begin).
  2. Environment: This method is only available in the standalone environment.

Periodic events

Method Name Input Parameters Return Type Description
animator callback: function FpAnimator
idler callback: function FpIdler
job callback: function FpJob
timer interval: double,
callback : function
FpTimer

Object construction

The <object parameters> notation below represents a list of generic object parameters. These are the parameters that are passed into the object() method, and the very same parameters can be specified during the construction of almost all FancyPants objects as most objects inherit from FpObject.


Method Name: container
  1. Description: Creates a container object
  2. Return Type: FpContainer
  3. Input Parameters:
    {
     <object parameters>
    }

Method Name: image
  1. Description: Creates an image object
  2. Return Type: FpImage
  3. Input Parameters:
    {
     <object parameters>
     file: string,
     url: string,
     theme_image: string,
     border:
     {
         left: integer,
         top: integer,
         right: integer,
         bottom: integer
     },
     tile:
     {
         x: integer,
         y: integer,
         w: integer,
         h: integer
     },
    }

Method Name: layout
  1. Description: Creates a layout object. For a list of orientations please refer to the Constants section.
  2. Return Type: FpLayout
  3. Input Parameters:
    {
     <object parameters>
     orientation: string
    }

Method Name: media
  1. Description: Creates a media object. For a list of states please refer to the Constants section.
  2. Return Type: FpMedia
  3. Input Parameters:
    {
     <object parameters>
     demuxer: string
     decoder: string
     file: string
     url: string
     videoLayer: integer
     keepAspect: bool
     loop: bool
     mute: bool
     speed: double
     state: string
     volume: integer
     tile: 
     {
         x: integer
         y: integer
         w: integer
         h: integer
     }
    }

Method Name: object
  1. Description: Creates an object based on a list of properties.
    • For a list of object types please refer to the Constants section.
    • The type is only valid (and mandatory) when caller creates an object via fp.object() method call, the type will be ignored for all other calls such as fp.image(), fp.text().
    • The default visible is true.
    • As the default size is 0 for all objects, it is reminded to have the size specified either during object constrution or later through the set() method.
    • The default color of any object in FancyPants is white (ie. r=g=b=a=255), however the color can be changed using the color property.
    • When specifying the color property during constructor call, if not all of the r,g,b channels are specified, the missing channel will be set to 0, the alpha will default to 255 if not specified. This allows caller to pass in {r:255} for red, for example.
    • The “premul” boolean indicates whether if the r,g,b,a values have been premultiplied. When color values are premultipled, the values of r,g,b must be less than or equals to alpha. “premul” is false by default, allowing developer to pass r,g,b,a within the range of 0~255 without worry about premultiplication.
  2. Return Type: FpObject
  3. Input Parameters:
    {
    type: string
    layer: short
    coord:
     {
       x: integer
       y: integer
     }
    size:
     {
       w: integer
       h: integer
     }
    visible: bool
    color:
     {
       r: integer
       g: integer
       b: integer
       a: integer
       premul: bool
     }
    clip: FpRectangle
    name: string
    focus: bool
    skipEvent: bool
    repeatEvent: bool
    }

Method Name: rectangle
  1. Description: Creates a rectangle object
  2. Return Type: FpRectangle
  3. Input Parameters:
    {
     <object parameters>
    }

Method Name: text
  1. Description: Creates a text object. For a list of text styles and effects please refer to the Constants section.
  2. Return Type: FpText
  3. Input Parameters:
    {
    <object parameters>
    text: string
    style: string
    textEffect: string
    glowColor:
     {
       r: integer
       g: integer
       b: integer
       a: integer
       premul: bool
     }
    glow2Color:
     {
       r: integer
       g: integer
       b: integer
       a: integer
       premul: bool
     }
    shadowColor:
     {
       r: integer
       g: integer
       b: integer
       a: integer
       premul: bool
     }
    outlineColor:
     {
       r: integer
       g: integer
       b: integer
       a: integer
       premul: bool
     }
    }

Widget Construction


Method Name: button
  1. Description: Creates a button object
    • bgThemeImageKey is the theme key of the button background image (refer to image:imageThemeByKey)
    • For a list of text styles please refer to the Constants section.
    • Sensitive activates or deactivates the button
  2. Return Type: FpButton
  3. Input Parameters:
    {
     <object parameters>
     text: string
     bgThemeImageKey:string
     textStyle: string
     sensitive: bool
    }

Method Name: calendar
  1. Description: Creates a calendar object. The “timestamp” parameter is the standard UNIX timestamp and is optional. The year/month/day parameters supersede the seconds if present.
  2. Return Type: FpCalendar
  3. Input Parameters:
    {
    <object parameters>
    date: 
     { 
       year: integer
       month: integer
       day: integer
        timestamp: integer
     }
    }

Method Name: checkbox
  1. Description: Creates a checkbox. Please refer to the Constants section for a list of text styles.
  2. Return Type: FpCheckbox
  3. Input Parameters:
    {
    <object parameters>
    checked: bool
    style: string
    text: string
    }

Method Name: cube
  1. Description: Creates a cube object.
    • angle direction: “snap”, “left”, “right”
    • tilt direction (from positive x-axis): “snap”, “up”, “down”
    • Both “deg” and “direction” parameters are mandatory if the corresponding “angle” or “tilt” is present.
    • “rotationDuration” is the time (in seconds) the animation to the target rotation degree will take. Must be strictly positive.
    • Only the first 6 valid FpObject in “faces” parameter will be accepted, once all 6 faces are added, subsequent FpObject will be ignored.
    • The order to which face the object will be added to is as follows: Front, Right, Back, Left, Top, Bottom.
    • Please refer to the Constants section for a list of orientations.
  2. Return Type: FpCube
  3. Input Parameters:
    {
    <object parameters>
    angle:
     {
       deg: double
       direction: string
     }
    tilt:
     {
       deg: double
       direction: string
     }
    faces: FpObject[6]
    depth: integer
    rotationDuration: double
    orientation: string
    perspective: 
    {
     coord:
       {
         x: integer
         y: integer
         z: integer
       }
    }
    }

Method Name: filebrowser
  1. Description: Creates a file browser widget.
    • IMPORTANT: Function returns “null” if the path cannot be found.
    • “filter” is a comma separated string indicating the type(s) of files that can be displayed in file browser.
    • “traversal” indicates whether if user can traverse to different folders.
    • Please refer to Constants section for a list of filters and traversal modes.
  2. Return Type: FpFilebrowser
  3. Input Parameters:
    {
    <object parameters>
    filter: string
    path: string
    traversal: string
    }

Method Name: flip
  1. Description: Creates a flip widget.
    • Both “front” and “back” are mandatory parameters. In the case when application needs to flip a single object, one may pass in the same object for both “front” and “back”.
    • “showboth” is a parameter indicating whether if both objects should be rendered at the same time. This parameter is set to “false” by default, and setting it to “true” is useful in the case when one of the object is semi-transparent, allowing user to see through to the back object.
  2. Return Type: FpFlip
  3. Input Parameters:
    {
    <object parameters>
    front: FpObject
    back: FpObject
    angle:
     {
       deg: double
       direction: string
     }
    depth: integer
    showboth: bool
    }

Method Name: keyboard
  1. Description: Creates a keyboard widget. Please note that the keyboard widget requires a text entry to be focused in order to have effect.
  2. Return Type: FpKeyboard
  3. Input Parameters:
    {
    <object parameters>
    }

Method Name: multiselect
  1. Description: Create a multiselect widget
  2. Return Type: FpMultiselect
  3. Input Parameters:
    {
    <object parameters>
    opened: bool
    alignment: string
    items: string[]
    selItem: string
    maxHeight: integer
    }

Method Name: progressbar
  1. Description: Create a progressbar widget For a list of orientations please refer to the Constants section.
  2. Return Type: FpProgressbar
  3. Input Parameters:
    {
    <object parameters>
    orientation: string
    max: double
    value: double
    }

Method Name: scrollbar
  1. Description: Creates a scrollbar widget. Please refer to Constants section for a list of appear modes for horizontal and vertical scrollbars.
  2. Return Type: FpScrollbar
  3. Input Parameters:
    {
    <object parameters>
    target: FpObject
    hAppear: string
    vAppear: string
    scrollPos:
     {
       x: integer
       y: integer
     }
    kinetic: bool
    fading: bool
    }

Method Name: scrolllist
  1. Description: Creates a scroll list. Please refer to Constants section for a list of orientation, appear modes for horizontal and vertical scrollbars, and scroll modes.
  2. Return Type: FpScrolllist
  3. Input Parameters:
    {
    <object parameters>
    objs: FpObject[]
    hAppear: string
    vAppear: string
    kinetic: bool
    orientation: string
    offset: integer
    padding: integer
    scroll: string
    }

Method Name: slider
  1. Description: Creates a slider.
  2. Return Type: FpSlider
  3. Input Parameters:
    {
    <object parameters>
    orientation:string  
    max: double
    value: double
    }

Method Name: textarea
  1. Description: Creates a text area.
    • For a list of alignments, see constant section.
    • For a list of textStyles, see constant section.
  2. Return Type: FpTextarea
  3. Input Parameters:
    {
    <object parameters>
    editable: bool
    alignment: string
    text: string
    textStyle: string
    lineSpacing: integer
    }

Method Name: textentry
  1. Description: Creates a text entry.
  2. Return Type: FpTextentry
  3. Input Parameters:
    {
    <object parameters>
    text: string
    selStart: integer
    selEnd: integer
    maxLength: integer
    cursorPos: integer
    editable: bool
    password: bool
    cursorBlink: bool
    }

Theme

Method Name: changeTheme
  1. Description: Change to the theme passed, if available in the theme path
  2. Input Parameters:
    name: string

FpAnimator Class

Extends: none

Constructor

FpAnimator is constructed through the animator() method from Fp as shown in sample code below:

var fp = fp_init();
animator = fp.animator(function() {
    return false;
});

Setting animator = null would stop animator after garbage collection, which will stop the callback from being called. One may use animator.stop() or return false in callback to stop an FpAnimator before garbage collection.

Properties

None

Events

None

Methods

Method Name Input Parameters Return Type Description
restart
stop
toString string Returns the string “FpAnimator”

FpIdler Class

Extends: none

Constructor

FpIdler is constructed through the idler() method from Fp as shown in sample code below:

var fp = fp_init();
idler = fp.idler(function() {
    return false;
});

Setting idler = null would stop FpIdler after garbage collection, which will stop the callback from being called. One may use idler.stop() or return false in callback to stop an FpIdler before garbage collection.

Properties

None

Events

None

Methods

Method Name Input Parameters Return Type Description
stop
toString string Returns the string “FpIdler”

FpJob Class

Extends: none

Constructor

FpJob is constructed through the job() method from Fp as shown in sample code below:

var fp = fp_init();
job = fp.job(function() {
    return false;
});

Setting job = null would stop FpJob after garbage collection, which will stop the callback from being called. One may use job.stop() or return false in callback to stop an FpJob before garbage collection.

Properties

None

Events

None

Methods

Method Name Input Parameters Return Type Description
stop
toString string Returns the string “FpJob”

FpTimer Class

Extends: none

Constructor

FpTimer is constructed through the timer() method from Fp as shown in sample code below:

var fp = fp_init();
timer = fp.timer(1.0, function() {
    return false;
});

Setting timer = null would stop FpTimer after garbage collection, which will stop the callback from being called. One may use timer.stop() or return false in callback to stop an FpTimer before garbage collection.

Properties

Property Name Type Type Description
interval double Changes in timer interval will take effect immediately, ie. next timer callback will be triggered at the “interval” second after calling FpTimer.set().

Events

None

Methods


Method Name: get
  1. Description: Get the property value
  2. Return Type: Property specific type
  3. Input Parameters:
    propName: string

Method Name: restart
  1. Description: Restart the timer

Method Name: stop
  1. Description: Stop the timer

Method Name: set
  1. Description: Set the value of the property
  2. Input Parameters:
    propName: string,
    propValue: property type

Method Name: set
  1. Description: Set the value of the property. This method allows multiple properties to be set through a single call. “propName” is the name of the property listed in the Properties section above, while the “propValue” is the value to be set. The type of the “propValue” is dependent on the associated properties, please refer to Properties section for details.. stop
  2. Return Type:
  3. Input Parameters:
    {
    propName: propValue,
    propName: propValue,
    ...
    }

Method Name: toString
  1. Description: Returns the string “FpTimer { interval: X sec” where X is replaced by the value of interval property.
  2. Return Type: string

FpObject Class

Extends: none

This is the base class of all FancyPants objects except for Fp, FpAnimator, FpIdler, FpJob, and FpTimer. Every properties, events, methods defined in this class are applicable for all objects constructed from Fp class except for the ones mentioned above.

Constructor

FpObject instances are constructed through object/widget construction methods from Fp.

Properties

The properties can be retrieved and modified using the get() and set() methods. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.


Property Name: clip
  1. Type: FpRectangle

Property Name: color
  1. Type:
    {
    r: integer
    g: integer
    b: integer
    a: integer
    premul: bool
    }
  2. Description:
    • Please note that if not all of the r,g,b channels are specified, instead of replacing the missing channels with 0, the current object's color will be used instead. For example, if the object's current color is {r: 255, g:0, b:0, a:255}, by specifying obj.set(“color”, {g:255}), we're essentially modifying the green channel to a value of 255, resuling with {r:255, g:255, b:0, a:255}.
    • “premul” boolean indicates whether if the r,g,b,a values have been premultiplied. When color values are premultipled, the values of r,g,b must be less than or equals to alpha. “premul” is false by default, allowing developer to pass r,g,b,a within the range of 0~255 without worry about premultiplication.
    • As FancyPants uses premultiplied color internally for its performance benefit, the retrieved color through FpObject.get(“color”) will always have its premul set to true.
    • The impact of this is that the r,g,b information could be lost when alpha is reduced, so when alpha channel is restored, the values of r,g,b will not come back to its original values.

Property Name: coord
  1. Type:
    {
    x: integer
    y: integer
    }

Property Name: focus
  1. Type: bool

Property Name: layer
  1. Type: short

Property Name: name
  1. Type: string

Property Name: repeatEvent
  1. Type: bool

Property Name: perspective
  1. Type:
    {
    coord:
     {
       x: integer
       y: integer
       z: integer
     }
    }

Property Name: rotation
  1. Type:
    {
    angle: double
    center:
     {
       x: integer
       y: integer
     }
    relative: bool
    }
  2. Description:
    • Write-only property.
    • Unit of angle is in degrees.
    • “relative” can be used to indicate whether the rotation is to be applied relative to the last angle of rotation. For example, if an object has rotated 45 degrees, and rotation property is applied again with an angle of 5 degrees and “relative” set to true, the result will be that the object is further rotated by 5 degrees, resulting in 50 degrees rotation in total.
    • Setting “relative” to false would make the rotation to begin from original position.

Property Name: rotation3d
  1. Type:
    {
    angles:
     {
       x: double
       y: double
       z: double
     }
    center:
     {
       x: integer
       y: integer
       z: integer
     }
    relative: bool
    }
  2. Description:
    • Write-only property.
    • Unit of angle is in degrees.
    • “relative” can be used to indicate whether the rotation is to be applied relative to the last angle of rotation. For example, if an object has rotated 45 degrees, and rotation3d property is applied again with an angle of 5 degrees and “relative” set to true, the result will be that the object is further rotated by 5 degrees, resulting in 50 degrees rotation in total.
    • Setting “relative” to false would make the rotation to begin from original position.

Property Name: size
  1. Type:
    {
    w: integer
    h: integer
    }
  2. Description: The width and height of this object

Property Name: skipEvent
  1. Type: bool
  2. Description: Set to true if events are to be ignored by this object and false otherwise

Property Name: type
  1. Type: string
  2. Description:
    • Read-only property.
    • Please refer to the Constants section.

Property Name: visible
  1. Type: bool
  2. Description: Set to true if this object is visible and false otherwise

Events

Events on objects can be registered using the addEventListener() method.


Event Name: mouseIn
Definition of event info parameter in callback:
{
  pos:
    {
      x: int
      y: int
    }
  buttons: int
  timestamp: int
}

“buttons” is a bit mask where:


Event Name: mouseOut
Definition of event info parameter in callback:

Same as mouseIn.


Event Name: mouseDown
Definition of event info parameter in callback:
{
  pos:
    {
      x: int
      y: int
    }
  button: int
  timestamp: int
}

“button” is a number indicating which button has pressed:


Event Name: mouseUp
Definition of event info parameter in callback:

same as mouseDown


Event Name: mouseMove
Definition of event info parameter in callback:
{
  pos:
    {
      x: int
      y: int
    }
  prev:
    {
      x: int
      y: int
    }
  buttons: int
  timestamp: int
}

“buttons” is a bit mask where:


Event Name: mouseWheel
Definition of event info parameter in callback:
{
  pos:
    {
      x: int
      y: int
    }
  z: int
  direction: int
  timestamp: int
}

Value of “z”:


Event Name: free
Definition of event info parameter in callback:

This event indicates that the object has been deleted by the FancyPants, most likely due to the deletion of its parenting container. Application should remove reference on this object as any subsequent access will be invalid.


Event Name: keyDown
Definition of event info parameter in callback:
{
  key: string
  logicalKey: string
  string: string
  compose: string
  timestamp: int
}

Following explanation assumes SHIFT has been held down and 1 is pressed


Event Name: keyUp
Definition of event info parameter in callback:

same as keyDown.


Event Name: focusIn
Definition of event info parameter in callback:

Event Name: focusOut
Definition of event info parameter in callback:

Event Name: show
Definition of event info parameter in callback:

Event Name: hide
Definition of event info parameter in callback:

Event Name: move
Definition of event info parameter in callback:
{
  pos:
    {
      x: int
      y: int
    }
  prev:
    {
      x: int
      y: int
    }
}

Event Name: resize
Definition of event info parameter in callback:
{
  size:
    {
      w: int
      yh: int
    }
  prev:
    {
      w: int
      h: int
    }
}

Event Name: restack
Definition of event info parameter in callback:

Event Name: imagePreloaded
Definition of event info parameter in callback:

Event Name: clipChange
Definition of event info parameter in callback:
{
  isclipper: bool
  clipee: FpObject
  old: FpObject
  current: FpObject
}

This event indicates that the clip of a clipee object has been changed. If this event is registered on the clip object, it too will receive the same event when a clipee has been added to it.

Consider the following example:

    clip1 = fp.rectangle(...);
    clip2 = fp.rectangle(...);
    img = fp.image(...);
    //
    img.set(“clip”, clip1);
    //
    img.addEventListener(“clip”, function(ev) {..});
    clip1.addEventListener(“clip”, function(ev) {..});
    clip2.addEventListener(“clip”, function(ev) {..});

Now, when we execute following statement:

    img.set(“clip”, clip2);

img's clipChange event data:

    isclipper = false
    clipee = img
    old = clip1
    current = clip2

clip2's clipChange event data:

    isclipper = true
    clipee = img
    old = clip1
    current = clip2

clip1 will not be receiving the clipChange event.


General Methods


Method name: addEventListener
Input parameters:
Description:

Method name: addKeyGrab
Input parameters:
Return type: bool
Description:

Method name: get
Input parameters:
Return type:
Description:

Gets the property value, or simply treat the properties like class variables and retrieve by obj.xxx syntax.


Method name: reflect
Description:

Adds the reflection effect on the object.


Method name: removeEventListener
Input parameters:
Description:

In the case of missing “callback” parameter, this function removes all listeners from the specified event.


Method name: removeKeyGrab
Input parameters:

Method name: ripple
Description:

Adds the ripple effect on the object.


Method name: set
Input parameters:
Description:

Sets the value of the property.


Method name: set
Input parameters:
{
  propName: propValue,
  propName: propValue,
  ...
}
Description:

This method allows multiple properties to be set through a single call. “propName” is the name of the property listed in the Properties section above, while the “propValue” is the value to be set. The type of the “propValue” is dependent on the associated properties, please refer to Properties section for details..

For example:

obj.set({
  coord:{x:10},
  size: {w: 100, h: 200},
  focus: true
});

Method name: stackAbove
Input parameters:

Method name: stackBelow
Input parameters:

Method name: stackBottom

Method name: stackTop

Method name: toString
Return type:
Description:

Returns the concrete class name of the object, with the value of the “name” property appended if available.


Effects


Method name: boing
Input parameters
{
  osc: double
  b: double
  a: double
  w: double
  callback: function
}
Description

Method name: bounce
Input parameters
{
  stop: bool
  callback: function
}
Description
Example
// Start bouncing
obj.bounce({callback: func1});
// Stop bouncing
obj.bounce({callback: func2});
// Only “func2” will be invoked when the bounce effect stopped.

Method name: colorEffect
Input parameters
{
  list: 
    [
      {
        effect: string
        param: string
      },
      {
        effect: string
        param: string
      },
      ...
    ],
  callback: function
}
Description

Method name: fade
Input parameters
{
  stop: bool
  fadeIn: bool
  callback: function
}
Description

Method name: fly
Input parameters
{
  dest :
    {
      x: integer
      y: integer
    }
  speed: integer
  rotations :
    {
      x: integer
      y: integer
      z: integer
    }
  callback: function
}
Description

Method name: follow
Input parameters
{
  src: FpObject
  top: integer
  left: integer
  right: integer
  bottom: integer
}

Method name: moveto
Input parameters
{
  dest :
    {
      x: integer
      y: integer
    }
  accel: bool
  callback: function
}
Description

Method name: shaderEffect
Input parameters
{
  stop: bool
  effect: string
  args: <shader dependent arguments>
}

If effect = “ripple”:

args =
 {
 center_x: double
 center_y: double
 }
 // center_x/y has range of 0~1 indicating the width/height of object.

If effect = “peel”:

args =
 {
 tess_col: integer
 tess_row: integer
 }
Description

Method name: shaderEffect
Input parameters

effect: string

Description

Method name: stars
Input parameters
{
  stop: bool
}
Description

There is only 1 instance of the stars effect, calling stars() multiple times will be ignored. “stop” can be use to stop the stars effect if needed.


Method name: transform
Input parameters
{
  newCoord :
    {
      x: integer
      y: integer
    }
  newSize :
    {
      w: integer
      h: integer
    }
  newColor :
    {
      r: integer
      g: integer
      b: integer
      a: integer
      premul: bool
    }
  callback: function
}
Description

Method name: typer
Input parameters
{
  stop: bool
  callback: function
}
Description

Method name: vacuum
Input parameters
{
  tl :
    {
      x: integer
      y: integer
    }
  tr :
    {
      x: integer
      y: integer
    }
  bl :
    {
      x: integer
      y: integer
    }
  br :
    {
      x: integer
      y: integer
    }
  tlTime: integer
  trTime: integer
  blTime: integer
  brTime: integer
  callback: function
}
Description

FpRectangle Class

Extends: FpObject

Constructor

FpRectangle instance is constructed through object/widget construction methods from Fp.

Properties

Properties of this class are inherited from FpObject, please refer to the list of properties supported by FpObject for details.

Events

Events supported by this class are inherited from FpObject, please refer to the list of events supported by FpObject for details.

Methods

This section defines the FpRectangle specific methods, please refer to FpObject methods page for list of methods supported in parent class.

Method Name Input Parameters Return Type Description
getClipees FpObject[] Returns null if no clipees.

FpText Class

Extends: FpObject

Constructor

FpText instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.

Property Name Type Description
text string
textEffect string Please refere to Constants section for a list of text effects.
style string Please refere to Constants section for a list of text styles. The values aren't limited to the list of constant. They retrieve the properties from the table located in the metrics file of the current theme name font_[the string]
glowColor { r: integer, g: integer, b: integer, a: integer, premul: bool } set only
glow2Color same set only
shadowColor same set only
outlineColor same set only

Events

Events supported by this class are inherited from FpObject, please refer to the list of events supported by FpObject for details.

Methods

Please refer to FpObject methods page for list of methods supported in parent class.

FpContainer Class

Extends: FpObject

Constructor

FpContainer instance is constructed through object/widget construction methods from Fp.

Properties

Properties of this class are inherited from FpObject, please refer to the list of properties supported by FpObject for details.

Events

Events supported by this class are inherited from FpObject, please refer to the list of events supported by FpObject for details.

Methods

This section defines the FpContainer specific methods, please refer to FpObject methods page for list of methods supported in parent class.

Method Name Input Parameters Description
add obj: FpObject, x: int, y: int x & y are optional parameters, indicating the offset of into the container object where the child should be added.
add obj: FpObject,
{ x: int, y: int }
Same as add(obj, x, y) above). The x & y parameters are optional in this method also.
remove obj: FpObject

FpImage Class

Extends: FpObject

Constructor

FpImage instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.


Property Name: border
Type
{
  left: integer,
  top: integer,
  right: intger,
  bottom: integer
}

Property Name: file
Type

string


Property Name: nativeSize
Type
{
  w: integer,
  h: integer
}
Description

Read-only property


Property Name: tile
Type
{
  x: integer,
  y: integer,
  w: integer,
  h: integer
}
Description

Property Name: url
Type
Description

Property Name: theme_image
Type

string

Description

The string passed into the constructor is a key to the metrics file. The key can be either a variable in the metrics file as follows:

var string = { file: “filename_of_image.png” }

To key can also be a function in the metrics file as follows:

function string(data) {
    print(“Hi”);
    // set image properties
    data.themeImageByFile(“filename_of_image.png”);
}

Events

Events supported by this class are inherited from FpObject, please refer to the list of events supported by FpObject for details.

Methods

This section defines the FpImage specific methods, please refer to FpObject methods page for list of methods supported in parent class.

Method Name Input Parameters Description
preload
preloadAbort
themeImageByKey string Looks in the current theme metrics file for a variable name as the string passed. If the variable is a function, the function gets executed. if the variable is a table, the image loads its properties from the table entries (file, border...). The theme metric file is $FP_THEMEPATH/currenttheme/metrics.fpj
themeImageByFile string Does the equivalent of a file set but prepending the passed string with “currenttheme/images/” where currenttheme is the full path of the current theme. The current theme is located in $FP_THEMEPATH/currenttheme/.

FpLayout Class

Extends: FpObject

Constructor

FpLayout instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.

Property Name Type Description
orientation string Please refer to Constants section for a list of orientations.

Events

Events supported by this class are inherited from FpObject, please refer to the list of events supported by FpObject for details.

Methods

This section defines the FpLayout specific methods, please refer to FpObject methods page for list of methods supported in parent class.

Method Name Input Parameters Description
add obj: FpObject, offset: integer, padding: integer “obj” is a mandatory parameter while all others are optional.
add obj: FpObject, mode: string, offset: integer, padding: integer “obj” is a mandatory parameter while all others are optional. Please refer to Constants section for a list of layout child modes.
add obj: FpObject,
{ mode: string, offset: integer, padding: integer }
“obj” is a mandatory parameter while all others are optional. Please refer to Constants section for a list of layout child modes.
remove obj: FpObject

FpMedia Class

Extends: FpObject

Constructor

FpMedia instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.


Property Name file
Type

string


Property Name duration
Type

double

Description

Read-only property.


Property Name elapsed
Type

double

Description

Read-only property.


Property Name keepAspect
Type

bool


Property Name loop
Type

bool


Property Name mute
Type

bool


Property Name: nativeSize
Type
{
  w: integer
  h: integer
}
Description

Read-only property.


Property Name: speed
Type

double

Description

Property Name: state
Type

string

Description

Property Name: tile
Type
{
  x: integer
  y: integer
  w: integer
  h: integer
}
Description

Property Name: url
Type

string


Property Name: videoLayer
Type

integer

Description

Write-only property.


Property Name: volume
Type

integer

Description

0 ~ 100

Events

There are two types of events supported by FpMedia: the events inherited from FpObject, and FpMedia specific events. For details on FpObject events, please refer to FpObject section. Following table defines a list of events specific to FpMedia, which can only be registered using the FpMedia.addMediaEventListener() method.

Event String Description
ready
meta
error The “extra” parameter in the callback specifies the error text. Please refer to the Constants section for a list of error strings.
end
bufferStart
bufferFilled
bufferData The “extra” parameter in the callback specifies the buffer percentage (0 ~ 100).

Methods

This section defines the FpMedia specific methods, please refer to FpObject methods page for list of methods supported in parent class.

Method Name Input Parameters Return Type Description
addMediaEventListener callback: function Caller does not need to specify the type of media event to add, caller only needs to specify a callback to receive and handle all types of media events. Callback is in the form of:
void callback(event_string, extra)
imageAttach img: FpImage Output the video onto an image object as well.
imageDetach img: FpImage
open bool
pause bool
play bool
removeMediaEventListener callback: function In the case of missing “callback” parameter, this function removes all media event listeners.
seek offset: double, whence: string bool Please refer to the Constants section for a list of whence values. “whence” is an optional parameter and has a default value of “set”.
stop bool

FpTextentry Class

Extends: FpObject

Constructor

FpTextentry instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.

Property Name Type Description
cursorBlink bool
alignment string See Constant
cursorPos integer
editable bool
maxLength integer
password bool
selEnd integer
selStart integer
selText string getter only, not setter
selTextLength integer getter only
text string
textLength integer getter only, not setter

Events

Events supported by this class are inherited from FpObject, please refer to the list of events supported by FpObject for details.

Event Name Definiton of “event_info” Parameter in Callback
enter User press enter. text passed as first parameter to the handler.

Methods

Please refer to FpObject methods page for list of methods supported in parent class.

FpCheckbox Class

Extends: FpObject

Constructor

FpCheckbox instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.

Property Name Type Description
checked bool
text string
style string Please refer to the Constants section for a list of text styles.

Events

Events supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use addEventListener() method as defined by FpObject to register the event listener for both of these types of events.

Event name Definiton of “event_info” Parameter in Callback
change “event_info” will be a bool value indicating whether if the checkbox is checked. true means checked, false means unchecked.

Methods

This section defines the FpCheckbox specific methods, please refer to FpObject methods page for list of methods supported in parent class.

Method Name Input Parameters Return Type Description
toggle bool Toggle the checkbox between checked and unchecked states. Function returns the state of checkbox after it's being toggled. true means checked, false means unchecked.

FpProgressbar Class

Extends: FpObject

Constructor

FpProgressbar instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.

Property Name Type Description
orientation string Please refer to the Constants section for a list of orientations.
max double
value double

Events

Events supported by this class are inherited from FpObject, please refer to the list of events supported by FpObject for details.

Methods

Pease refer to FpObject methods page for list of methods supported in parent class.

FpCalendar Class

Extends: FpObject

Constructor

FpCalendar instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.

Property Name: date
Type
{
  year: integer
  month: integer
  day: integer
  timestamp: integer
}
Description

Events

Events supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use addEventListener() method as defined by FpObject to register the event listener for both of these types of events.

Event name Definiton of “event_info” Parameter in Callback
change Triggered when the selected date of the calendar has been changed. The passed date (see type above) contains the new date.

Methods

Please refer to FpObject methods page for list of methods supported in parent class.

FpButton Class

Extends: FpObject

Constructor

FpButton instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.

Property Name Type Description
text string Label of the button
bgThemeImageKey string Button background image theme key (refer to FpImage:imageThemeByKey)
textStyle string Please refer to the Constants section for a list of text styles.
sensitive bool

Events

Events supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use addEventListener() method as defined by FpObject to register the event listener for both of these types of events.

Event name Definiton of “event_info” Parameter in Callback
click Triggered when the button is clicked.

Methods

Please refer to FpObject methods page for list of methods supported in parent class.

FpCube Class

Extends: FpObject

Constructor

FpCube instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.


Property Name: angle
Type
{
  deg: double
  direction: string
}
Description

Both the “deg” and “direction” are mandatory parameter, the “direction” can be one of “snap”, “left”, "right”.


Property Name: rotationDuration
Type

double

Description

The number of seconds for the cube to animate to the target rotation degree.


Property Name: depth
Type

integer


Property Name: orientation
Type

string

Description

Please refer to the Constants section for a list of orientations.


Property Name: perspective
Type
{
  coord :
    {
      x: integer
      y: integer
      z: integer
    }
}

Property Name: tilt
Type
{
  deg: double
  direction: string
}
Description

Both the “deg” and “direction” are mandatory parameter, the “direction” can be one of “snap”, “up”, "down”.

Events

Events supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use addEventListener() method as defined by FpObject to register the event listener for both of these types of events.

Event name Definiton of “event_info” Parameter in Callback
animate “event_info” will be a bool value indicating whether if the cube animation is in progress or has ended. true means animating, false means animation stopped.

Methods

This section defines the FpCube specific methods, please refer to FpObject methods page for list of methods supported in parent class.

Method Name Input Parameters Return Type Description
add face: FpObject bool Up to 6 objects can be added to the cube, each object represents a face on the cube. Once all 6 faces have been added (including the faces added through FpCube constructor call), any subsequent objects will be ignored.
The order to which face the object will be added to is as follows: Front, Right, Back, Left, Top, Bottom.
Function returns “true” indicating the object was successfully added, “false” otherwise.

FpFlip Class

Extends: FpObject

Constructor

FpFlip instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.


Property Name: angle
Type
{
  deg: double
  direction: string
}
Description

Property Name: depth
Type

integer


Property Name: showboth
Type

bool

Events

Events supported by this class are inherited from FpObject, please refer to the list of events supported by FpObject for details.

Methods

Please refer to FpObject methods page for list of methods supported in parent class.

FpKeyboard Class

Extends: FpObject

FpKeyboard is a widget that displays a virtual keyboard on screen, allowing user to enter text to the FpTextentry widget as the keys are clicked on. As such, Fpkeyboard only responds to mouse input, and require a FpTextentry to be created and focused in order to have any effect.

Constructor

FpKeyboard instance is constructed through object/widget construction methods from Fp.

Properties

Properties of this class are inherited from FpObject, please refer to the list of properties supported by FpObject for details.

Events

Events supported by this class are inherited from FpObject, please refer to the list of events supported by FpObject for details.

Methods

Please refer to FpObject methods page for list of methods supported in parent class.

FpTextarea Class

Extends: FpObject

Constructor

FpTextarea instance is constructed through object/widget construction methods from Fp.

Properties

Properties of this class are inherited from FpObject, please refer to the list of properties supported by FpObject for details. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.

Property Name Type Description
cursorPos integer
editable bool
alignment string See Constant
text string
textHeight integer get() only, text height, in pixel
textStyle string set() only, For a list of text styles please refer to the Constants section.
lineSpacing integer set() only Number of pixels between lines

Events

Events supported by this class are inherited from FpObject, please refer to the list of events supported by FpObject for details.

Methods

Please refer to FpObject methods page for list of methods supported in parent class.

FpSlider Class

Extends: FpObject

Constructor

FpSlider instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.

Property Name Type Description
max double
value double

Events

Events supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use addEventListener() method as defined by FpObject to register the event listener for both of these types of events.

Event Name Definiton of “event_info” Parameter in Callback
change Triggered when the position of the slider bar has been changed. The new value property is passed.

Methods

Please refer to FpObject methods page for list of methods supported in parent class.

FpFilebrowser Class

Extends: FpObject

Constructor

FpFilebrowser instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.


Property Name: content
Type
[
  {
    name: string
    folder: bool
    playlist: bool
    size: double
    date: string
    thumbnail: string
  },
  {
    name: string
    folder: bool
    playlist: bool
    size: double
    date: string
    thumbnail: string
  },
  ...
]
Description

Read-only property.


Property Name: filter
Type

string

Description

Property Name: path
Type

string

Description

Setting this property will not trigger the “change” event callback.


Property Name: traversal
Type

string

Description

Events

Events supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use addEventListener() method as defined by FpObject to register the event listener for both of these types of events.

Event Name Definiton of “event_info” Parameter in Callback
change Event callback is triggered when user changes a directory within file browser, the callback is not triggered when “path” property is changed.
“event_info” will be the path of the directory that the file browser is changing to.
select Event callback is triggered when user select an item in file browser.
“event_info” will be the name of the item (file or folder) that is being selected in the file browser.

Methods

Please refer to FpObject methods page for list of methods supported in parent class.

FpMultiselect Class

Extends: FpObject

Constructor

FpMultiselect instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.

Property Name Type Description
opened bool
selItem string
alignment string set() only, See Constant
openable boolean set() only
maxHeight integer set() only, Maximum height of the list of items.

Events

Events supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use addEventListener() method as defined by FpObject to register the event listener for both of these types of events.

Event Name Definiton of “event_info” Parameter in Callback
select Triggered when the selected item has changed. The new selItem: string is passed.

Methods

This section defines the FpMultiselect specific methods, please refer to FpObject methods page for list of methods supported in parent class.

Method Name Input Parameters Return Type Description
add item: string Add the item to the list of items
add items: string[] Add the items to the list of items
clear clear the list of items

FpScrolllist Class

Extends: FpObject

Constructor

FpScrolllist instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.

Property Name Type Description
hAppear string Please refer to Constants section for a list of appear modes for horizontal and vertical scrollbars.
kinetic bool
orientation string Please refer to the Constants section for a list of orientations.
offset integer
padding integer
selIndex integer Read-only property.
-1 if no object is selected.
selObject FpObject Use get() to retrieve the currently selected object, null if no object is selected.
Use set() to set focus on the object.
scroll string Please refer to Constants section for a list of scroll modes.
vAppear string Please refer to Constants section for a list of appear modes for horizontal and vertical scrollbars.

Events

Events supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use addEventListener() method as defined by FpObject to register the event listener for both of these types of events.

Event Name Definiton of “event_info” Parameter in Callback
select “event_info” will be a FpObject indicating the object that has been selected in the scroll list.

Methods

This section defines the FpScrolllist specific methods, please refer to FpObject methods page for list of methods supported in parent class.

Method Name Input Parameters Return Type Description
add obj: FpObject
clear
remove obj: FpObject

FpScrollbar Class

Extends: FpObject

Constructor

FpScrollbar instance is constructed through object/widget construction methods from Fp.

Properties

Properties supported by this class are ones inherited from FpObject and the ones listed in the table below. Please use get() and set() methods as defined by FpObject to retrieve and modify these properties. Properties can also be retrieved by treating them as class variables and accessible through obj.xxx syntax.


Property Name: fading
Type

bool


Property Name: hAppear
Type

string

Description

Please refer to Constants section for a list of appear modes for horizontal and vertical scrollbar.


Property Name: kinetic
Type

bool


Property Name: scrollPos
Type
{
  x: integer
  y: integer
}

Property Name: target
Type

obj: FpObject

Description

Value can be null to unset the object in scrollbar.


Property Name: vAppear
Type

string

Description

Please refer to Constants section for a list of appear modes for horizontal and vertical scrollbar.

Events

Events supported by this class are inherited from FpObject, please refer to the list of events supported by FpObject for details.

Methods

Please refer to FpObject methods page for list of methods supported in parent class.

Back to main - Copyright © 2015 Fluffy Spider Techologies - http://fluffyspider.com