XML technologies / SVG / Filters, transformations and gradients / Gradient and pattern settings / Types of gradients / Linear gradients
(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)
Linear gradients are created with the <linearGradient> tag. It supports these attributes:
gradientUnitsspecifies whether an object or the drawing area is filled. Possible values areuserSpaceOnUseandobjectBoundingBox. This also determines the coordinate system for x1/y1 and x2/y2. WithobjectBoundingBoxthe coordinates refer to the group containing the element; withuserSpaceOnUsethey refer to the element itself.gradientTransformdefines transformations adjusting the gradient. All transformations supported by thetransformattribute of the<g>tag are allowed. For example, you can rotate the gradient.x1andy1set the gradient’s starting position. A virtual path is drawn between the positions defined byx1/y1andx2/y2, which the gradient follows. These positions determine the 0% and 100% marks of the<stop>tags. Suitable values set the gradient’s direction even without thegradientTransformattribute. Ifx1andy1are omitted, both default to 0%.The attributes
x2andy2set the virtual path’s endpoint. When omitted,x2defaults to 100% andy2to 0%.
Note:
The attributes x1, x2, y1 and y2 accept both absolute and percentage values according to SVG. However, absolute values prevent SVG Viewer 2.0 from displaying the filled object, although its documentation states no restrictions for the <linearGradient> tag. Therefore use percentages only. Absolute values are accepted when the attribute gradientUnits has the value userSpaceOnUse.
spreadMethodspecifies how to fill the rest of an object when the gradient does not cover it completely. A gradient path from 10%/10% to 90%/90%, for example, leaves parts unfilled. Possible values arepad,reflectandrepeat.padis the default when omitted. It fills areas before the 0% mark with the initial color and areas beyond the end mark with the final color. The valuereflectreverses the gradient to fill the rest. Withrepeatthe gradient repeats until the object is completely filled.xlink:hrefreferences an existing gradient to incorporate into this definition. To define several gradients sharing colors andstoppositions but differing attributes, first define a simple gradient and reference it in the others using thexlink:hrefattribute.
Copyright © verlag moderne industrie GmbH 2001
You may print the online version for your private use.
Otherwise, this chapter from “Das Einsteigerseminar SVG — Webgrafiken mit XML” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
verlag moderne industrie GmbH, Justus-von-Liebig-Straße 1, D-86899 Landsberg/Lech, fon ++49 (0) 81 91 / 125 – 0, leserservice(at)mi-verlag.de
back to top