[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There are two parts of blending to consider. The first is the simplest, and involves alpha values in your color.
pen.SetColor(1,1,1,1); |
This statement would set the color to a completely opaque white.
pen.SetColor(1,1,1,0.5); |
Whereas this one would set the color to a shade that is 50% transparent. It is easy to see how this works, in that the transparency is a number from 0 to 1, where 0 is completely transparent, and 1 is completely opaque.
There is a more sophisticated sort of blending that Pen can also perform. This is referred to more generally as compositing.
SetMixMode(mixmode_constant)
Set the blending mode used for further drawing to one of the Pen.MIX_XXX constants.
SetMixMode(mixmode_object)
Set the blending mode used for further drawing by generating it from a Mixmode object that allows you to specify any of the source and destination blending operations CS supports.
The constants that can be used for blending are as follows:
MIX_ADD
The source color and destination colors are added together.
MIX_ALPHA
The source and destination colors are blended using the alpha value.
MIX_COPY
The destination color is overwritten by the source color. (No blending).
MIX_DST_ALPHA_ADD
The source color is multiplied by the alpha component of the destination color and the result is added together.
MIX_FLAT
No shading is implemented for vertex colors.
MIX_MULTIPLY
To do
MIX_MULTIPLY2
To do
MIX_PRE_MULT_ALPHA
To do
MIX_SRC_ALPHA_ADD
To do
MIX_TRANSPARENT
To do
MIX_TRANSPARENT_TEST
To do
MIX_DST_ALPHA
Like MIX_DST_ALPHA_ADD, but the results are blended not added.
MIX_DST_ALPHA_MASK
To do
In order to do masking, for example, you might set the pen state like this:
pen.SetMixMode(Pen.MIX_COPY); pen.SetColor(1,1,1,1); pen.DrawTriangle(5,0,10,10,0,10); pen.SetMixMode(Pen.MIX_DST_ALPHA_ADD); pen.SetFlag(Pen.FLAG_TEXTURE); pen.SetTexture(my_tex); pen.DrawRect(0,0,20,20); |
The texture will only be drawn where the triangle was drawn. The area around the triangle will be left clean.
Blending allows you to do a number of interesting special effects, including highlighting and complex texturing. For an example of the use of blending see `data/aws/widgets/slider.js'
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated using texi2html 1.76.