[Cairo] py-cairo example & Context save/restore quesiton

Jesse David Andrews jdandr2 at uky.edu
Fri Nov 14 10:46:38 PST 2003


Maybe it is two iterations that cause the

 |
  \
   |

I am away from a graphical terminal for the day :( so I cannot test.

Very interesting that saving/restoring also can wipe out the path.  I find
it a little bizaire...  Any reasons behind it (I guess I am used to coding
in postscript where this is NOT the behavor of save/restore and cannot
think of where saving/restoring the path would be more useful...)

Regardless, in terms of what I am trying to do:

will:

  forward
  save
  forward
  stroke
  restore
  forward
  stroke

work?

I am used to stroke "destroying" the path, but if "restore" reloads the
path, does that mean I can always stroke before a restore? and achieve the
desired results?

Thanks,
Jesse

On Fri, 14 Nov 2003, Carl Worth wrote:

> On Nov 14, Jesse Andrews wrote:
>  > The order that the path is being drawn (in logo psuedo code):
>  >
>  > new path
>  >
>  >   forward
>  >   save state
>  >   rotate
>  >   forward
>  >   restore state
>  >   forward
>  >
>  > stroke
>
> Ah, I see the miscommunication. The path is part of the state that is
> saved/restored. So, assuming that forward only modifies the path, (and
> doesn't draw anything), then the above sequence is equivalent to:
>
> new path
>
>   forward
>   forward
>
> stroke
>
> Which is not what you were wanting, (but does jibe with the fact that
> I only ever see a straight line with the plant example).
>
> I've attached another python program demonstrating your sequence above.
>
>  > It seems like the restore does NOT reload the position, but does reload
>  > the rotation.
>
> The current point *is* restored along with the rest of the path.
>
> -Carl
>
>
>





More information about the cairo mailing list