Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.aberustudios.afrosuit.visual
- {
- import flash.display.BitmapData;
- import flash.display.GradientType;
- import flash.display.Graphics;
- import flash.display.Sprite;
- import flash.geom.Matrix;
- import net.flashpunk.FP;
- public class Gradient extends BitmapData
- {
- public function Gradient(width:int, height:int, colorA:uint = 0xFFFFFF, colorB:uint = 0x000000, angle:Number = 90)
- {
- super(width, height, true, 0x00000000);
- m.createGradientBox(width, height, angle * (-FP.RAD));
- g.beginGradientFill(GradientType.LINEAR, [colorA, colorB], [1, 1], [0, 255], m);
- g.drawRect(0, 0, width, height);
- draw(s);
- }
- public function updateGradient(colorA:uint = 0xFFFFFF, colorB:uint = 0x000000):void
- {
- g.clear();
- g.beginGradientFill(GradientType.LINEAR, [colorA, colorB], [1, 1], [0, 255], m);
- g.drawRect(0, 0, width, height);
- draw(s);
- }
- private var s:Sprite = new Sprite;
- private var g:Graphics = s.graphics;
- private var m:Matrix = new Matrix;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement