Kaleidoscope ©2009 Grant Skinner, gskinner.com. Visit www.gskinner.com/blog/ for documentation, updates and more free code. Licensed under the MIT license - see the source file header for more information.
Draws a kaleidoscope effect based on a specified source image.
Fast Mode: Note that Kaleidoscope will use a faster drawing mode if the source is a BitmapData instance, and all offset values are set to 0.
protected var _autoUpdate:Boolean
autoUpdate:Boolean
[read-write]
If true, the kaleidoscope will update every frame. If false, you must call update() when you want it to update.
Implementation
public function get autoUpdate():Boolean
public function set autoUpdate(value:Boolean):void
protected var bmpd:BitmapData
protected var bmpList:Vector
protected var _maskSlices:Boolean = true
maskSlices:Boolean
[read-write]
If true, each slice of the kaleidoscope will be masked. If false, they will be able to overlap.
Implementation
public function get maskSlices():Boolean
public function set maskSlices(value:Boolean):void
protected var mtx:Matrix
public var offsetRotation:Number = 0
Rotation offset to use when drawing the image source into the kaleidoscope. For example, this can be used to create the effect of twisting the kaleidoscope.
public var offsetX:Number = 0
X offset to use when drawing the image source into the kaleidoscope.
public var offsetY:Number = 0
Y offset to use when drawing the image source into the kaleidoscope.
public var onChange:Function
Callback that is called eforethe kaleidoscope updates. Useful for making updates to the source immediately before the kaleidoscope updates.
public var onChanged:Function
Callback that is called after the kaleidoscope updates. Useful for reacting to changes.
protected var pt:Point
protected var _radius:Number
radius:Number
[read-write]
Sets the radius for the kaleidoscope.
Implementation
public function get radius():Number
public function set radius(value:Number):void
protected var _reflect:Boolean
reflect:Boolean
[read-write]
Indicates whether alternating slices should be flipped to reflect each other. If you set this to true with an odd number of slices, the number of slices will be increased by one to make it even.
Implementation
public function get reflect():Boolean
public function set reflect(value:Boolean):void
protected var sliceList:Vector
protected var sliceMask:BitmapData
protected var _slices:uint
slices:uint
[read-write]
Sets the number of slices in the kaleidoscope. Must be 1 or greater. If reflect is true, this must be an even number.
Implementation
public function get slices():uint
public function set slices(value:uint):void
public var source:IBitmapDrawable
The image source. For example, a DisplayObject or BitmapData instance. Note that Kaleidoscope will use a faster drawing mode if the source is a BitmapData instance, and all offset values are set to 0.
public function Kaleidoscope(source:IBitmapDrawable = null, radius:uint = 200, slices:uint = 8, reflect:Boolean = true)
Creates a new kaleidoscope instance.
Parameters
| source:IBitmapDrawable (default = null )
|
|
| radius:uint (default = 200 )
|
|
| slices:uint (default = 8 )
|
|
| reflect:Boolean (default = true )
|
protected function drawSlice(g:Graphics, sx:Number, sy:Number, radius:Number, arc:Number, startAngle:Number = 0):void
Parameters
| g:Graphics |
|
| sx:Number |
|
| sy:Number |
|
| radius:Number |
|
| arc:Number |
|
| startAngle:Number (default = 0 )
|
protected function init():void
protected function tick(evt:Event):void
Parameters
public function update():void
Draws the latest source image to the kaleidoscope and calls the onChange and onChanged callbacks. Called every frame automatically if autoUpdate is true.
protected function updateMask():void