[cairo] SVG Spacewar

mental at rydia.net mental at rydia.net
Fri Apr 1 07:15:23 PST 2005


Quoting Nigel Tao <nigel.tao at myrealbox.com>:

> There is a cairo snippet that loads a static SVG file, but I was
> thinking... the red ship and the blue ship are pretty much
> identical, but for different colors.  Do you know if the SVG spec
> (or something else?) allows for "parameterized" SVG, so that I can
> say something like "load the ship.svg file with parameters
> (primary_color = #FF66CC, active_layers = [ship, shields,
> exhaust], frame = 2)"?

That would be the role of stylesheets and CSS classes.

 .primary-fill {
   fill: #ff66cc;
 }
 #ship, #shields, #exhaust {
   visibility: visible;
 }

Given something like:

 <g id="ship" visibility="hidden">
   <path d="whatever" class="primary-fill"/>
   ...etc...
 </g>
 <g id="shields" visibility="hidden">
   ...etc...
 </g>
 <g id="exhaust" visibility="hidden">
   ...etc..
 </g>

(not sure about the "frame" bit)

[ n.b. Stylesheets will take precedence over presentation
attributes, but not CSS properties specified with style="" ]

-mental



More information about the cairo mailing list