This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19
SVG_Use
|
SVG_Use ( parentSVGObjec ; id {; x ; y ; width ; height {; mode}} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
parentSVGObjec | SVG_Ref |
![]() |
Reference of parent element | |||||
id | String |
![]() |
Name of symbol | |||||
x | Longint |
![]() |
X position of viewbox | |||||
y | Longint |
![]() |
Y position of viewbox | |||||
width | Longint |
![]() |
Width of viewbox | |||||
height | Longint |
![]() |
Height of viewbox | |||||
mode | String |
![]() |
Adjustment to viewbox | |||||
Function result | SVG_Ref |
![]() |
SVG object reference | |||||
The SVG_Use command places an occurrence of the symbol in the SVG container designated by parentSVGObject and returns its reference. If parentSVGObject is not an SVG document or if id is not the object name of an SVG document, an error is generated.
A symbol is used to specify graphic objects; it is never rendered directly but may be instantiated using the SVG_Use command.
The id parameter specifies the name of the symbol.
The optional x, y, width and height parameters specify the viewbox rectangle ('viewBox' attribute).
The optional mode parameter can be used to indicate if the graphic must be fitted, and how so, to the size of the viewbox. (see the SVG_New command).
Specify a graphic composed of two red circles and two blue squares. Then use this graphic in a loop to create 36 occurrences with varying positions, opacity and rotation of the original graphic.
$SVG:=SVG_New
`Draw a background
SVG_New_rect($SVG;20;20;650;650;0;0;"gray";"lemonchiffon")
`Specify a symbol composed of 2 squares and 2 circles
$Symbol:=SVG_Define_symbol($SVG;"MySymbol";0;0;110;110;"true")
SVG_New_circle($Symbol;30;30;25;"red";"palevioletred")
SVG_New_rect($Symbol;10;60;40;40;0;0;"blue";"cornflowerblue")
SVG_New_rect($Symbol;60;10;40;40;0;0;"blue";"cornflowerblue")
SVG_New_circle($Symbol;80;80;25;"red";"palevioletred")
`In a group…
$g:=SVG_New_group($SVG)
`…positioned 20 units from the top left corner of the document…
SVG_SET_TRANSFORM_TRANSLATE($g;20;20)
`…place 36 patterns by varying the position, opacity and rotation
For($x;0;540;90) `6 columns
For($y;0;540;90) `6 rows
$use:=SVG_Use($g;"MySymbol";$x;$y;110;110)
SVG_SET_OPACITY($use;100-($y/12)+($x/12)
SVG_SET_TRANSFORM_ROTATE($use;($x*(18/50))+($y*(18/50));($x+55);($y+55))
End for
End for
Product: 4D
Theme: Drawing
Number:
65959
Created: Composant 4D SVG v11.3
4D SVG Component ( 4D v19)