[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Texturing is off by default. In order to texture a shape you have to turn it on, and also set a texture.
pen.SetFlag(Pen.FLAG_TEXTURE); pen.SetTexture(my_tex); |
To turn it back off, simply clear the flag.
pen.ClearFlag(Pen.FLAG_TEXTURE); |
It is very important to realize that the current color set will affect the texture. For example, if you set the current color to a bright white, the texture will be brighter than if you set it to black or a grey. Setting the color to red will cause the texture to have a reddish cast. Setting the alpha component will make the texture more or less translucent.
What about texture coordinates? All shapes are automatically textured. The one exception is the triangle shape. The Pen object currently does not have a good way to specify texture coordinates for it. This is likely to be corrected in the future.
For any given shape, the texture coordinates will be (0,0) at (xmin, ymin) and (1,1) at (xmax,ymax). It is important to realize that this works great for texturing an entire widget. However, if you which to texture sub-shapes within a widget, you must modify the transformation matrix so that texture coordinates will be properly generated.
Imagine that you have a widget that is 50 x 50 pixels. Assume that you have a small knob, that is 10 x 10 pixels, and you wish to texture it differently than the rest of the widget. Note that it may also move around inside the widget. The easiest way to do that is by:
pen.PushTransform(); pen.Translate(knob_x, knob_y, 0); pen.SetFlag(Pen.FLAG_TEXTURE); pen.SetTexture(my_tex); pen.DrawRect(0,0,10,10); pen.PopTransform(); |
This will normalize the coordinates of your shape and allow the pen to create correct texture coordinates for it.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated using texi2html 1.76.