Skip to main content

FlxGradient

Kindclass
Packageflixel.util
Full nameflixel.util.FlxGradient
Sourcesource/source-haxelib-patches/flixel/util/FlxGradient.hx

Adds a set of color gradient creation / rendering functions

@version 1.6 - May 9th 2011 @link http://www.photonstorm.com @author Richard Davey / Photon Storm @see Requires FlxMath

Public methods​

createGradientMatrix​

static function createGradientMatrix(width:Int, height:Int, colors:Array<FlxColor>, chunkSize:UInt = 1, rotation:Int = 90):GradientMatrix
ParameterTypeDefault
widthInt—
heightInt—
colorsArray<FlxColor>—
chunkSize (optional)UInt1
rotation (optional)Int90

View source

createGradientArray​

static function createGradientArray(width:Int, height:Int, colors:Array<FlxColor>, chunkSize:UInt = 1, rotation:Int = 90, interpolate:Bool = true):Array<FlxColor>
ParameterTypeDefault
widthInt—
heightInt—
colorsArray<FlxColor>—
chunkSize (optional)UInt1
rotation (optional)Int90
interpolate (optional)Booltrue

View source

createGradientFlxSprite​

static function createGradientFlxSprite(width:Int, height:Int, colors:Array<FlxColor>, chunkSize:UInt = 1, rotation:Int = 90, interpolate:Bool = true):FlxSprite

Creates a FlxSprite of the given width/height with a colour gradient flowing through it.

@param width The width of the FlxSprite (and therefore gradient) @param height The height of the FlxSprite (and therefore gradient) @param colors An array of colour values for the gradient to cycle through @param chunkSize If you want a more old-skool looking chunky gradient, increase this value! @param rotation Angle of the gradient in degrees. 90 = top to bottom, 180 = left to right. Any angle is valid @param interpolate Interpolate the colours? True uses RGB interpolation, false uses linear RGB @return A FlxSprite containing your gradient (if valid parameters given!)

ParameterTypeDefault
widthInt—
heightInt—
colorsArray<FlxColor>—
chunkSize (optional)UInt1
rotation (optional)Int90
interpolate (optional)Booltrue

View source

createGradientBitmapData​

static function createGradientBitmapData(width:UInt, height:UInt, colors:Array<FlxColor>, chunkSize:UInt = 1, rotation:Int = 90, interpolate:Bool = true):BitmapData
ParameterTypeDefault
widthUInt—
heightUInt—
colorsArray<FlxColor>—
chunkSize (optional)UInt1
rotation (optional)Int90
interpolate (optional)Booltrue

View source

overlayGradientOnFlxSprite​

static function overlayGradientOnFlxSprite(dest:FlxSprite, width:Int, height:Int, colors:Array<FlxColor>, destX:Int = 0, destY:Int = 0, chunkSize:UInt = 1, rotation:Int = 90, interpolate:Bool = true):FlxSprite

Creates a new gradient and overlays that on-top of the given FlxSprite at the destX/destY coordinates (default 0,0) Use low alpha values in the colours to have the gradient overlay and not destroy the image below

@param dest The FlxSprite to overlay the gradient onto @param width The width of the FlxSprite (and therefore gradient) @param height The height of the FlxSprite (and therefore gradient) @param colors An array of colour values for the gradient to cycle through @param destX The X offset the gradient is drawn at (default 0) @param destY The Y offset the gradient is drawn at (default 0) @param chunkSize If you want a more old-skool looking chunky gradient, increase this value! @param rotation Angle of the gradient in degrees. 90 = top to bottom, 180 = left to right. Any angle is valid @param interpolate Interpolate the colours? True uses RGB interpolation, false uses linear RGB @return The composited FlxSprite (for chaining, if you need)

ParameterTypeDefault
destFlxSprite—
widthInt—
heightInt—
colorsArray<FlxColor>—
destX (optional)Int0
destY (optional)Int0
chunkSize (optional)UInt1
rotation (optional)Int90
interpolate (optional)Booltrue

View source

overlayGradientOnBitmapData​

static function overlayGradientOnBitmapData(dest:BitmapData, width:Int, height:Int, colors:Array<FlxColor>, destX:Int = 0, destY:Int = 0, chunkSize:UInt = 1, rotation:Int = 90, interpolate:Bool = true):BitmapData

Creates a new gradient and overlays that on-top of the given BitmapData at the destX/destY coordinates (default 0,0) Use low alpha values in the colours to have the gradient overlay and not destroy the image below

@param dest The BitmapData to overlay the gradient onto @param width The width of the FlxSprite (and therefore gradient) @param height The height of the FlxSprite (and therefore gradient) @param colors An array of colour values for the gradient to cycle through @param destX The X offset the gradient is drawn at (default 0) @param destY The Y offset the gradient is drawn at (default 0) @param chunkSize If you want a more old-skool looking chunky gradient, increase this value! @param rotation Angle of the gradient in degrees. 90 = top to bottom, 180 = left to right. Any angle is valid @param interpolate Interpolate the colours? True uses RGB interpolation, false uses linear RGB @return The composited BitmapData

ParameterTypeDefault
destBitmapData—
widthInt—
heightInt—
colorsArray<FlxColor>—
destX (optional)Int0
destY (optional)Int0
chunkSize (optional)UInt1
rotation (optional)Int90
interpolate (optional)Booltrue

View source