2
* This file is part of the dis-Emi-A HaXe Library. Copyright (c) edA-qa mort-ora-y
3
* For full copyright and license information please refer to doc/license.txt.
9
import neash.display.Graphics;
11
import flash.display.Graphics;
17
Solid( color : Color, alpha : Float );
21
* Creates a logical pen which can be used for outlined drawn objects
23
class Pen implements draw.GraphicsImplement
28
private function new( width : Float, pt : PenType )
34
/*final*/ public function isNonEmpty() : Bool
39
/*virtual*/ public function apply( graphics : Graphics )
45
//NEASH: quirk, how to reset line-style
49
case Solid( color, alpha ):
50
graphics.lineStyle( width, color.asInt(), alpha );
54
/*ctor*/ static public function empty() : Pen
56
return new Pen( 0, PenType.None );
59
/*ctor*/ static public function solid( width : Float, color : Color, ?alpha : Null<Float> ) : Pen
64
return new Pen( width, PenType.Solid( color, alpha ) );
67
/*virtual*/ public function toString()
73
case Solid( color, alpha ):
74
return "Solid " + width + " " + color + " " + alpha;
81
/*ctor*/ static public function parsed( decl : String ) : Pen
83
define(`TYPE_CHECK',`PARSE_CHECK($1,"Pen",decl)')
84
var parts = decl.split( " " );
85
TYPE_CHECK( parts.length > 0 )
86
if( parts[0] == "None" )
88
if( parts[0] == "Solid" )
90
TYPE_CHECK( parts.length > 2 )
91
//the next three lines are to workaround a failure in haxe with Flash9 as the target
92
var alpha : Null<Float> = null;
93
if( parts.length > 3 )
94
alpha = TypeConvert.asFloat( parts[3] );
96
TypeConvert.asFloat( parts[1] ),
97
TypeConvert.asColor( parts[2] ),