[cairo] Observations from a newb
dirk.schoenberger at sz-online.de
Fri Nov 9 00:23:32 PST 2007
>> M is moveto, C is curveto, L is lineto, Z is closepath, f is fill, s is
>> stroke, r is set_source_rgb etc
>> a metadata file would look something like
>> 10 10 M 100 0 L 100 100 L 0 0 L 1 0 0 r f
>> Maybe I will give this idea a try.
> I can't help but think that SVG already provides this data. It *is* the
> metafile already. You are aiming at what I was trying. A way to "play" an
> file out via cairo to a source.
Yes and no. You can use the SVG data to do the path creation data.
Extracting data about how to render the paths is much more difficult, here
come things like CSS (cascading style sheets into play)
There exist also SVG elements for e.g. groups, transformations etc.
Handling all these is rather complex, that's why there exist so free
solution for all of this yet.
My metafile format would allow to use all cairo API as direct operators,
without having to fight with CSS matching rules, internal and external
references, URL resolving and such stuff. If I want to use a cairo
pattern, I will define a p operator.
> I don't grok the difference between doing that and using librsvg (mainly
> because I can't get librsvg to compile on my system.) It *sounds* like
> librsvg is creating a "bitmap" of the svg file (like an export from
> to a png) and this is a step too far for the idea.
Exactly. The problem is that librsvg is an external library with no
dependency on cairo, so it cannot use cairo as an output device. I _think_
there was sometimes a project to do exactly that, but I believe this
project never got off the ground.
> SVG -> Parser -> SomeCairoObject (that contains commands to move_to,
> (Oh and, does Cairo already do : Cairo commands -> SVG file with paths and
> some embedded bitmap ?)
That's where the "service level API" or "meta surface" comes into play.
Some surfaces (SVG, PS, PDF I think) can work with low level events like
"moveto(10,10)" and output these events as valid SVG (i.e. a "10 10 M"
string). As a side effect these surfaces can be used as a vector pattern
(in order to be able to write these events, they have to be able to record
and replay these events)
More information about the cairo