Packagecom.gskinner.effects
Classpublic class Kaleidoscope
InheritanceKaleidoscope Inheritance flash.display.Sprite

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.



Public Properties
 PropertyDefined by
  autoUpdate : Boolean
If true, the kaleidoscope will update every frame.
Kaleidoscope
  maskSlices : Boolean
If true, each slice of the kaleidoscope will be masked.
Kaleidoscope
  offsetRotation : Number = 0
Rotation offset to use when drawing the image source into the kaleidoscope.
Kaleidoscope
  offsetX : Number = 0
X offset to use when drawing the image source into the kaleidoscope.
Kaleidoscope
  offsetY : Number = 0
Y offset to use when drawing the image source into the kaleidoscope.
Kaleidoscope
  onChange : Function
Callback that is called eforethe kaleidoscope updates.
Kaleidoscope
  onChanged : Function
Callback that is called after the kaleidoscope updates.
Kaleidoscope
  radius : Number
Sets the radius for the kaleidoscope.
Kaleidoscope
  reflect : Boolean
Indicates whether alternating slices should be flipped to reflect each other.
Kaleidoscope
  slices : uint
Sets the number of slices in the kaleidoscope.
Kaleidoscope
  source : IBitmapDrawable
The image source.
Kaleidoscope
Protected Properties
 PropertyDefined by
  _autoUpdate : Boolean
Kaleidoscope
  bmpd : BitmapData
Kaleidoscope
  bmpList : Vector
Kaleidoscope
  _maskSlices : Boolean = true
Kaleidoscope
  mtx : Matrix
Kaleidoscope
  pt : Point
Kaleidoscope
  _radius : Number
Kaleidoscope
  _reflect : Boolean
Kaleidoscope
  sliceList : Vector
Kaleidoscope
  sliceMask : BitmapData
Kaleidoscope
  _slices : uint
Kaleidoscope
Public Methods
 MethodDefined by
  
Kaleidoscope(source:IBitmapDrawable = null, radius:uint = 200, slices:uint = 8, reflect:Boolean = true)
Creates a new kaleidoscope instance.
Kaleidoscope
  
update():void
Draws the latest source image to the kaleidoscope and calls the onChange and onChanged callbacks.
Kaleidoscope
Protected Methods
 MethodDefined by
  
drawSlice(g:Graphics, sx:Number, sy:Number, radius:Number, arc:Number, startAngle:Number = 0):void
Kaleidoscope
  
init():void
Kaleidoscope
  
tick(evt:Event):void
Kaleidoscope
  
updateMask():void
Kaleidoscope
Property detail
_autoUpdateproperty
protected var _autoUpdate:Boolean
autoUpdateproperty 
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
bmpdproperty 
protected var bmpd:BitmapData
bmpListproperty 
protected var bmpList:Vector
_maskSlicesproperty 
protected var _maskSlices:Boolean = true
maskSlicesproperty 
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
mtxproperty 
protected var mtx:Matrix
offsetRotationproperty 
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.

offsetXproperty 
public var offsetX:Number = 0

X offset to use when drawing the image source into the kaleidoscope.

offsetYproperty 
public var offsetY:Number = 0

Y offset to use when drawing the image source into the kaleidoscope.

onChangeproperty 
public var onChange:Function

Callback that is called eforethe kaleidoscope updates. Useful for making updates to the source immediately before the kaleidoscope updates.

onChangedproperty 
public var onChanged:Function

Callback that is called after the kaleidoscope updates. Useful for reacting to changes.

ptproperty 
protected var pt:Point
_radiusproperty 
protected var _radius:Number
radiusproperty 
radius:Number  [read-write]

Sets the radius for the kaleidoscope.

Implementation
    public function get radius():Number
    public function set radius(value:Number):void
_reflectproperty 
protected var _reflect:Boolean
reflectproperty 
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
sliceListproperty 
protected var sliceList:Vector
sliceMaskproperty 
protected var sliceMask:BitmapData
_slicesproperty 
protected var _slices:uint
slicesproperty 
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
sourceproperty 
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.

Constructor detail
Kaleidoscope()constructor
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)
Method detail
drawSlice()method
protected function drawSlice(g:Graphics, sx:Number, sy:Number, radius:Number, arc:Number, startAngle:Number = 0):voidParameters
g:Graphics
 
sx:Number
 
sy:Number
 
radius:Number
 
arc:Number
 
startAngle:Number (default = 0)
init()method 
protected function init():void
tick()method 
protected function tick(evt:Event):voidParameters
evt:Event
update()method 
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.

updateMask()method 
protected function updateMask():void