Canvas draw library: Difference between revisions

Jump to navigation Jump to search
No edit summary
Line 272: Line 272:
=== setSubdivisionLength() ===
=== setSubdivisionLength() ===
Set length of subdivision marker in %marker_length
Set length of subdivision marker in %marker_length
== transform module ==
The following methods are available to manipulate existing canvas elements.
{{note|This chapter is a draft, see {{code|FGDATA/Nasal/canvas/draw/transform.nas}} for details }}
{{note|All transform methods expect a canvas element as first parameter.}}
=== move() ===
params: elem, dx, dy
===rotate() ===
params: elem, deg, center
=== flipX() ===
params: elem, xaxis = 0
mirror element on x-axis
=== flipY() ===
params: elem, yaxis = 0
mirror element on y-axis
=== alignX() ===
Aligns the element, moving it horizontaly to ref.
params:
elem      element to be moved.
ref        reference may be an integer or another element.
alignment  as string: may be 'left-left', 'left-center', 'left-right', 'center-left', 'center-center', 'center-right', 'right-left', 'right-center', 'right-right'.
If ref is a single number, the 2nd word is ignored.
=== alignY() ===
Aligns the element, moving it vertically to ref.
params:
elem      element to be moved.
ref        reference may be an integer or another element.
alignment  as string: may be 'top-top', 'top-center', 'top-bottom', 'center-top', 'center-center', 'center-bottom', 'bottom-top', 'bottom-center', 'bottom-bottom'.
text elements also accept 'baseline' as reference.
If ref is a single number, the 2nd word is ignored.
 
 
=== rotate180() ===
params: elem, center = nil
center as [x,y] in pixels, otherwise: rotate in place
=== scaleX() ===
Stretch element horizontally
params:
elem        element to be stretched.
factor      the new-width/old-width ratio.
ref        the relative point to keep inplace. May be 'left', 'center' or 'right'.
=== scaleY() ===
strech element vertically
params:
elem        element to be stretched.
factor      the new-height/old-height ratio.
ref        the relative point to keep inplace. May be 'top', 'center' or 'bottom'.
=== resize() ===
params:
elem        element to be stretched.
factors    as vector [Xfactor, Yfactor]
ref        the relative point to keep inplace:
may be 'left-top', 'left-center', 'left-bottom', 'center-top', 'center-center', 'center-bottom', 'right-top', 'right-center', 'right-bottom'.


= References =
= References =
[[CompassRose]] is based on canvas draw.
[[CompassRose]] is based on canvas draw.
{{Note|You can test, improve and play around with canvas.draw by downloading the [[Addons|CanvasDrawDev add-on]]. }}
{{Note|You can test, improve and play around with canvas.draw by downloading the [[Addons|CanvasDrawDev add-on]]. }}
252

edits

Navigation menu