Skip to content

Commit d29b02e

Browse files
committed
Tweaking paint to ensure that open lines are not closed due to calling Graphics.endFill in the Paint.endPaint method when there's no fill specified. All open lines should use a paint that doesn't specify a fill
1 parent 84a6d33 commit d29b02e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/examples/ParabolaFromLineAndVertex.as

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package examples
22
{
3+
import ui.Paint;
4+
35
import as3geometry.geom2D.Line;
46
import as3geometry.geom2D.Parabola;
57
import as3geometry.geom2D.line.MutableLine;
@@ -15,6 +17,7 @@ package examples
1517
public class ParabolaFromLineAndVertex extends ExampleBaseSprite
1618
{
1719
private var vertexPaint:SolidPaint;
20+
private var linePaint:Paint;
1821

1922
private var dragMechanism:DragMechanism;
2023

@@ -31,6 +34,7 @@ package examples
3134
public function ParabolaFromLineAndVertex()
3235
{
3336
vertexPaint = new SolidPaint(0xFFFF0000, 0xFF000000, 2);
37+
linePaint = new SolidPaint(0, 0xFF000000, 2);
3438

3539
dragMechanism = new DragMechanism();
3640

@@ -53,7 +57,7 @@ package examples
5357
lineDrawer = new LineDrawer(_context, line);
5458

5559
parabola = new MutableParabola(_context, c, line);
56-
parabolaDrawer = new ParabolaDrawer(_context, parabola);
60+
parabolaDrawer = new ParabolaDrawer(_context, parabola, linePaint);
5761

5862
addChild(lineDrawer);
5963
addChild(parabolaDrawer);

src/ui/paint/SolidPaint.as

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ package ui.paint
1414
public class SolidPaint implements Paint
1515
{
1616

17+
private static const ALPHA_SCALAR:Number = 1 / 0xFF;
18+
1719
private var _fill:uint;
1820

1921
private var _stroke:uint;
@@ -44,17 +46,19 @@ package ui.paint
4446

4547
public function beginPaint(graphics:Graphics):void
4648
{
47-
graphics.beginFill(_fill & 0xFFFFFF, (_fill >>> 24) / 0xFF);
49+
if (_fill)
50+
graphics.beginFill(_fill & 0xFFFFFF, (_fill >>> 24) * ALPHA_SCALAR);
4851

4952
if (_width >= 0)
50-
graphics.lineStyle(_width, _stroke & 0xFFFFFF, (_stroke >>> 24) / 0xFF);
53+
graphics.lineStyle(_width, _stroke & 0xFFFFFF, (_stroke >>> 24) * ALPHA_SCALAR);
5154
else
5255
graphics.lineStyle();
5356
}
5457

5558
public function endPaint(graphics:Graphics):void
5659
{
57-
graphics.endFill();
60+
if (_fill)
61+
graphics.endFill();
5862
}
5963
}
6064
}

0 commit comments

Comments
 (0)