LGUI2:Canvas Operation

From Lavish Software Wiki
Revision as of 22:48, 2 October 2019 by Lax (talk | contribs) (Created page with "A LGUI2:Canvas Operation is a rendering instruction for a LGUI2:canvas. Each Canvas Operation is defined by a JSON Object. When specifying a list of operations, suc...")
(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to navigation Jump to search

A Canvas Operation is a rendering instruction for a canvas.

Each Canvas Operation is defined by a JSON Object. When specifying a list of operations, such as the canvas' "initialize" property or a Batch call, the operation is specified by an "op" property. Otherwise, the operation is selected outside of the JSON (for example, LavishScript methods named DrawRect, DrawCircle, etc specify the operation instead).

List of Canvas Operations

clear

Clears the canvas (sets all pixels to the same value), either to transparent #00000000 or to a specified color value.

clear operation properties
op clear
color (Optional) A Color definition


initialize

Initializes the Canvas by Batching its "initialize" array, if either a) it has not been auto-initialized since last allocated, or b) "force" is set to true

initialize operation properties
op initialize
force (Optional) A boolean value specifying whether initialize should be Batched regardless of any prior state. This may be useful after a clear operation, which does not auto-initialize the canvas.


pushBrush

Pushes a Brush onto the Brush stack for the Canvas. The top Brush on the stack is used for drawing.

pushBrush operation properties
op pushBrush
font A string specifying the name of a Brush specified by the Canvas


popBrush

Pops a Brush off the Brush stack for the Canvas. The top Brush on the stack is used for drawing.

popBrush operation properties
op popBrush
font (Optional) A string specifying the name of a Brush specified by the Canvas


pushFont

Pushes a Font onto the Font stack for the Canvas. The top Font on the stack is used for drawing text.

pushFont operation properties
op pushFont
font A string specifying the name of a Font specified by the Canvas


popFont

Pops a Font off the Font stack for the Canvas. The top Font on the stack is used for drawing text.

popFont operation properties
op popFont
font (Optional) A string specifying the name of a Font specified by the Canvas


drawArc

Draws an arc using the top Brush on the stack

Form 1

popFont operation properties
op drawArc
transform A boolean value specifying whether to transform vertices by scaling to the canvas size. (default true)
x A floating point value specifying the X-coordinate of the center of the arc
y A floating point value specifying the Y-coordinate of the center of the arc
opacity A floating point value specifying the opacity of the arc (default 1.0)
color A Color specifying the color to apply to the arc. If not specified, the Brush color is used.
startDegrees A floating point value specifying the starting angle, in degrees clockwise from 3 o'clock.
endDegrees A floating point value specifying the ending angle, in degrees clockwise from 3 o'clock.
innerRadius A floating point value specifying the radius of the inner edge of the arc
outerRadius A floating point value specifying the radius of the outer edge of the arc
segments An integer value specifying the number of segments to generate along the outer edge of the arc. A higher value produces a higher resolution arc.

Form 2

popFont operation properties
op drawArc
transform A boolean value specifying whether to transform vertices by scaling to the canvas size. (default true)
x A floating point value specifying the X-coordinate of the center of the arc
y A floating point value specifying the Y-coordinate of the center of the arc
opacity A floating point value specifying the opacity of the arc (default 1.0)
color A Color specifying the color to apply to the arc. If not specified, the Brush color is used.
centerDegrees A floating point value specifying the starting angle, in degrees clockwise from 3 o'clock.
innerArcLength A floating point value specifying the arc length of the inner arc, in degrees
outerArcLength A floating point value specifying the arc length of the outer arc, in degrees
innerRadius A floating point value specifying the radius of the inner edge of the arc
outerRadius A floating point value specifying the radius of the outer edge of the arc
segments An integer value specifying the number of segments to generate along the outer edge of the arc. A higher value produces a higher resolution arc.


drawCircle

drawCircle operation properties
op drawCircle
transform A boolean value specifying whether to transform vertices by scaling to the canvas size. (default true)
x A floating point value specifying the X-coordinate of the center of the circle
y A floating point value specifying the Y-coordinate of the center of the circle
radius A floating point value specifying the radius of the circle
opacity A floating point value specifying the opacity of the circle (default 1.0)
color A Color specifying the color to apply to the circle. If not specified, the Canvas' Foreground color is used.


drawRect

drawRect operation properties
op drawRect
transform A boolean value specifying whether to transform vertices by scaling to the canvas size. (default true)
x A floating point value specifying the X-coordinate of the top left corner of the rectangle
y A floating point value specifying the Y-coordinate of the top left corner of the rectangle
width A floating point value specifying the width of the rectangle
height A floating point value specifying the height of the rectangle
opacity A floating point value specifying the opacity of the text (default 1.0)
color A Color specifying the color to apply to the text. If not specified, the Canvas' Foreground color is used.


drawText

drawText operation properties
op drawText
transform A boolean value specifying whether to transform vertices by scaling to the canvas size. (default true)
x A floating point value specifying the X-coordinate of the top left corner of the text
y A floating point value specifying the Y-coordinate of the top left corner of the text
opacity A floating point value specifying the opacity of the text (default 1.0)
color A Color specifying the color to apply to the text. If not specified, the Canvas' Foreground color is used.
text The text to render


drawPrimitives

drawPrimitives operation properties
op drawPrimitives
type A string value specifying one of "triangleList" "triangleStrip" "lineList" "lineStrip" or "pointList"
transform A boolean value specifying whether to transform vertices by scaling to the canvas size. (default true)
vertices A JSON Array of canvas vertex definitions (see below)


Canvas Vertex Definitions

A Canvas Vertex can be specified either by a JSON Array or Object.

canvas vertex properties
x A floating point value specifying the X-coordinate
y A floating point value specifying the Y-coordinate
tu A floating point value specifying the texture X-coordinate (always between 0 and 1)
tv A floating point value specifying the texture Y-coordinate (always between 0 and 1)
color A Color definition specifying the color to apply to the vertex. If not specified, the Brush color will be used.
opacity A floating point value specifying the opacity value to use for the vertex. (default 1.0)

Alternatively, the properties specified in the table above can be given in array form, in the listed order. In short: [x,y,tu,tv,color,opacity]