4D v14SVG_Define_linear_gradient |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14
SVG_Define_linear_gradient
SVG_Define_linear_gradient
The SVG_Define_linear_gradient command sets a new linear gradient in the SVG container designated by parentSVGObject and returns its reference. If parentSVGObject is not an SVG document, an error is generated. A gradient consists in a continuous progressive color transition from one color to another along a vector. Once specified, gradients are called on a given graphic element, while indicating whether this element must be filled or edged with the gradient called. The id parameter specifies the name of the gradient. If an element with the same name exists, it will be replaced. This is the name that will be used to call the gradient each time a that a color expression is expected by using the syntax "url(#ID)". The startColor and endColor parameters specify the colors used to begin and end the gradient. The optional rotation parameter sets the position and direction of the gradient vector (see example). The optional spreadMethod parameter defines the filling to be used when the gradient begins or ends within the bounds of the parentSVGObject. You can pass one of the following strings in this parameter:
If this parameter is omitted, the "pad" value effect is used. The optional x1, y1, x2 and y2 parameters define the gradient vector. This vector provides the starting and ending points used by the rendering engine. You can pass percentages expressed as ratios (0...1) in these parameters. Starting with V14, you can pass the optional startColorOffset and endColorOffset parameters to define the percentage value, respectively, of the start color and end color offset. You can pass either a real value < 1, or a value between 0 and 100 to set the percentage, i.e. "0.1" and/or "10" are both interpreted as 10%. Passing a negative value is interpreted as 0% for the startColorOffset parameter and as 100% for the endColorOffset parameter. If you pass a value > 100, it is interpreted as 100%. Draw 6 solid squares where each uses a linear gradient paint server while varying the rotation and direction of the gradient vector: $svg:=SVG_New Example using the startColorOffset and endColorOffset parameters (added in v14): $Dom_node:=SVG_Define_linear_gradient($Dom_svg;"clicked";"black:50";"black:20";-90;"reflect";0;80) will give the definition: <linearGradient id="clicked spreadMethod="reflect x1="0" x2="0" y1="1" y2="0"> <stop offset="0%" stop-color="black" stop-opacity="0.5"/> <stop offset="80%" stop-color="black" stop-opacity="0.2"/> </linearGradient> This example illustrates the effect of the startColorOffset and endColorOffset parameters: $svg:=SVG_New |
PROPERTIES
Product: 4D
HISTORY
SEE ALSO
SVG Colors ARTICLE USAGE
4D SVG Component ( 4D v14) Inherited from : SVG_Define_linear_gradient ( 4D v13) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||