Packagecom.rubenswieringa.drawing
Classpublic class DrawingTool

Provides basic functionality for drawing with the Drawing API.

See also

edit 1 Before modifying and/or redistributing this class, please contact Ruben Swieringa (ruben.swieringa


Public Methods
 MethodDefined by
  
clearLineStyle(graphics:Graphics):void
[static] Sets the lineStyle of a Graphics instance to none.
DrawingTool
  
draw(graphics:Graphics, area:Array, connect:Boolean = true, lineStyle:LineStyle = null):void
[static] Draws lines between the Point instances in the area Array onto graphics with the drawing API.
DrawingTool
  
drawLine(graphics:Graphics, point1:Point, point2:Point, lineStyle:LineStyle = null, moveTo:Boolean = true):void
[static] Draws a line from one Point to another.
DrawingTool
  
drawMarker(graphics:Graphics, point:*, size:Number = 10, shape:String, lineStyle:LineStyle = null):void
[static] Draws a cross shaped marker on the specified coordinate(s).
DrawingTool
  
drawRect(graphics:Graphics, rect:Rectangle, lineStyle:LineStyle = null):void
[static] Draws lines between the four corners of a Rectangle.
DrawingTool
Public Constants
 ConstantDefined by
  CIRCLE : String = "circle"
[static]
DrawingTool
  CROSS : String = "cross"
[static]
DrawingTool
Method detail
clearLineStyle()method
public static function clearLineStyle(graphics:Graphics):void

Sets the lineStyle of a Graphics instance to none.

Parameters
graphics:Graphics — Graphics instance of which to clear the lineStyle.
draw()method 
public static function draw(graphics:Graphics, area:Array, connect:Boolean = true, lineStyle:LineStyle = null):void

Draws lines between the Point instances in the area Array onto graphics with the drawing API. This method its main functionality is that it executes the lineTo() method, so (for example) when aiming to draw a filled shape, beginFill() must be called first. For drawing lines, either the lineStyle() method of the Graphics class must be executed, or a LineStyle instance must be used as a parameter value for this method (DrawingTool.draw()). Also see the example below.

Parameters
graphics:Graphics — Graphics instance on which the lines should be drawn
 
area:Array — Array with coordinates (Point instances)
 
connect:Boolean (default = true) — Boolean indicating whether or not to connect the last Point in area with the last Point in area. Defaults to true.
 
lineStyle:LineStyle (default = null) — LineStyle instance carrying the styles for the lines of the shape to be drawn.

See also


Example
Drawing a filled shape:
      var shape:Array = [new Point(0,0), new Point(100,0), new Point(0,100)];
      myGraphics.beginFill(0xFF0000);
      DrawingTool.draw(myGraphics, shape);
      myGraphics.endFill();
      

Drawing a shape with outline:
      var shape:Array = [new Point(0,0), new Point(100,0), new Point(0,100)];
      myGraphics.lineStyle(1, 0x00FF00);
      DrawingTool.draw(myGraphics, shape);
      

Drawing a shape with dashed outline using the LineStyle class:
      var shape:Array = [new Point(0,0), new Point(100,0), new Point(0,100)];
      var lineStyle:LineStyle = new LineStyle(1, 0x00FF00);
      lineStyle.dash = 4;
      DrawingTool.draw(myGraphics, shape);
      

drawLine()method 
public static function drawLine(graphics:Graphics, point1:Point, point2:Point, lineStyle:LineStyle = null, moveTo:Boolean = true):void

Draws a line from one Point to another. This method its main functionality is that it executes the lineTo() method, so (for example) when aiming to draw a filled shape, beginFill() must be called first. For drawing lines, either the lineStyle() method of the Graphics class must be executed, or a LineStyle instance must be used as a parameter value for this method.

Parameters
graphics:Graphics — Graphics instance on which to draw the line.
 
point1:Point — First Point.
 
point2:Point — second Point.
 
lineStyle:LineStyle (default = null) — LineStyle instance storing the properties of the line to be drawn.
 
moveTo:Boolean (default = true) — Whether or not to execute the Graphics class its moveTo() method before running the rest of the method.

See also

drawMarker()method 
public static function drawMarker(graphics:Graphics, point:*, size:Number = 10, shape:String, lineStyle:LineStyle = null):void

Draws a cross shaped marker on the specified coordinate(s). This method its main functionality is that it executes the lineTo() method, so (for example) when aiming to draw a filled shape, beginFill() must be called first. For drawing lines, either the lineStyle() method of the Graphics class must be executed, or a LineStyle instance must be used as a parameter value for this method.

Parameters
graphics:Graphics — Graphics instance on which to draw the shape.
 
point:* — Array or Point specifying one or more Point instances. If the point parameter value is neither a Point nor an Array then the function will silently fail.
 
size:Number (default = 10) — Size of the marker.
 
shape:String — Shape of the marker, either DrawingTool.CROSS or DrawingTool.CIRCLE. Defaults to DrawingTool.CROSS.
 
lineStyle:LineStyle (default = null) — LineStyle instance carrying the styles for the lines of the marker to be drawn.

See also

drawRect()method 
public static function drawRect(graphics:Graphics, rect:Rectangle, lineStyle:LineStyle = null):void

Draws lines between the four corners of a Rectangle. Note that this method is not the same as the method with the same name in the Graphics class, which takes the parameters of the Rectangle constructor as parameters, instead of a Rectangle instance, as does this method. This method its main functionality is that it executes the lineTo() method, so (for example) when aiming to draw a filled shape, beginFill() must be called first. For drawing lines, either the lineStyle() method of the Graphics class must be executed, or a LineStyle instance must be used as a parameter value for this method. Also see the example included in the documentation for the draw() method.

Parameters
graphics:Graphics — Graphics instance on which the lines should be drawn
 
rect:Rectangle — Rectangle
 
lineStyle:LineStyle (default = null) — LineStyle instance carrying the styles for the lines of the Rectangle to be drawn.

See also

Constant detail
CIRCLEconstant
public static const CIRCLE:String = "circle"
CROSSconstant 
public static const CROSS:String = "cross"