#64 Problem/weakness with Flare's coloring system

open
nobody
None
5
2009-06-05
2009-06-05
toker5
No

I've encountered a small, but annoying, problem when it comes to line and fill colors for nodes and edges:

If you set the fill color for a node to white, the node will be rendered transparent (i.e. without a fill), and the reason for this seems to be the way colors are defined/specified in flare, using an 32-bit number with an alpha component at the highest 8. The Graphics APIs beginFill() method, however, doesn't seem to support this (even though it accepts a 32-bits uint as its fill color), and high enough numbers are treated as transparent.

To reproduce, try out the following in a Sprite whose background is darker than white:

graphics.clear();
graphics.lineStyle(1);

graphics.beginFill(0xffffffff);
graphics.drawRect(10, 10, 100, 100);
graphics.endFill();

graphics.beginFill(0xffffff);
graphics.drawRect(120, 10, 100, 100);
graphics.endFill();

This will draw two rectangles - the first one using a color definition with an alpha component. The first rectangle will be transparent and the second will be white.

To bypass this problem/limitation, one can use a bit mask while setting the fill:
var color:Number = 0xffffffff;
graphics.beginFill(0xffffff & color);

But this is clearly a bit cumbersome.

Proposed solutions:
Add a method to the Colors utility (e.g. rgb(color:Number):Number) or change the color properties for Nodes and Edges to NOT use an alpha channel (this would work since there is a fillAlpha and a lineAlpha property present already).

Discussion