any chance you can give us a diagram or something of what you are trying to acheive? picture speaks 1000 words &allthat
On 12/22/05, Claudia Barnal <[EMAIL PROTECTED]> wrote: > Anyone? Please... > > > >From: "Claudia Barnal" <[EMAIL PROTECTED]> > >Reply-To: Flashcoders mailing list <[email protected]> > >To: [email protected] > >Subject: [Flashcoders] BitmapData and setPixel(); > >Date: Thu, 22 Dec 2005 04:03:57 +0000 > > > >Hi everyone, > > > >I'm having some math problems with a BitmapData and setPixel(). > > > >I'm using a for loop to calculate the different color values that should be > >assigned to a BitmapData, creating a gradient with a specific shape. > >Problem is that I can't get the right combination of color and shape of the > >gradient. > > > >In the sample code (which you can copy and paste and it will work straight > >away) I set two examples of the var p. > > > >The first option has the shape that I want. The issue is that the colors > >that are in the top and bottom center (very dark green and very light > >green) should be in the corners of their respective top and bottom. > > > >The second option has somewhat the color distribution that I want, but I > >doesn't have the shape that I need. Here the curvature starts in the > >corners, but should be as in the first option. > > > >I know it is a problematic question, but I would love to see your replies, > >as I have tried to solve this little problem for quite some time now. > > > >Claudia Barnal > > > >// CODE > > > >var stageW:Number = 255; > >var stageH:Number = 255; > >var hStageMiddle:Number = Math.round((stageW / 2) + 1); > >var bd:flash.display.BitmapData = new flash.display.BitmapData(stageW, > >stageH); > > > > > >for (var x:Number = 0; x < hStageMiddle; x++) > >{ > > /* > > * OPTION1 RIGHT SHAPE, WRONG COLOR DISTRIBUTION > > * CURVE STARTS FROM TOP AND BOTTOM CENTER > > */ > > var p:Number = Math.pow(1 - (x / hStageMiddle), 2); > > > > /* > > * OPTION2 WRONG SHAPE, RIGHT COLOR DISTRIBUTION > > * CURVE STARTS FROM THE CORNERS, WHICH IS WRONG > > */ > > //var p:Number = Math.pow(2, 1 - (x / hStageMiddle)); > > > > for (var y:Number = 0; y < stageH; y++) > > { > > var val1:Number = ((255 * y) / stageH); > > var val2:Number = ((val1 * (1 - p)) + (128 * p)); > > var col:Number = (((val2 << 8) | 0) | 0); > > bd.setPixel(x, y, col); > > bd.setPixel(stageW - x, y, col); > > } > >} > > > > > >createEmptyMovieClip("bmp", 1); > >bmp.attachBitmap(bd, 2); > > > >// CODE END > > > >_________________________________________________________________ > >The new MSN Search Toolbar now includes Desktop search! > >http://toolbar.msn.co.uk/ > > > >_______________________________________________ > >Flashcoders mailing list > >[email protected] > >http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > _________________________________________________________________ > Are you using the latest version of MSN Messenger? Download MSN Messenger > 7.5 today! http://messenger.msn.co.uk > > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

