PDA

View Full Version : Is the pattern image mutiplied by matrix PAINT to USER?



Leezhang
04-19-2007, 11:17 PM
When an image is used as a pattern, have I to do a Paint to User transform on that image? Or, just draw the path in User Space, and use the x,y of pixel P(5,5) to get the pattern image texel T(5,5), and transform to Surface at last?
Thanks for your help!

Ivo Moravec
04-23-2007, 03:09 PM
Conceptually, the path user to surface transform is a matrix for transforming the path data (for example moving it around the screen).

The Paint to user transforms on the other hand are for transforming the paint about on your path data (e.g. making use the texture is rotate 45 degrees).

So if:
Mu = Matrix: User to Surface Transform, and
Mp = Matrix: Paint Transform
P = Data coordinate [x y 1]^T
C = Texel coordinate [x y 1]^T

then the path data points (which give the shape) will be transformed with:
Screen coordinate = Mu * P

However, the colors that will appear on the screen are as if you drew the pixels under the this transformation:
Mp * Mu * C

Just play with it, you'll get the idea. Hope that helped.

Leezhang
04-24-2007, 03:25 AM
That really help me. Thanks a lot!
But I still have a question. If the pattern image is rotated, it may not be a rectangle anymore. So how to do pattern tiling with it?

Ivo Moravec
04-24-2007, 07:35 AM
That really help me. Thanks a lot!
But I still have a question. If the pattern image is rotated, it may not be a rectangle anymore. So how to do pattern tiling with it?

vgSetParameter(Your_paint, VG_PAINT_PATTERN_TILING_MODE, mode);

The allowed modes are:
VG_TILE_FILL - tile color is used outside of the image
VG_TILE_PAD - border of image is extended
VG_TILE_REPEAT - image is repeated
VG_TILE_REFLECT - image is repeatedly relfected

If you just want to rotate the path data, you should just leave the paint matrix constant. The paint matrix only moves the paint relative to the path. As such, it's your responsibilty to make sure it doesn't move in a way you don't want by setting the paint matrix correctly.

Leezhang
04-25-2007, 08:41 PM
Now I think I get this idea. Thank you very much! :D