(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

There are (apparently) several types of gradients that can be interesting to support, but are not part of the SVG standard. This page is meant to document which gradient types Inkscape may want to support and how these could be simulated.

Common definitions

Any gradient can be defined by a mapping $\displaystyle{ f:\mathbb{R}^2\rightarrow[0,1] }$ from any point in the plane to a value in the range $\displaystyle{ [0,1] }$, combined with a mapping from the range $\displaystyle{ [0,1] }$ to colors. The former is defined by the type of gradient (and its parameters) and the latter by the gradient stops.

For each new gradient type it suffices to find a good method of generating $\displaystyle{ f }$ (over all four color channels). The desired colors can then be determined by using an feComponentTransfer filter with the table transfer function type. This allows the gradient to be approximated to any required accuracy.

Alternatively the mapping to colors of the gradient could be done using feDisplacementMap, if $\displaystyle{ f }$ is pre-processed properly. Specifically, the values of $\displaystyle{ f }$ are meant to be interpreted in an absolute sense, while feDisplacementMap uses them as an offset relative to the current position. So if $\displaystyle{ (x1,y1),(x2,y2) }$ defines the bounding box of the object to which the gradient is applied, and a (horizontal) linear gradient is applied to a rectangle using these same coordinates, then the scale parameter should be set in such a way that $\displaystyle{ x1+scale*0.5=x2 }$ and $\displaystyle{ x2-scale*0.5=x1 }$, so $\displaystyle{ scale=2(x2-x1) }$. The x displacement channel should then be set to a channel corresponding to $\displaystyle{ f }$ and the y displacement channel should then be set to some channel that is zero.

"A gradient which goes along the circular arc around a center." In other words (ignoring rotations and so on), given a center $\displaystyle{ (cx,cy) }$,