My favorites | English | Sign in

o3d.CanvasPaint Class Reference

Inherits o3d.ParamObject

List of all members.


Detailed Description

The CanvasPaint class is used for specifying how to draw objects and text to a canvas.

Public Types

enum Style o3d.CanvasPaint
enum TextAlign o3d.CanvasPaint

Public Member Functions

copyParams(sourceParamObject) o3d.ParamObject
o3d.Param  createParam(paramName, paramTypeName) o3d.ParamObject
!o3d.CanvasFontMetrics  getFontMetrics() o3d.CanvasPaint
o3d.Param  getParam(paramName) o3d.ParamObject
boolean  isAClassName(className) o3d.ObjectBase
!o3d.Float4  measureText(text) o3d.CanvasPaint
boolean  removeParam(param) o3d.ParamObject
setOutline(radius, color) o3d.CanvasPaint
setShadow(radius, offsetY, offsetX, color) o3d.CanvasPaint

Public Properties

string className o3d.ObjectBase
number clientId o3d.ObjectBase
!o3d.Float4 color o3d.CanvasPaint
!o3d.CanvasFontMetrics fontMetrics o3d.CanvasPaint
string name o3d.NamedObject
!Array.<!o3d.Param> params o3d.ParamObject
o3d.CanvasShader shader o3d.CanvasPaint
o3d.CanvasPaint.TextAlign textAlign o3d.CanvasPaint
number textSize o3d.CanvasPaint
o3d.CanvasPaint.Style textStyle o3d.CanvasPaint
string textTypeface o3d.CanvasPaint

Public Types Documentation

enum o3d.CanvasPaint.Style

Style

  • NORMAL,
  • BOLD,
  • ITALIC,
  • BOLD_ITALIC Text styles
  • enum o3d.CanvasPaint.TextAlign

    TextAlign

  • LEFT,
  • CENTER,
  • RIGHT, Text alignment options

  • Member Function Documentation

    CanvasPaint.copyParams ( !o3d.ParamObject sourceParamObject ) [inherited from o3d.ParamObject]

    Copies all the params from a the given source_param_object to this param object. Does not replace any currently existing params with the same name.

    Parameters:
    sourceParamObject param object to copy params from.
    o3d.Param CanvasPaint.createParam ( string paramName
    string paramTypeName ) [inherited from o3d.ParamObject]

    Creates a Param with the given name and type on the ParamObject. Will fail if a param with the same name already exists.

    Parameters:
    paramName The name of the Param to be created.
    paramTypeName The type of Param to create. Valid types are
  • 'o3d.ParamBoolean'
  • 'o3d.ParamBoundingBox'
  • 'o3d.ParamDrawContext'
  • 'o3d.ParamDrawList'
  • 'o3d.ParamEffect'
  • 'o3d.ParamFloat'
  • 'o3d.ParamFloat2'
  • 'o3d.ParamFloat3'
  • 'o3d.ParamFloat4'
  • 'o3d.ParamFunction'
  • 'o3d.ParamInteger'
  • 'o3d.ParamMaterial'
  • 'o3d.ParamMatrix4'
  • 'o3d.ParamParamArray'
  • 'o3d.ParamRenderSurface'
  • 'o3d.ParamRenderDepthStencilSurface'
  • 'o3d.ParamSampler'
  • 'o3d.ParamSkin'
  • 'o3d.ParamSteamBank'
  • 'o3d.ParamState'
  • 'o3d.ParamString'
  • 'o3d.ParamTexture'
  • 'o3d.ParamTransform'
  • 'o3d.ProjectionParamMatrix4'
  • 'o3d.ProjectionInverseParamMatrix4'
  • 'o3d.ProjectionTransposeParamMatrix4'
  • 'o3d.ProjectionInverseTransposeParamMatrix4'
  • 'o3d.ViewParamMatrix4'
  • 'o3d.ViewInverseParamMatrix4'
  • 'o3d.ViewTransposeParamMatrix4'
  • 'o3d.ViewInverseTransposeParamMatrix4'
  • 'o3d.ViewProjectionParamMatrix4'
  • 'o3d.ViewProjectionInverseParamMatrix4'
  • 'o3d.ViewProjectionTransposeParamMatrix4'
  • 'o3d.ViewProjectionInverseTransposeParamMatrix4'
  • 'o3d.WorldParamMatrix4'
  • 'o3d.WorldInverseParamMatrix4'
  • 'o3d.WorldTransposeParamMatrix4'
  • 'o3d.WorldInverseTransposeParamMatrix4'
  • 'o3d.WorldViewParamMatrix4'
  • 'o3d.WorldViewInverseParamMatrix4'
  • 'o3d.WorldViewTransposeParamMatrix4'
  • 'o3d.WorldViewInverseTransposeParamMatrix4'
  • 'o3d.WorldViewProjectionParamMatrix4'
  • 'o3d.WorldViewProjectionInverseParamMatrix4'
  • 'o3d.WorldViewProjectionTransposeParamMatrix4'
  • 'o3d.WorldViewProjectionInverseTransposeParamMatrix4'
  • Returns:
    o3d.Param.The newly created Param or null on failure.
    CanvasPaint.getFontMetrics ( )

    Returns metrics describing the font currently set on this paint object.

    Returns:
    !o3d.CanvasFontMetrics.The font metrics.
    o3d.Param CanvasPaint.getParam ( string paramName ) [inherited from o3d.ParamObject]

    Searches by name for a Param defined in the object.

    Parameters:
    paramName Name to search for.
    Returns:
    o3d.Param.The Param with the given name, or null otherwise.
    boolean CanvasPaint.isAClassName ( string className ) [inherited from o3d.ObjectBase]

    Takes the name of a class as an argument, and returns true if this object is either an instance of that class or derives from that class.

    var t = pack.createObject('o3d.Transform');
    t.isAClassName('o3d.Transform');    // true
    t.isAClassName('o3d.ParamObject');  // true
    t.isAClassName('o3d.Shape');        // false
    
    Parameters:
    className Name of class to check for.
    Returns:
    boolean.true if this object is a or is derived from the given class name.
    !o3d.Float4 CanvasPaint.measureText ( string text )

    Returns the bounds of the given text string when rendered with this paint. The bounds are returned as an array containing [left, top, right, bottom] values relative to (0, 0).

    Parameters:
    text The string of text to be measured.
    Returns:
    !o3d.Float4.The bounds of text.
    boolean CanvasPaint.removeParam ( !o3d.Param param ) [inherited from o3d.ParamObject]

    Removes a Param from a ParamObject. This function will fail if the param does not exist on this ParamObject or if the param is unremovable.

    Parameters:
    param param to remove.
    Returns:
    boolean.True if the param was removed.
    CanvasPaint.setOutline ( number radius
    !o3d.Float4 color )

    Sets the color and radius of an outline around the text. Setting the radius to 0 cancels the outline effect. The outline and shadow effects are mutually exclusive.

    Parameters:
    radius Distance outward from object to draw the background
    color Color of the outline
    CanvasPaint.setShadow ( number radius
    number offsetY
    number offsetX
    !o3d.Float4 color )

    Create a blur shadow effect on this paint. Setting the radius to 0 cancels the shadow effect.

    Parameters:
    radius radius to blur the paint
    offsetY offset of the blur in X
    offsetX offset of the blur in Y
    color color for the blur

    Member Property Documentation

    string CanvasPaint.className [inherited from o3d.ObjectBase]

    The concrete class name for an object derived from ObjectBase. If you want to know if an object is of a certain type you should use objectBase.isAClassName

    var t = pack.createObject('o3d.Transform');
    t.className == 'o3d.Transform';  // true
    
    This property is read-only.
    number CanvasPaint.clientId [inherited from o3d.ObjectBase]

    Unique id of the object. This id will be unique, even across multiple O3D clients in the same page. This property is read-only.

    !o3d.Float4 CanvasPaint.color

    The color used for all the draw operations using this paint. Default = [0, 0, 0, 1].

    !o3d.CanvasFontMetrics CanvasPaint.fontMetrics

    Metrics of the current font used by the paint object. This property is read-only.

    string CanvasPaint.name [inherited from o3d.NamedObject]

    The object's name. Setting this has no meaning to O3D, but is useful for debugging and for the functions Client.getObjects, Pack.getObject, RenderNode.getRenderNodesByNameInTree and RenderNode.getTransformsByNameInTree which search for objects by name.

    !Array.<!o3d.Param> CanvasPaint.params [inherited from o3d.ParamObject]

    Gets all the param on this param object. Each access to this field gets the entire list, so it is best to get it just once. For example:

    var params = paramObject.params;
    for (var i = 0; i < params.length; i++) {
      var param = params[i];
    }
    
    Note that modifications to this array [e.g. push()] will not affect the underlying ParamObject, while modifications to the array's members will affect them. This property is read-only.
    o3d.CanvasShader CanvasPaint.shader

    The 2D shader used by this paint. Set to null to stop using a shader.

    o3d.CanvasPaint.TextAlign CanvasPaint.textAlign

    The alignment mode used for drawing text. Default = LEFT.

    number CanvasPaint.textSize

    The size of the font used for drawing text. Default = 10.

    o3d.CanvasPaint.Style CanvasPaint.textStyle

    The style applied to the text (e.g. italic, bold, etc) Default = NORMAL.

    string CanvasPaint.textTypeface

    The font typeface used for drawing text. Passing an empty string will revert to the default font. Default = "".