drawVBL: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 17: Line 17:
The shapes can be one of {{code|"Rectangle"}}, {{code|"Circle"}}, {{code|"Polygon"}} or {{code|"Cross"}}.
The shapes can be one of {{code|"Rectangle"}}, {{code|"Circle"}}, {{code|"Polygon"}} or {{code|"Cross"}}.


For {{code|"shape":"Rectangle"}}:
For {{code|"shape":"Rectangle"}} and {{code|"shape":"Cross"}}:
{{param|"x"|Abscissa in pixels. (aka: X-Coordinate)}}
{{param|"x"|Abscissa in pixels. (aka: X-Coordinate)}}
{{param|"y"|Ordinate in pixels. (aks: Y-Coordinate)}}
{{param|"y"|Ordinate in pixels. (aks: Y-Coordinate)}}
Line 29: Line 29:
{{param|"thickness"|Line thickness from {{code|2}} to {{code|n}} pixels. Lower than {{code|2}} or empty defaults to {{code|2}}. Even numbers only (odd numbers get rounded down by one). Can't be bigger than width or height. '''Optional.'''}}
{{param|"thickness"|Line thickness from {{code|2}} to {{code|n}} pixels. Lower than {{code|2}} or empty defaults to {{code|2}}. Even numbers only (odd numbers get rounded down by one). Can't be bigger than width or height. '''Optional.'''}}
{{param|"scale"|If provided number not {{code|0}}, will scale rectangle by {{code|x}}, ie scale: {{code|2}} is double, scale: {{code|0.5}} is half. '''Optional.'''}}<br />
{{param|"scale"|If provided number not {{code|0}}, will scale rectangle by {{code|x}}, ie scale: {{code|2}} is double, scale: {{code|0.5}} is half. '''Optional.'''}}<br />
: Example:<source lang="mtmacro">
: Example:<source lang="mtmacro">
{"shape":"rectangle","x":1743,"y":2198,"w":100,"h":100,"r":45,"fill":1,"thickness":1,"scale":0}
[h:rectangle = "{'shape':'rectangle','x':50,'y':50,'w':100,'h':200,'r':45,'fill':1,'thickness':1,'scale':0}"]
</source>
:<source lang="mtmacro">
[h:cross = "{'shape':'cross','x':-50,'y':-50,'w':50,'h':100,'r':30,'fill':1,'thickness':1,'scale':2}"]
</source><br />
</source><br />


For {{code|"shape":"Circle"}}:
For {{code|"shape":"Circle"}}:
{{param|"x"|Abscissa in pixels.}}
{{param|"x"|see {{code|"shape":"rectangle"}}.}}
{{param|"y"|Ordinate in pixels.}}
{{param|"y"|see {{code|"shape":"rectangle"}}.}}
{{param|"radius"|In pixels.
{{param|"radius"|In pixels.
{{param|"fill"|If {{code|1}} fills circle, otherwise creates empty shape. '''Optional.'''}}
{{param|"sides"|Specifies how many sides the polygon will have to approximate a circle, from {{code|3}} to {{code|100}}. '''Optional.'''}}
{{param|"thickness"|Line thickness from {{code|2}} to {{code|n}} pixels. Lower than {{code|2}} or empty defaults to {{code|2}}. Even numbers only (odd numbers get rounded down by one). '''Optional.'''}}
{{param|"r"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"sides"|Specifies how many sides the polygon will have to approximate a circle, from {{code|3}} to {{code|100}}.}}<br />
{{param|"facing"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"rx"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"ry"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"fill"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"thickness"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"scale"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}<br />
: Example:<source lang="mtmacro">
: Example:<source lang="mtmacro">
{"shape":"circle", "X":50, "Y":100, "radius":200, "sides":12, "thickness":3, "fill":0}</source><br />
[h:circle = "{'shape':'circle', 'X':50, 'Y':100, 'radius':200, 'thickness':3, 'fill':0, 'sides':12,'r':45}"]</source>
: Note that this shape can be used to easily create regular polygons, e.g. a triangle:<source lang="mtmacro">
{"shape":"circle", "X":50, "Y":100, "radius":200, "sides":3, "thickness":3, "fill":0, "r":30}</source>
: and a quare:<source lang="mtmacro">
{"shape":"circle", "X":50, "Y":100, "radius":200, "thickness":3, "fill":0, "sides":4,"r":45}</source><br />


For {{code|"shape":"Polygon"}}:
For {{code|"shape":"Polygon"}}:
{{param|"r"|Rotation on centre axis in degrees, clockwise.}}
{{param|"points"|[[JSON Array]] of 2 or more {{code|"x"}}, {{code|"y"}} coordinates.}}<br />
{{param|"thickness"|Line thickness from {{code|2}} to {{code|n}} pixels. Lower than {{code|2}} or empty defaults to {{code|2}}. Even numbers only (odd numbers get rounded down by one). '''Optional.'''}}
{{param|"close"| If {{code|1}} then it will close the polygon otherwise it will leave it open. '''Optional.'''}}
{{param|"close"| If {{code|1}} then it will close the polygon otherwise it will leave it open. '''Optional.'''}}
{{param|"fill"|If {{code|1}} and {{code|"close"}} is set too fills polygon, otherwise creates empty shape. '''Optional.'''}}
{{param|"r"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"points"|[[JSON Array]] of 2 or more {{code|"x"}}, {{code|"y"}} coordinates.}}<br />
{{param|"facing"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"rx"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"ry"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"fill"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"thickness"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}
{{param|"scale"|see {{code|"shape":"rectangle"}}. '''Optional.'''}}<br />
: Example:<source lang="mtmacro">
: Example:<source lang="mtmacro">
{"shape":"polygon","r":0,"fill":1,"close":1,"thickness":10,"points":[{"x":1993,"y":1998},{"x":2043,"y":1998},{"x":1993,"y":2148}]}</source><br />
[h:polygon = "{'shape':'polygon','r':0,'close':1,'thickness':10,'points':[{'x':0,'y':0},{'x':200,'y':200},{'x':150,'y':10}"]</source><br />
 
for
For {{code|"shape":"Cross"}}:
{{param|"x"|Abscissa in pixels.}}
{{param|"y"|Ordinate in pixels.}}
{{param|"w"|Width in pixels.}}
{{param|"h"|Height in pixels.}}
{{param|"r"|Rotation on centre axis in degrees, clockwise.}}
{{param|"thickness"|Line thickness from {{code|2}} to {{code|n}} pixels. Lower than {{code|2}} or empty defaults to {{code|2}}. Even numbers only (odd numbers get rounded down by one). Can't be bigger than width or height. '''Optional.'''}}
{{param|"scale"|If provided number not {{code|0}}, will scale cross by {{code|x}}, ie scale: {{code|2}} is double, scale: {{code|0.5}} is half. '''Optional.'''}}}}<br />
: Example:<source lang="mtmacro">{"shape":"cross","x":1593,"y":2198,"w":50,"h":50,"r":22,"thickness":5,"scale":0.75}</source><br />


|example=
|example=
This example doesn't really do anything.
This example build an array of the object from the above examples (I cannot paste them here as the multitude of curly brackets lets the wiki page go haywire) and then feeds that array into the drawVBL function
<source lang="mtmacro" line>
[h: exampleVariable = "a,b,c"]
[r: exampleFunction(exampleVariable, reverse)]
</source>
Returns:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
c,b,a
[h:objectArrary = json.append('',rectangle, cross, circle, polygon)]
[h:drawVBL(objectArrary)]
</source>
</source>



Revision as of 10:51, 10 April 2013

 This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.
 This article needs: Lacks examples.

{{MacroFunction |name=drawVBL |proposed=false |trusted=true |version=1.3b89 |description= This function draws VBL shapes.

|usage=

drawVBL(shapesList)

Parameters

The shapes can be one of "Rectangle", "Circle", "Polygon" or "Cross".

For "shape":"Rectangle" and "shape":"Cross":

  • "x" - Abscissa in pixels. (aka: X-Coordinate)
  • "y" - Ordinate in pixels. (aks: Y-Coordinate)
  • "w" - Width in pixels.
  • "h" - Height in pixels.
  • "r" - Rotation on centre axis in degrees, clockwise. Using default mathematical system: '0' is no rotation, + is clockwise, - is counterclockwise. Optional.
  • "facing" - Rotation on centre axis in degrees, clockwise. Using the MT facing system: '0' will rotate the shape 90 degrees anticlockwise, + is counterclockwise, - is clockwise. When using both 'r' and 'facing', then 'facing' takes precedence. Optional.
  • "rx" - Rotation centre offset in pixels. Optional.
  • "ry" - Rotation centre offset in pixels. When used the centre over which the shape is rotated is positioned at the rx,ry coordinate. The centre defaults to the actual centre of the shape. Optional.
  • "fill" - If 1 fills rectangle, otherwise creates empty shape. Optional.
  • "thickness" - Line thickness from 2 to n pixels. Lower than 2 or empty defaults to 2. Even numbers only (odd numbers get rounded down by one). Can't be bigger than width or height. Optional.
  • "scale" - If provided number not 0, will scale rectangle by x, ie scale: 2 is double, scale: 0.5 is half. Optional.
Example:
[h:rectangle	= "{'shape':'rectangle','x':50,'y':50,'w':100,'h':200,'r':45,'fill':1,'thickness':1,'scale':0}"]
[h:cross	= "{'shape':'cross','x':-50,'y':-50,'w':50,'h':100,'r':30,'fill':1,'thickness':1,'scale':2}"]

For "shape":"Circle":

  • "x" - see "shape":"rectangle".
  • "y" - see "shape":"rectangle".
  • "radius" - In pixels.
  • "sides" - Specifies how many sides the polygon will have to approximate a circle, from 3 to 100. Optional.
  • "r" - see "shape":"rectangle". Optional.
  • "facing" - see "shape":"rectangle". Optional.
  • "rx" - see "shape":"rectangle". Optional.
  • "ry" - see "shape":"rectangle". Optional.
  • "fill" - see "shape":"rectangle". Optional.
  • "thickness" - see "shape":"rectangle". Optional.
  • "scale" - see "shape":"rectangle". Optional.
Example:
[h:circle		= "{'shape':'circle', 'X':50, 'Y':100, 'radius':200, 'thickness':3, 'fill':0, 'sides':12,'r':45}"]
Note that this shape can be used to easily create regular polygons, e.g. a triangle:
{"shape":"circle", "X":50, "Y":100, "radius":200, "sides":3, "thickness":3, "fill":0, "r":30}
and a quare:
{"shape":"circle", "X":50, "Y":100, "radius":200, "thickness":3, "fill":0, "sides":4,"r":45}

For "shape":"Polygon":

  • "points" - JSON Array of 2 or more "x", "y" coordinates.
  • "close" - If 1 then it will close the polygon otherwise it will leave it open. Optional.
  • "r" - see "shape":"rectangle". Optional.
  • "facing" - see "shape":"rectangle". Optional.
  • "rx" - see "shape":"rectangle". Optional.
  • "ry" - see "shape":"rectangle". Optional.
  • "fill" - see "shape":"rectangle". Optional.
  • "thickness" - see "shape":"rectangle". Optional.
  • "scale" - see "shape":"rectangle". Optional.
Example:
[h:polygon		= "{'shape':'polygon','r':0,'close':1,'thickness':10,'points':[{'x':0,'y':0},{'x':200,'y':200},{'x':150,'y':10}"]

for