Difference between revisions of "Qmaze2D How To/en/functions"
Line 6: | Line 6: | ||
How to use the functions, what they do and more.<br /> | How to use the functions, what they do and more.<br /> | ||
<br /><br /> | <br /><br /> | ||
− | If you wish to try out the functions in a safe and easy to use enviroment, visit: [https:// | + | If you wish to try out the functions in a safe and easy to use enviroment, visit: [https://diego.qmaze.nl/default.aspx?page=109] |
<br /> | <br /> | ||
<br/><br/> | <br/><br/> |
Revision as of 12:08, 8 December 2020
Contents
- 1 Explanation per individual function
- 1.1 Adding / Altering (existing) objects / images:
- 1.2 Altering existent objects / images
- 1.2.1 setcolor
- 1.2.2 setdraggable
- 1.2.3 setanimationduration
- 1.2.4 setanimationtype
- 1.2.5 sethandles
- 1.2.6 sethandlecolor
- 1.2.7 setheight
- 1.2.8 setwidth
- 1.2.9 setscale
- 1.2.10 setid
- 1.2.11 setlineheight
- 1.2.12 setrotation
- 1.2.13 setx
- 1.2.14 sety
- 1.2.15 setz
- 1.2.16 setstroke
- 1.2.17 setstrokecolor
- 1.2.18 settextfont
- 1.2.19 settextsize
- 1.2.20 settextweight
- 1.2.21 setvisible
- 1.2.22 setflipx
- 1.2.23 setflipy
- 1.2.24 setdefault
- 1.3 Retrieving object / image properties
- 1.4 Other functions
Explanation per individual function
Here you can find all the documentation for each individual functions.
How to use the functions, what they do and more.
If you wish to try out the functions in a safe and easy to use enviroment, visit: [1]
Adding / Altering (existing) objects / images:
These functions can be used to add objects / images to the canvas.
If objects already exist they will be altered.
Function name:
setcanvas
Function description:
Changes the default canvas to a fabric canvas.
Function structure:
x3d(object).setcanvas;
setcanvas('object');
Example:
x3d(c).setcanvas;
setcanvas('c');
The objects(id) must be the same as
Returns:
canvas
Function name:
settext
Function description:
Adds a text object to a canvas or changes the text of an already existent text object.
Function structure:
x3d(object).settext = value
settext('object','value');
Example:
x3d(welcometext).settext = Hello World!
settext('welcometext','Hello World!');
In case a text object already exists; When the id matches that of an already existent text object,
the text of this object is then replaced by the given value.
If you wish to split a sentence (enter), you can use \n.
An example of this: x3d('welcomeimg').settext = Hello \n World! or settext('welcomeimg','Hello \n World!');
Returns:
add: text value
alter: 'succes' or 'error'
Function name:
setimage
Function description:
Adds a image to a canvas or changes the source/url or data string of an already existent image.
Function structure:
x3d(object).setimage = source/url/data-string
setimage('object','source/url/data-string);
Example:
x3d('welcomeimg').setimage = /Images/pug.png
setimage('welcomeimg','/Images/pug.png');
In case a image already exists; When the id matches that of an already existent image,
the source/url or datastring of this image will be replaced by the given value.
Returns:
add: image (object)
alter: 'succes' or 'error'
Function name:
setbgimg
Function description:
Adds a background image to a canvas or changes the current background image, the image fills the entire canvas.
Function structure:
x3d(object).setbgimg = source/url/data-string
setbgimg('object','source/url/data-string);
Example:
x3d(bgimg).setbgimg = /Images/pineapples.png
setbgimg('bgimg','/Images/pineapples.png');
In case a background image already exists; When the id matches that of an already existing background image,
the source/url or data string of this background image will be replaced by the given value.
When you add a background image with another id whilst a background image is already active on that canvas,
the lastest added background image will be the one shown because of the layering structure. (see setz)
Returns:
bgimg (object)
Function name:
setrectangle
Function description:
Adds a rectangle to a canvas or changes an already existent rectangle. ( position, height and width )
Function structure:
x3d(object).setrectangle = x1,y1,x2,y2
setrectangle('object','x1,y1,x2,y2');
Example:
x3d(newrect).setrectangle = 50,50,100,100
setrectangle('newrect','50,50,100,100');
The rectangle in this example starts ( starting top left (0,0)) 50 pixels to the right and 50 pixels to the bottom.
In case a rectangle with this id is already existent, the locations ( and the width,height ) are changed.
Returns:
add: rectangle (object)
alter: rectangle (object) or 'error'
Function name:
setcircle
Function description:
Adds a circle to a canvas or changes an already existent circle. ( position and radius )
Function structure:
x3d(object).setcircle = x,y,radius
setcircle('object','x,y,radius');
Example:
x3d(newcircle).setcircle = 50,50,25
setcircle('newcircle','50,50,25');
The circle in this example starts ( starting top left (0,0)) 50 pixels to the right and 50 pixels to the bottom and gets a 25 pixel radius.
In case a circle with this id is already existent, the location and radius is changed.
Returns:
add: rectangle (object)
alter: rectangle (object) or 'error'
Function name:
settriangle
Function description:
Adds a triangle to a canvas or changes an already existent circle. ( position, height and width )
Function structure:
x3d(object).settriangle = x,y,width,height
settriangle('object','x,y,width,height');
Example:
x3d(newtriangle).settriangle = 50,50,75,75
settriangle('newtriangle','50,50,75,75');
The triangle in this example starts ( starting top left (0,0)) 50 pixels to the right and 50 pixels to the bottom and get a 75 pixels height and a 75 pixels width.
In case a triangle with this id is already existent, the location, height and width are changed.
Returns:
add: triangle(object)
alter: triangle(object) or 'error'
Function name:
setpolygon
Function description:
Adds a polygon to a canvas or changes an already existent polygon, the begin and endpoint always connect. ( positions)
Function structure:
x3d(object).setpolygon = x1,y1,x2,y2 etc.
setpolygon('object','x1,y1,x2,y2 etc.');
Example:
x3d(newpoly).setpolygon = 20,0,40,50,60,80,40,70,20,60
setpolygon('newpoly','20,0,40,50,60,80,40,70,20,60');
The polygon in this example starts ( starting top left (0,0)) 20 pixels to the right and 0 pixels to the bottom, the second point is 40 pixels to the right and 50 pixels to the bottom etc.
The end of the polygon always connects with the beginpoint.
In case a triangle with this id is already existent, the points get changed.
Returns:
add: polygon(object)
alter: polygon(object) or 'error'
Function name:
setarrows
Function description:
Adds a line to the canvas with 2 arrowpoints or replaces an already existing arrow/line.
Function structure:
x3d(object).setarrows = x1,y1,x2,y2
setarrows('object','x1,y1.x2.y2');
Example:
x3d(newarrow).setarrows = 100,100,300,300
setarrows('newarrow','100,100,300,300');
The arrow in this example starts ( starting top left (0,0)) 100 pixels to the right and 100 pixels to the bottom and stops 300 pixels to the right and 300 pixels to the bottom.
In case a arrow with this id is already existent (setline,setarrow,setarrows), the positions are replaced with the given value and if required arrowpoints are added/removed.
Returns:
'succes' or 'error'
Function name:
setarrow
Function description:
Adds a line to a canvas with 1 arrowpoint or replaces an already existing arrow/line.
Function structure:
x3d(object).setarrow = x1,y1,x2,y2
setarrow('object','x1,y1,x2,y2');
Example:
x3d(newarrow).setarrows = 100,100,300,300
setarrow('newarrow','100,100,300,300');
The arrow in this example starts ( starting top left (0,0)) 100 pixels to the right and 100 pixels to the bottom and stops 300 pixels to the right and 300 pixels to the bottom.
In case a arrow with this id is already existent (setline,setarrow,setarrows), the positions are replaced with the given value and if required arrowpoints are added/removed.
Returns:
'succes' or 'error'
Function name:
setline
Function description:
Adds a line to a canvas or replaces an already existing arrow/line.
Function structure:
x3d(object).setline = x1,y1,x2,y2
setline('object','x1,y1,x2,y2');
Example:
x3d(newarrow).setline = 100,100,300,300
setline('newarrow','100,100,300,300');
The arrow in this example starts ( starting top left (0,0)) 100 pixels to the right and 100 pixels to the bottom and stops 300 pixels to the right and 300 pixels to the bottom.
In case a arrow with this id is already existent (setline,setarrow,setarrows), the positions are replaced with the given value and if required arrowpoints are added/removed.
Returns:
'succes' or 'error'
Altering existent objects / images
These functions alter an already existent object' / image' property.
Function name:
setcolor
Function description:
Changes the color of an object.
Function structure:
x3d(object).setcolor = value
setcolor('object','value');
Example:
x3d(welcometext).setcolor = red
setcolor('welcometext','red');
When the object is a canvas the background color is changed to the given value.
The value can be a color in: string, hex and rgb.
Returns:
'succes' or 'error'
Function name:
setdraggable
Function description:
Changes the object to be static or dynamic ( user interaction )
Function structure:
x3d(object).setdraggable = value
setdraggable('object','value');
Example:
x3d(welcomeimg).setdraggable = 1
setdraggable('welcomeimg','1');
The value can either be 1 or 0, where 0 makes the object static and 1 makes the object draggable.
Objects that are NOT draggable will still have events, the user will not be able to move/scale/rotate the object/image.
Returns:
'succes' or 'error'
Function name:
setanimationduration
Function description:
Changes the duration of animations.
Function structure:
x3d().setanimationduration = duration
setanimationduration('duration');
Example:
x3d(object).setanimationduration = 1000
setanimationduration('1000');
In this example the animation duration is set to 1000ms (1 second).
The animation duration counts for all animations until it is altered again.
Returns:
'succes' or 'error'
Function name:
setanimationtype
Function description:
Changes which animation is played when positions change.
Function structure:
x3d().setanimationtype = value
setanimationtype('value');
Example:
x3d().setanimationtype = easeInOutBounce
setanimationtype('easeInOutBounce');
In this example the animation type is set to InOutBounce, this makes the object 'bounce' at the end of an position change.
The animation type counts for all animations until it is altered again.
Returns:
'succes' or 'error'
Function name:
sethandles
Function description:
Changes the handles of an object depended on the value.
Function structure:
x3d(object).sethandles = value
sethandles('object','value');
Example:
x3d(newrect).sethandles = 2
sethandles('newrect','2');
Changes which lines and or user interactive corners are visible.
Returns:
'succes' or 'error'
Function name:
sethandlecolor
Function description:
Changes the color of the handles.
Function structure:
x3d(object).sethandlecolor = value
sethandlecolor('object','value');
Example:
x3d(newrect).sethandlecolor = red
sethandlecolor('newrect','red');
This function changes the color of all handlers, visible or invisible.
The value can be a color in: string, hex and rgb.
Returns:
'succes' or 'error'
Function name:
setheight
Function description:
Changes the height of an object in pixels.
Function structure:
x3d(object).setheight = value
setheight('object',value);
Example:
x3d(welcomeimg).setheight = 150
setheight('welcomeimg',150);
Returns:
'succes' or 'error'
Function name:
setwidth
Function description:
Changes the width of an object in pixels.
Function structure:
x3d(object).setwidth = value
setwidth('object',value);
Example:
x3d(welcomeimg).setwidth = 250
setwidth('welcomeimg',250);
Returns:
'succes' or 'error'
Function name:
setscale
Function description:
Changes the width and height of an object or image by scale.
Function structure:
x3d(object).setscale = value
setscale('object',value);
Example:
x3d(welcomeimg).setscale = 0.8
setscale('welcomeimg',0.8)
The value represents the scale on which the object / image is scaled. ( x and y axle )
The value 1 is the original value.
Returns:
'succes' or 'error'
Function name:
setid
Function description:
Changes the id of an already existent object / image.
Function structure:
x3d(object).setid = value
setid('object','value');
Example:
x3d(welcomeimg).setid = goodbyeimg
setid('welcomeomg','goodbyeimg');
The object is the id of an object that is to be changed, the value is to become the new id.
The new id must not be existent on the canvas.
Returns:
'succes' or 'error'
Function name:
setlineheight
Function description:
Changes how much height is between text lines.
Function structure:
x3d(object).setlineheight = value
setlineheight('object',value);
Example:
x3d(welcometext).setlineheight = 10
setlineheight('welcometext',10);
Returns:
'succes' or 'error'
Function name:
setrotation
Function description:
Changes the rotation of an object / image.
Function structure:
x3d(object).setrotation = value
setrotation('object',value);
Example:
x3d(welcomeimg).setrotation = 90
setrotation('welcomeimg',90);
The value is the rotation starting from the original rotationpoint (0) in degrees. (celcius)
The object / image is always rotated from its most center point.
This function is animated if an animation is set.
Returns:
'succes' or 'error'
Function name:
setx
Function description:
Changes the position of an object / image on the x-axle. (in pixels where the left is 0)
Function structure:
x3d(object).setx = value
setx('object',value);
Example:
x3d(welcomeimg).setx = 500
setx('welcomeimg',500);
The image in this example will now be placed 500 pixels to the right.
This function can be animated dependend on the animationtype and duration.
Using the setx and sety function together will make the object / image move diagonally.
This function is animated if an animation is set.
Returns:
'succes' or 'error'
Function name:
sety
Function description:
Changes the position of an object / image on the y-axle. (in pixels where the top is 0)
Function structure:
x3d(object).sety = value
sety('object',value);
Example:
x3d(welcomeimg).sety = 200
sety('welcomeimg',200);
The image in this example will now be placed 200 pixels to the bottom.
This function can be animated dependend on the animationtype and duration.
Using the setx and sety function together will make the object / image move diagonally.
This function is animated if an animation is set.
Returns:
'succes' or 'error'
Function name:
setz
Function description:
Changes on which layer the object / image resides. ( where 0 is in the back )
Function structure:
x3d(object).setz = value
setz('object',value);
Example:
x3d(welcomeimg).setz = 10
setz('welcomeimg',10);
The value is the layer on which the object / image is placed, where the layer 0 is in the back.
The object / image that is already active on the chosen layer will be placed 1 place higher into the layers.
Returns:
'succes' or 'error'
Function name:
setstroke
Function description:
Changes the stroke of an object.
Function structure:
x3d(object).setstroke = value
setstroke('object',value);
Example:
x3d(newrect).setstroke = 20
setstroke('newrect',20);
The object gets a line around the object with the size of the value in pixels.
Returns:
'succes' or 'error'
Function name:
setstrokecolor
Function description:
Changes the color of the objects' stroke.
Function structure:
x3d(object).setstrokecolor = value
setstrokecolor('object','value');
Example:
x3d(newrect).setstrokecolor = blue
setstrokecolor('newrect','blue');
The value can be a color in: string, hex and rgb.
Returns:
'succes' or 'error'
Function name:
settextfont
Function description:
Changes the text font of an text object.
Function structure:
x3d(object).settextfont = value
settextfont('object','value');
Example:
x3d(welcometext).settextfont = Arial
settextfont('welcometext','Arial');
The text font must exist, if this is not the case the text font will remain the same. Attention: Case sensitive!
You can download text fonts directly from fonts.google.com or through a url link.
Returns:
'succes' or 'error'
Function name:
settextsize
Function description:
Changes the text size of a text object.
Function structure:
x3d(object).settextsize = value
settextsize('object',value);
Example:
x3d(welcometext).settextsize = 20
settextsize('welcometext',20);
The value is the text size in pixels.
Returns:
'succes' or 'error'
Function name:
settextweight
Function description:
Changes the boldness of an text object.
Function structure:
x3d(object).settextweight = value
settextweight('object',value);
Example:
x3d(welcometext).settextweight = 400
settextweight('welcometext',400);
Possible values: light, normal, bold, number.
Returns:
'succes' or 'error'
Function name:
setvisible
Function description:
Changes the visibility of an object / image / canvas.
Function structure:
x3d(object).setvisible = value
setvisible('object',value);
Example:
x3d(welcometext).setvisible = 0.7
setvisible('welcometext',0.7);
To make the canvas visible or invisible the value must be either 1 or 0 where 0 makes it invisible and 1 makes it visible.
To make an object / image visible or invisible the value must be between 0 and 1, where 1 is visible and 0 is invisible, decimals may be used.
This function is animated if an animation is set.
Returns:
'succes' or 'error'
Function name:
setflipx
Function description:
Flips the object / image around. (Horizontally)
Function structure:
x3d(object).setflipx = value
setflipx('object','value');
Example:
x3d(welcomeimg).setflipx = true
setflipx('welcomeimg','true');
The 'value' true flips the object / image around from it original stance, the value 'false' changes it back to it's original stance.
The value 'flip' makes the object / image flip around no matter which stance it currently is.
Returns:
'succes' or 'error'
Function name:
setflipy
Function description:
Flips the object / image around. (Vertically)
Function structure:
x3d(object).setflipy = value
setflipy('object','value');
Example:
x3d(welcomeimg).setflipy = flip
setflipy('welcomeimg','flip');
The 'value' true flips the object / image around from it original stance, the value 'false' changes it back to it's original stance.
The value 'flip' makes the object / image flip around no matter which stance it currently is.
Returns:
'succes' or 'error'
Function name:
setdefault
Function description:
Changes the default properties of which an object / image is loaded in with.
Function structure:
x3d(object).setdefault = property,propertyvalue
setdefault('object','propertympropertyvalue');
Example:
x3d(text).setdefault = fill,red
setdefault('text','fill,red');
Object defines the type of object, this could for example be; 'Text','Image','Rectangle','Arrow','Circle',Etc.
Neither the property, nor the propertyvalue is case sensitive.
Returns:
'succes' or 'error'
Retrieving object / image properties
These functions 'get' a property of the object / image, they return this property and could thus be used for testing or to fill variables for example.
Function name:
getproperty
Function description:
Gets the chosen property (value) of the object / image.
Function structure:
x3d(object).getproperty = value
getproperty('object','value');
Example:
x3d(welcomeimg).getproperty = top
getproperty('welcomeimg','top');
The value is the property you wish to retrieve.
Returns:
propertyvalue
Function name:
getx
Function description:
Gets the x-axle value from the object / image.
Function structure:
x3d(object).getx
getx('object');
Example:
x3d(welcomeimg).getx
getx('welcomeimg');
Note: This function returns the value of which the object resides in at that moment and time, if the object is in animation this might not be the end position.
Returns:
x (left) value
Function name:
gety
Function description:
Gets the y-axle value from the object / image.
Function structure:
x3d(object).gety
gety('object');
Example:
x3d(welcomeimg).gety
gety('welcomeimg');
Note: This function returns the value of which the object resides in at that moment and time, if the object is in animation this might not be the end position.
Returns:
y (top) value
Function name:
getz
Function description:
Gets the layer on which the object / images resides.
Function structure:
x3d(object).getz
getz('object');
Example:
x3d(welcomeimg).getz
getz('welcomeimg');
Returns:
z (layer) value
Function name:
getscale
Function description:
Gets the objects scale (X&Y combined)
Function structure:
x3d(object).getscale
getscale('object');
Example:
x3d(welcomeimg).getscale
getscale('welcomeimg');
Returns:
scale (x&y) value
Function name:
getscalex
Function description:
Gets the objects x-axle scale.
Function structure:
x3d(object).getscalex
getscalex('object');
Example:
x3d(welcomeimg).getscalex
getscalex('welcomeimg'):
Returns:
scalex value
Function name:
getscaley
Function description:
Gets the objects y-axle scale.
Function structure:
x3d(object).getscaley
getscaley('object');
Example:
x3d(welcomeimg).getscaley
getscaley('welcomeimg');
Returns:
scaley value
Other functions
These functions don't add/alter objects / images.
They are classified as 'other' functions for this reason.
Function name:
copy
Function description:
Copies the chosen object / image and gives it a new id.
Function structure:
x3d(object).copy = value
copy('object','value');
Example:
x3d(welcomeimg).copy = newimage
copy('welcomeimg','newimage');
The new id (value) must be unique. (can't already exist)
Note: When copying an object/image the new object/image will be placed ontop of the copied object/image.
Returns:
cloned object (object) or 'error'
Function name:
delete/deletethis
Function description:
Deletes the chosen object / image from the canvas.
Function structure:
x3d(object).delete
deletethis('object');
Example:
x3d(newimage).delete
deletethis('newimage');
If you wish to use this function in the outputscript you must use 'deletethis' otherwise an error will occur.
Using this function in the rules works with both 'delete' and 'deletethis'.
To use this function, you only need to enter an object(id).
Returns:
'succes' or 'error'
Function name:
clearcanvas
Function description:
Removes all objects and images from the canvas.
Function structure:
x3d(object).clearcanvas
clearcanvas('object');
Example:
x3d(c).clearcanvas
clearcanvas('c');
To use this function, you only need to enter an object(id).
The object(id) in this case is that of the canvas.
Returns:
'succes' or 'error'
Function name:
screenshot
Function description:
Makes a screenshot of the chosen canvas.
Function structure:
x3d(object).screenshot
screenshot('object');
Example:
x3d(c).screenshot
screenshot('c');
To use this function, you only need to enter an object(id).
The object(id) in this case is that of the canvas.
Returns:
'succes' or 'error'