[cairo] Scrolling/Copying

Tim Teulings rael at edge.ping.de
Thu Jun 23 15:01:53 PDT 2005


Hallo!

> Perhaps it's the concept of "user space coordinates" that's not
> understood here?

I now do :-) But it was unclear before. The description of the function
is even more irritating since it is speaking of patterns which do not
apear as part of the interface parameters neither the fucntion name. I
now do know, that patterns are a very general concept in Cairo, it can
be just a color (an invinite source are of single color ;-)), a classic
bitmap pattern but also part of a existing surface (with this knowledge
is is then clear, that while this function does not look like pattern
handling is still uses the pattern mechanism internally). In fact this
design makes perfectly sense and as you find out below it is just that
these concepts are not yet part of the manual.

> In that case, the result of the above operation can be depicted
> in crude ASCII art as:
> 
>    target surface (eg. "window")
> 0,0--------------------------------------------------------
>   |                                                        |
>   |            source surface                              |
>   | dX-sX,dY-sY--------------------------------------      |
>   |           |                                      |     |
>   |           |       rectangle                      |     |
>   |           |  dX,dY---------                      |     |
>   |           |      |/////////|                     |     |
>   |           |      |/////////|                     |     |
>   |           |      |/////////|                     |     |
>   |           |       ---------dX+width,dY+height    |     |
>   |           |                                      |     |
>   |            --------------------------------------      |
>   |                                                        |
>    --------------------------------------------------------

I'm still unsure:-/ sX,sY are the coordinates of the source retangle is
user/device space (that is what I assumed)? The picture suggests a
different interpretation, the coordinate of the source rectangle are
dX-sX,dY-dY instead of just sX,sY!?


That is what I want. Move the rectangle sX,sY,width,height to dX,dY.

0,0
x------>
|
|


   sX,sY         sX+width-1,sY
   x-------------x
   |+        dX,dY
   |         x---|---------
   |         |+  |         |
   x-------------          |
   sX,sY+height-1          |
              -------------



> All coordinates shown in the figure are in user-space which as we
> assumed above happens to be the same as the target device space.

OK, also in my example.

>>So for cairo_rectangle the top left x coordinate calculates to
>>dX+(-(dX-sX) with results into sX and the bottom right x coordinate
>>calculates to dX+width-1+(-(dX-sX)) which calculates to sX+width-1,
>>which is exactly what I want :-)

And that is still what IMHO is happening (and my code proves it).

> 
> Yes, that's the lookup that goes on for obtaining color information
> from the source surface.

And you agree. Sorry, it is just your coordinates of the source surface
are irritating me (see your picture above in comparrison to mine).
Nevertheless we should not talk this to death, the code is correct and
this is what counts ;-)

> color. Meanwhile, there is also a transformation from user space to
> device space (the CTM) that is applied to all user-space coordinates,
> (such as those passed to cairo_set_source_surface and cairo_rectangle
> above).

Yes I droped that since in my case user space is device space.

> I don't think we can capture all of those transformations in the
> documentation for cairo_set_source_surface. We'll need to just provide
> a pointer to an introductory chapter that explains the general imaging
> model, including the use of the source pattern matrix.

Agreed.

-- 
Gruß...
       Tim.



More information about the cairo mailing list