Gradients

Other topics

Remarks:

SVG is case sensitive so remember to use a capital G in the middle.

linearGradient

<svg>
  <defs>
        <linearGradient id='g' y1="100%" x2="100%">
            <stop offset='0%' stop-color='yellow' />
            <stop offset='100%' stop-color='green' />
        </linearGradient>
    </defs>
    <rect width='100%' height='100%' fill='url(#g)'/>
</svg>

radialGradient

<svg>
  <defs>
    <radialGradient id="g">
      <stop offset="10%" stop-color="green" />
      <stop offset="90%" stop-color="white" />
    </radialGradient>
  </defs>

  <rect width='100%' height='100%' fill='url(#g)'/>
</svg>

Parameters:

commondefinition
gradientUnitsthe coordinate system of the gradient attributes. Either objectBoundingBox or userSpaceOnUse
gradientTransformthe transform to apply to the gradient contents
spreadMethoddefines what happens outside the gradient boundaries. Either pad, reflect or repeat
xlink:hreflink to another gradient which provides attributes or content
------------
Linear GradientDefinition
------------
x1defines the gradient vector
x2see x1
y1see x1
y2see x1
------------
Radial GradientDefinition
------------
cxthe x coordinate of the outer gradient centre
cythe y coordinate of the outer gradient centre
rthe outer radius of the gradient. The location of a 100% stop
fxthe x coordinate of the inner gradient centre. The location of a 0% stop
fythe y location of the inner gradient centre. The location of a 0% stop

Contributors

Topic Id: 3346

Example Ids: 11505,11506

This site is not affiliated with any of the contributors.