Re: [Flashcoders] BitmapData and setPixel();

2005-12-23 Thread Claudia Barnal

Paul,

Thanks for looking into this.

I’m not sure you tried the code I provided, as there you can see graphically 
what I mean. All you would need to do is copy and paste it.


Thanks again,
Claudia

_
Are you using the latest version of MSN Messenger? Download MSN Messenger 
7.5 today! http://messenger.msn.co.uk


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] BitmapData and setPixel();

2005-12-23 Thread Paul BH
I can see the two resultant images, but from your description, I still
cant quite get what it is you want your grad to look like...

Thats why I wanted you to post an image of what you were trying to acheieve

On 12/23/05, Claudia Barnal [EMAIL PROTECTED] wrote:
 Paul,

 Thanks for looking into this.

 I'm not sure you tried the code I provided, as there you can see graphically
 what I mean. All you would need to do is copy and paste it.

 Thanks again,
 Claudia

 _
 Are you using the latest version of MSN Messenger? Download MSN Messenger
 7.5 today! http://messenger.msn.co.uk

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] BitmapData and setPixel();

2005-12-22 Thread Claudia Barnal

Anyone? Please...



From: Claudia Barnal [EMAIL PROTECTED]
Reply-To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] BitmapData and setPixel();
Date: Thu, 22 Dec 2005 04:03:57 +

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
Flashcoders@chattyfig.figleaf.com
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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] BitmapData and setPixel();

2005-12-22 Thread Paul BH
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 flashcoders@chattyfig.figleaf.com
 To: flashcoders@chattyfig.figleaf.com
 Subject: [Flashcoders] BitmapData and setPixel();
 Date: Thu, 22 Dec 2005 04:03:57 +
 
 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
 Flashcoders@chattyfig.figleaf.com
 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
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders