In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

hues tints shades

Not too hard to write, and it just shows another use of the colour gradient function, getGradient() , that I wrote a little while back.

Although I doubt it will be, if it's too hard to read, as I didn't write a ton of comments, just contact me.
Get Adobe Flash player
by NME 12 May 2015
/*

just testing for now... not done yet, i'll be coming back once in a while today

Written by Anthony Pace, in Toronto Canada, ap13mo@student.ocadu.ca
All rights reserved.
*/

package {
    import flash.geom.Rectangle;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {init();}
        public function init():void{
           var sh:uint = stage.stageHeight,
               sw:uint = stage.stageWidth;
           var bmd:BitmapData = new BitmapData(sw,sh,false);
           var hues:Array=[0xff0000,0xffff00,0x00ff00,0x00ffff,0x0000ff,0xff00ff,0xff0000];
           var cvec:Vector.<uint> = new Vector.<uint>;
           var swDivByHLNeg1:uint = sw/(hues.length-1);
           cvec = cvec.concat(ColourStuff.getGradient(swDivByHLNeg1,hues[0],hues[1]));
           for (var i:uint=1;i!=hues.length-2;i++){
              cvec = cvec.concat(ColourStuff.getGradient(swDivByHLNeg1,hues[i],hues[i+1]));
           }
           cvec = cvec.concat(ColourStuff.getGradient(swDivByHLNeg1,hues[i],hues[i+1]));
           var w2h2b:Vector.<uint>;
           var rect:Rectangle = new Rectangle(0,0,1,sh+1);//needs at least one extra to write
           var hDiv2:uint = rect.height/2,
               hDiv2Plus1:uint = hDiv2+1,
               cvecLen:uint = cvec.length,
               tmpClr:uint;
           for(i=0;i!=cvecLen;i++){
               rect.x=i;
               tmpClr=cvec[i];
               w2h2b = ColourStuff.getGradient(hDiv2,0xffffff,tmpClr);
               w2h2b.fixed =false; //seems to be considering the passed back vector as fixed
               w2h2b.pop(); //thus, unless we set fixed to false, the pop() method wouldn't work 
               w2h2b = w2h2b.concat(ColourStuff.getGradient(hDiv2Plus1,tmpClr,0x000000));
               bmd.setVector(rect,w2h2b);
           }
           this.addChild(new Bitmap(bmd));
        }
    }
}
internal class  ColourStuff {
    //Hi, Anthony Pace a.k.a. NME here... ap13mo@student.ocadu.ca
    //this class is really just to simplify access to my gradient function for further use
     public static function getGradient(maxSteps:uint,startClr:uint,endClr:uint):Vector.<uint>{
            var r0:uint = startClr>>16,g0:uint = (startClr>>8)&0xff,b0:uint = startClr&0xff,
                r1:uint = endClr>>16,  g1:uint = (endClr>>8)&0xff,  b1:uint = endClr&0xff;
            var transitionVec:Vector.<uint>;        
            if(maxSteps <2){
                maxSteps = 2;
            }
            transitionVec = new Vector.<uint>(maxSteps,true);          
            var msn1:uint = maxSteps-1;
            var rFac:Number= (r1-r0)/msn1;
            var gFac:Number = (g1-g0)/msn1;
            var bFac:Number = (b1-b0)/msn1;
            transitionVec[0]=startClr;         
            for (var i:uint = 1;i!=msn1;i++){
                transitionVec[i]= uint( (uint(r0+i*rFac)<< 16 ) | ( uint(g0+i*gFac) << 8 ) | uint(b0+i*bFac) );
            }
            transitionVec[i] = endClr;
            return transitionVec;
     }
}