Re: Is forward referencing of gradients/patterns etc legal?

Yes, forward references in SVG are legal, but generally recommended as 
something to avoid if possible.

In general, when using a forward references such as referring to a gradient 
that is defined later, then there are two distinct cases: (1) when there a 
backup paint specified after the gradient (e.g., 
fill="url(#ForwardRefToGradient) black" specifies that black paint is the 
backup), or (2) when there is no backup paint specified.

There are also three distinct time periods to consider during progressive 
rendering of an SVG: (a) Before parsing/processing the forward reference, 
(b) After parsing/processing the forward reference, and (c) After resolving 
the forward reference.

For 1a, haven't reached the referencing element yet
For 1b, render the backup paint (i.e., black)
For 1c, render the gradient

For 2a, haven't reached the referencing element yet
For 2b, temporary error state - render only up to the forward reference
For 2c, render the gradient

As an exercise, folks can attempt to work through this logic by reading 
relevant parts of the specification:

Specifying paint talks about backup paint servers:
    http://www.w3.org/TR/SVG/painting.html#SpecifyingPaint
Invalid references are discussed toward the end of:
    http://www.w3.org/TR/SVG/struct.html#HeadOverview
Error processing is discussed at:
    http://www.w3.org/TR/SVG/implnote.html#ErrorProcessing

Jon Ferraiolo
SVG 1.0 Editor
jferraio@adobe.com

At 06:13 AM 8/16/01 +0200, Sigurd Lerstad wrote:
>Hello
>
>Is forward referencing of gradients/patterns etc legal?
>
>I mean that can en element A for example contain style fill:url(#grad)
>
>if the grad element B is declared later in the document than A
>
>thanks,
>
>--
>Sigurd Lerstad

Received on Thursday, 16 August 2001 04:46:08 UTC