Package | com.nocircleno.graffiti |
Class | public class GraffitiCanvas |
Inheritance | GraffitiCanvas ![]() |
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 1.0, Flash Player 10 - AIR 1.5 |
1.2 Features:
It is up to the developer to implement a UI for these features.
Property | Defined By | ||
---|---|---|---|
activeTool : ITool | GraffitiCanvas | ||
canvasEnabled : Boolean | GraffitiCanvas | ||
canvasHeight : uint | GraffitiCanvas | ||
canvasWidth : uint | GraffitiCanvas | ||
historyLength : uint [read-only]
Get the current number of saved history items. | GraffitiCanvas | ||
historyPosition : uint [read-only]
Get the current history position. | GraffitiCanvas | ||
maxHistoryLength : uint [read-only]
Get the maximum number of history items. | GraffitiCanvas | ||
maxZoom : Number [read-only]
Maximum Zoom value. | GraffitiCanvas | ||
minZoom : Number [read-only]
Minimum Zoom value. | GraffitiCanvas | ||
mouseDrag : Boolean | GraffitiCanvas | ||
overlay : DisplayObject [write-only]
Display Object displayed above the drawing. | GraffitiCanvas | ||
underlay : DisplayObject [write-only]
Display Object displayed under the drawing. | GraffitiCanvas | ||
zoom : Number | GraffitiCanvas |
Method | Defined By | ||
---|---|---|---|
GraffitiCanvas(canvasWidth:uint = 100, canvasHeight:uint = 100, numberHistoryLevels:uint = 0, overlay:DisplayObject = null, underlay:DisplayObject = null)
The GraffitiCanvas constructor. | GraffitiCanvas | ||
clearCanvas():void
The clearCanvas method will clear the Canvas. | GraffitiCanvas | ||
clearHistory():void
The clearHistory method will clear all history items. | GraffitiCanvas | ||
drawing():BitmapData
The drawing method will return the bitmapdata object that captures
the drawn canvas including any overlay or underlay assets. | GraffitiCanvas | ||
drawToCanvas(asset:Object):void
The drawToCanvas method will draw a display object or bitmapdata object to the canvas. | GraffitiCanvas | ||
fill(point:Point, color:uint):void
The fill method will flood fill an area of the drawing with the supplied color. | GraffitiCanvas | ||
getColorAtPoint(point:Point, useEntireCanvas:Boolean = false):int
The getColorAtPoint method will return the color at a specific point on the drawing. | GraffitiCanvas | ||
getViewableRect():Rectangle
The getViewableRect method will return a Rectangle defining the viewable area of the Canvas. | GraffitiCanvas | ||
nextHistory():void
The nextHistory method will step forward and display the next item in
the history. | GraffitiCanvas | ||
prevHistory():void
The prevHistory method will step backwards and display the next item in
the history. | GraffitiCanvas | ||
setCanvasPos(pos:Point):void
The setCanvasPos method will change the position of the canvas. | GraffitiCanvas |
Constant | Defined By | ||
---|---|---|---|
HISTORY_LENGTH_CHANGE : String = historyLengthChange [static] | GraffitiCanvas |
activeTool | property |
activeTool:ITool
[read-write] public function get activeTool():ITool
public function set activeTool(value:ITool):void
canvasEnabled | property |
canvasEnabled:Boolean
[read-write] public function get canvasEnabled():Boolean
public function set canvasEnabled(value:Boolean):void
canvasHeight | property |
canvasHeight:uint
[read-write] public function get canvasHeight():uint
public function set canvasHeight(value:uint):void
canvasWidth | property |
canvasWidth:uint
[read-write] public function get canvasWidth():uint
public function set canvasWidth(value:uint):void
historyLength | property |
historyLength:uint
[read-only] Get the current number of saved history items.
public function get historyLength():uint
historyPosition | property |
historyPosition:uint
[read-only] Get the current history position.
public function get historyPosition():uint
maxHistoryLength | property |
maxHistoryLength:uint
[read-only] Get the maximum number of history items.
public function get maxHistoryLength():uint
maxZoom | property |
maxZoom:Number
[read-only] Maximum Zoom value.
public function get maxZoom():Number
minZoom | property |
minZoom:Number
[read-only] Minimum Zoom value.
public function get minZoom():Number
mouseDrag | property |
mouseDrag:Boolean
[read-write] public function get mouseDrag():Boolean
public function set mouseDrag(value:Boolean):void
overlay | property |
overlay:DisplayObject
[write-only] Display Object displayed above the drawing.
public function set overlay(value:DisplayObject):void
underlay | property |
underlay:DisplayObject
[write-only] Display Object displayed under the drawing.
public function set underlay(value:DisplayObject):void
zoom | property |
zoom:Number
[read-write] public function get zoom():Number
public function set zoom(value:Number):void
GraffitiCanvas | () | Constructor |
public function GraffitiCanvas(canvasWidth:uint = 100, canvasHeight:uint = 100, numberHistoryLevels:uint = 0, overlay:DisplayObject = null, underlay:DisplayObject = null)
The GraffitiCanvas
constructor.
canvasWidth:uint (default = 100 ) — Width of the canvas.
| |
canvasHeight:uint (default = 100 ) — Height of the canvas.
| |
numberHistoryLevels:uint (default = 0 ) — Max number of History items to keep, if 0 then no history is kept.
| |
overlay:DisplayObject (default = null ) — An optional DisplayObject that can be used as an overlay to the Canvas. DisplayObject should be partially transparent.
| |
underlay:DisplayObject (default = null ) — An optional DisplayObject that can be used as an underlay to the Canvas.
|
package { import flash.display.Sprite; import com.nocircleno.graffiti.GraffitiCanvas; import com.nocircleno.graffiti.tools.BrushTool; import com.nocircleno.graffiti.tools.BrushType; public class Main extends Sprite { public function Main() { // create new instance of graffiti canvas, with a width and height of 400 and 10 history levels. // by default a Brush instance is created inside the GraffitiCanvas Class and assigned as the active tool. var canvas:GraffitiCanvas = new GraffitiCanvas(400, 400, 10); addChild(canvas); // create a new BrushTool instance, brush size of 8, brush color is Red, fully opaque, no blur and Brush type is Backward line. var angledBrush:BrushTool = new BrushTool(8, 0xFF0000, 1, 0, BrushType.BACKWARD_LINE); // assign the Brush as the active tool used by the Canvas canvas.activeTool = angledBrush; } } }
clearCanvas | () | method |
public function clearCanvas():void
The clearCanvas
method will clear the Canvas.
clearHistory | () | method |
public function clearHistory():void
The clearHistory
method will clear all history items.
the Canvas.
See also
drawing | () | method |
public function drawing():BitmapData
The drawing
method will return the bitmapdata object that captures
the drawn canvas including any overlay or underlay assets.
BitmapData — A BitmapData object containing the entire canvas.
|
drawToCanvas | () | method |
public function drawToCanvas(asset:Object):void
The drawToCanvas
method will draw a display object or bitmapdata object to the canvas.
This allows you to add an image that will be editable by the drawing engine.
Parameters
asset:Object — Image to write to canvas. Object must IBitmapDrawable. This includes MovieClips, Sprites, Bitmaps, BitmapData.
|
fill | () | method |
public function fill(point:Point, color:uint):void
The fill
method will flood fill an area of the drawing with the supplied color.
The fill DOES NOT take into account an overlay or underlayed image.
Parameters
point:Point — Point at which to flood fill with color.
| |
color:uint — Color to fill with.
|
getColorAtPoint | () | method |
public function getColorAtPoint(point:Point, useEntireCanvas:Boolean = false):int
The getColorAtPoint
method will return the color at a specific point on the drawing.
If the point is out of bounds then -1 is returned.
Parameters
point:Point — Point to get color from.
| |
useEntireCanvas:Boolean (default = false ) — A Boolean value that specifies whether to include any overlay or underlay display objects when reading the color at the point specified.
|
int — Returns the color value at the point passed, returns -1 if point is outside of canvas dimensions.
|
getViewableRect | () | method |
public function getViewableRect():Rectangle
The getViewableRect
method will return a Rectangle defining the viewable area of the Canvas.
Rectangle — A Rectangle object that represents the viewable are of the Canvas.
If the canvas is zoomed all they way out then the dimensions of the Rectangle
are same as the Canvas width and height.
|
nextHistory | () | method |
public function nextHistory():void
The nextHistory
method will step forward and display the next item in
the history.
See also
prevHistory | () | method |
public function prevHistory():void
The prevHistory
method will step backwards and display the next item in
the history.
See also
setCanvasPos | () | method |
public function setCanvasPos(pos:Point):void
The setCanvasPos
method will change the position of the canvas.
Parameters
pos:Point — Point to move canvas to.
|
HISTORY_LENGTH_CHANGE | Constant |
public static const HISTORY_LENGTH_CHANGE:String = historyLengthChange