|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectcommon:Generic
common:ColorMerge
class
This is a generic color blending class. It accepts two
colors and produces a merged result.
Constructor Summary | |
---|---|
ColorMerge()
|
|
ColorMerge(Generic pparent)
Constructor |
Method Summary | |
---|---|
color |
FullMerge(color pbottom,
color ptop,
float popacity)
Composing/blending helper function |
boolean |
IsOpaque(color ptop)
Opaque test function |
color |
Merge(color pbottom,
color ptop)
Color merging function |
static color |
Stack(color pbottom,
color ptop,
color pmerged,
float popacity)
Static composing/blending helper function |
Methods inherited from class common:Generic |
---|
GetParent |
Methods inherited from class Object |
---|
|
Constructor Detail |
---|
public ColorMerge(Generic pparent)
pparent
- a reference to the object creating the new object; typically, 'this'public ColorMerge()
Method Detail |
---|
public color Merge(color pbottom, color ptop)
pbottom
- color on the bottomptop
- color on the top
public boolean IsOpaque(color ptop)
In some cases, formulas want to know if, given a particular color, merging it onto another color will leave any of the other color visible (i.e. does all the color come from the top color). This function should return true in that case. The default implementation always returns false; if you write a merging class which can identify opaque colors, you should override this function. (Note this isn't as simple as just looking at the top color's opacity; in non-Normal merge modes the bottom color still influences the output.)
ptop
- top color to test
public static color Stack(color pbottom, color ptop, color pmerged, float popacity)
The explicit formula provided in the UF help for doing a color blend is:
compose(b, blend(t, mergeX(b, t), alpha(b)), o)
This at first seems overly complicated, but in fact is necessary to account for alpha in both the bottom and top colors. This function wraps up the compose and blend steps so you don't have to remember the correct formula. To use this, you will need to have the top color both before and after the merge function has been applied.
This is a static function, so you can call it without creating a ColorMerge object. Just call ColorMerge.Stack() directly.
pbottom
- color on the bottomptop
- color on the top (pre-merge)pmerged
- color on the top (post-merge)popacity
- opacity; 0 indicates all bottom, 1 indicates all toppublic color FullMerge(color pbottom, color ptop, float popacity)
Like Stack(), this is a helper function to make it easier to merge colors layer-style. However, Stack() still requires you to produce the merged color. FullMerge() will do the merging for you, but you have to use a ColorMerge object (not just call a static function).
pbottom
- color on the bottomptop
- color on the top (pre-merge)popacity
- opacity; 0 indicates all bottom, 1 indicates all top
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |