Canvas
Last updated
Was this helpful?
Last updated
Was this helpful?
(part of package '') Extends designtime/SolutionModel: Extends runtime:
This is a reference page; many components have detailed usage guides .
Array of canvas objects to be rendered on the canvas. Type:
Configuration options for the canvas rendering engine. Type:
The size, in pixels, of each grid cell used for drawing and snapping. Type: Default Value: 10
Array of media references for images that are preloaded for use in canvas objects. Type:
Called after the canvas has finished rendering all objects.
Called when a canvas object is clicked.
Called when a canvas object is long-pressed (touch event).
Called when a canvas object is modified (e.g., moved, scaled, or rotated).
Called when the canvas is fully initialized and ready for interaction.
Zooms into the canvas given the x/y coords and a zoom level.
Parameters:
Add one or more canvas objects and optionally select it. If given more than one item in the objs array, the elements will be grouped as a single entity.
Parameters:
Brings a specific element given it's ID, to the front layer of the canvas
Parameters:
Clear the canvas and remove all objects
clones the currently selected element.
Get the selected object
Parameters:
Loads the canvas from a JSON object
Parameters:
Print the current canvas view (TING only). Can use an optional DPI resolution for higher quality prints.
Parameters:
Remove an canvas object given it's ID.
Parameters:
Rotate the canvas at a specific angle
Parameters:
Save the canvas as an image. The callback has a single parameter which contains the base64 data of the canvas.
Parameters:
Save the canvas as a JSON object. The callback has a single parameter which contains the JSON object. This JSON object can be used with the loadCanvas method.
Parameters:
Select one or more objects in the canvas given it's ID.
Parameters:
Start animating sprites
Stop animating sprites
Update a specific canvas object and optionally select it
Parameters:
Definition of a canvas object. scripting type: CustomType<svycanvas-Canvas.canvasObject>
angle
The rotation angle of the canvas object in degrees.
ctrl
Holds control data for the object.
custom_data
A generic property to store custom data related to the canvas object.
fill
The fill color of the canvas object.
flipX
If true, the object is flipped horizontally.
flipY
If true, the object is flipped vertically.
fontFamily
For text objects, the font family.
fontSize
For text objects, the font size.
frameTime
The time (in milliseconds) for each frame in sprite animation.
height
The height of the canvas object.
id
A unique identifier for the canvas object.
left
The x-coordinate position of the canvas object.
mediaName
For image objects, the name of the media resource.
objectType
The type of canvas object (e.g., 'Circle', 'Rect', 'Triangle', etc.).
Default Value: "Rect"
objects
For grouped objects, holds an array of child objects.
opacity
The opacity level of the canvas object.
path
The path data for path-based objects.
points
Array of points defining a polygon or polyline.
radius
For circular objects, the radius.
rx
The horizontal corner radius for rounded rectangles.
ry
The vertical corner radius for rounded rectangles.
scaleX
The horizontal scaling factor for the object.
scaleY
The vertical scaling factor for the object.
selectable
Determines if the object is selectable.
spriteHeight
The height of the sprite frame.
spriteIndex
The current index of the sprite frame.
spriteName
For sprite objects, the name of the sprite sheet.
spriteWidth
The width of the sprite frame.
state
Contains state information for the canvas object.
stateHolder
An auxiliary property for state management.
stroke
The stroke color of the canvas object.
strokeLineJoin
The style of the line join for the stroke (e.g., miter, round, bevel).
strokeWidth
The width of the stroke (outline) of the canvas object.
text
For text objects, the text content.
Default Value: "Text"
textAlign
For text objects, the text alignment (e.g., left, center, right).
Default Value: "left"
top
The y-coordinate position of the canvas object.
width
The width of the canvas object.
Configuration options for the canvas. scripting type: CustomType<svycanvas-Canvas.canvasOptions>
ZoomOnMouseScroll
Enables zooming via mouse scroll when true.
Default Value: 0
animationSpeed
Sets the speed of canvas animations in milliseconds.
Default Value: 50
hasRotatingPoint
Indicates whether canvas objects display a rotation control handle.
Default Value: 1
renderOnAddRemove
Specifies if the canvas should automatically re-render when objects are added or removed.
Default Value: 0
selectable
Determines if canvas objects are selectable.
Default Value: 1
skipOffscreen
If true, objects outside the visible canvas area are not rendered.
Default Value: 1
skipTargetFind
If true, disables target finding for canvas objects to improve performance.
Default Value: 0
Flag to indicate whether the grid background should be displayed. Type: Default Value: 0
Flag to enable snapping canvas objects to the grid when moved or resized. Type: Default Value: 0
CSS class applied to the canvas container for custom styling. Type:
{} x The x-coordinate to center the zoom on.
{} y The y-coordinate to center the zoom on.
{} zoom The zoom level to apply to the canvas.
{} objs An array of canvas objects to be added.
{} [setActive] If true, the added object(s) will be selected as the active item.
{} id The ID of the element to bring to the front layer of the canvas.
{} saveCB A callback function that receives the selected canvas object.
{} data The JSON string containing the canvas structure and properties to be loaded.
{} resolutionWidth The optional DPI resolution width for higher quality prints.
{} id The ID of the canvas object to be removed.
{} angle The angle, in degrees, to rotate the canvas.
{} imgCB A callback function that receives the base64-encoded image data of the canvas.
{} saveCB A callback function that receives the serialized JSON object representing the canvas.
{} ids An array of object IDs to be selected on the canvas.
{} obj The canvas object to update with new properties or modifications.
{} selectActiveItems If true, the updated object will be selected as the active item.
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type:
Type: