[cairo] Scrolling/Copying
Carl Worth
cworth at cworth.org
Thu Jun 23 15:34:00 PDT 2005
On 24 Jun 2005 00:01:53 +0200, "Tim Teulings" wrote:
> 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.
Yeah, it would have been nice if my original answer to you could have
been just a pointer to an introductory chapter on patterns.
> > 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)?
No. Here, sX,sY is the coordinate of the rectangle within *pattern
space*, (ie. the coordinate system of the image being used as the
source surface). This is a distinct space from either user space or
device space.
> The picture suggests a
> different interpretation, the coordinate of the source rectangle are
> dX-sX,dY-dY instead of just sX,sY!?
The "source rectangle" ???
The coordinate of the "source surface" within device space is
dX-sX,dY-sY.
The coordinate of the "rectangle" within device space is dX,dY.
The coordinate of the "rectangle" within the source surface pattern
space is 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 |
> -------------
Ahah! I see the confusion. My drawing doesn't include the rectangle
you have at sX,sy, and your drawing doesn't have the rectangle mine
has at dX-sX,dY-sY, (which is the one you need to get the right values
for cairo_set_source_surface). You want to shift the origin by the
right amount so that the point sX,sY will move to dX,dY. Here's the
missing rectangle added to your picture:
> 0,0
> x------>
> | dX-sX,dY-sY
> | x------>
> |
> |
> sX,sY sX+width-1,sY
> x-------------x
> |+ dX,dY
> | x---|---------
> | |+ | |
> x------------- |
> sX,sY+height-1 |
> -------------
There, all four rectangles in one diagram. Hopefully that's quite
clear now.
I came up with my original diagram by thinking of the source surface
as being a separate surface from the target. It's perhaps a little
easier to think about things that way, but as you can see the math
still works even when the source and target are the same. (We'll
ignore for the moment the fact that the implementation has bugs in
actually getting the right result in this case.)
> 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 ;-)
No, it's good to talk things through to understanding on both parts. I
think we have a better diagram now that we can put in some
documentation at some point.
-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050623/6889de1f/attachment.pgp
More information about the cairo
mailing list