[cairo] How to draw paths with different registration points?
Arjen Nienhuis
a.g.nienhuis at gmail.com
Fri Jan 29 05:30:29 PST 2010
On Fri, Jan 29, 2010 at 11:55 AM, Stuart Axon <stuaxo2 at yahoo.com> wrote:
> Hi,
> In the Shoebot project were implementing the Nodebox api using Cairo.
> I wonder if anyone on the cairo list would know how we can implement something:
>
>
> Nodebox lets you set the registration point of paths drawn
> (when you draw a shape in NB it creates a path)
>
> This is set using the transform mode, which can change during the script:
>
>
>
> transform(mode=CORNER)
> In this case the current cursor position is the top-left of any path that will be drawn.
>
>
> transform(mode=CENTER)
> In this case the current cursor position is the middle of any path that will be drawn.
>
>
>
> Having some sort of sub-surface might make sense here, but it's too slow for us to use image surfaces for this
> (really we just want the bottom surface to be the image).
>
> Calculating the center of the path manually in python also seems like a bad plan for performance.
>
A group is a kind of sub-surface. You might be able to do something like:
cairo_push_group()
cairo_move_to()
cairo_line_to()
...
cairo_line_to()
cairo_path_extents()
cairo_stroke()
cairo_pop_group()
cairo_translate()
cairo_set_source(group)
cairo_paint()
>
> Any ideas ?
> (- is this something the new meta surfaces could help with ?)
>
> S++
>
>
>
>
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
More information about the cairo
mailing list