Re: [Flashcoders] Dynamically generate blend colors

2009-05-01 Thread Glen Pike

Have a look at the Greensock Tween classes - they might help.

natalia Vikhtinskaya wrote:

Hi to all
I need dynamically generate blend colors from one color to another.
For example RGB:
1Mc 255  255 255
2?
3?
4?
5?
6?
7 136 114 141
Is there a way to calculate blend colors for 5 steps?
Thanks you for any help or links.
___
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] Dynamically generate blend colors

2009-05-01 Thread natalia Vikhtinskaya
Thank you. Yes this class allows to create gradient. But I need code
that allows to have N  MovieClips with blend colors from one to
another.

2009/5/1 Glen Pike g...@engineeredarts.co.uk:
 Have a look at the Greensock Tween classes - they might help.

 natalia Vikhtinskaya wrote:

 Hi to all
 I need dynamically generate blend colors from one color to another.
 For example RGB:
 1Mc 255  255 255
 2?
 3?
 4?
 5?
 6?
 7 136 114 141
 Is there a way to calculate blend colors for 5 steps?
 Thanks you for any help or links.
 ___
 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


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


Re: [Flashcoders] Dynamically generate blend colors

2009-05-01 Thread Hans Wichman
Hi,

mask out the r,g, b and tween them individually.

eg write a class:

RGBTween.getRGB (source, dest, 0..1);

The getRGB should mask out the r,g,b values, calculate the result r,g,b
based on source, dest and a 0..1 factor and combine the parts into a new rgb
value.

It will do the trick, but Im not sure its visually correct.

HTH
JC

On Fri, May 1, 2009 at 2:38 PM, natalia Vikhtinskaya
natavi.m...@gmail.comwrote:

 Thank you. Yes this class allows to create gradient. But I need code
 that allows to have N  MovieClips with blend colors from one to
 another.

 2009/5/1 Glen Pike g...@engineeredarts.co.uk:
   Have a look at the Greensock Tween classes - they might help.
 
  natalia Vikhtinskaya wrote:
 
  Hi to all
  I need dynamically generate blend colors from one color to another.
  For example RGB:
  1Mc 255  255 255
  2?
  3?
  4?
  5?
  6?
  7 136 114 141
  Is there a way to calculate blend colors for 5 steps?
  Thanks you for any help or links.
  ___
  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
 

 ___
 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] Dynamically generate blend colors

2009-05-01 Thread natalia Vikhtinskaya
I am sorry. I did not understand your advice. I am working with AS2.

2009/5/1 Hans Wichman j.c.wich...@objectpainters.com:
 Hi,

 mask out the r,g, b and tween them individually.

 eg write a class:

 RGBTween.getRGB (source, dest, 0..1);

 The getRGB should mask out the r,g,b values, calculate the result r,g,b
 based on source, dest and a 0..1 factor and combine the parts into a new rgb
 value.

 It will do the trick, but Im not sure its visually correct.

 HTH
 JC

 On Fri, May 1, 2009 at 2:38 PM, natalia Vikhtinskaya
 natavi.m...@gmail.comwrote:

 Thank you. Yes this class allows to create gradient. But I need code
 that allows to have N  MovieClips with blend colors from one to
 another.

 2009/5/1 Glen Pike g...@engineeredarts.co.uk:
   Have a look at the Greensock Tween classes - they might help.
 
  natalia Vikhtinskaya wrote:
 
  Hi to all
  I need dynamically generate blend colors from one color to another.
  For example RGB:
  1Mc 255  255 255
  2?
  3?
  4?
  5?
  6?
  7 136 114 141
  Is there a way to calculate blend colors for 5 steps?
  Thanks you for any help or links.
  ___
  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
 

 ___
 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


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


RE: [Flashcoders] Dynamically generate blend colors

2009-05-01 Thread Jack Doyle
Here's a function that you can feed a start hex color, end hex color, and
however many steps you want, and it'll generate an Array with hex values for
that many steps:

--

function getHexSteps($start:uint, $end:uint, $steps:uint):Array {
var startVals:Object = {r:$start  16, g:($start  8)  0xff,
b:$start  0xff};
var changeVals:Object = {r:($end  16) - startVals.r, g:(($end 
8)  0xff) - startVals.g, b:($end  0xff) - startVals.b};
var hexSteps:Array = [];
var spacing:Number = 1 / ($steps - 1);
var changeFactor:Number;
for (var i:int = 0; i  $steps; i++) {
changeFactor = i * spacing;
hexSteps[i] = ((startVals.r + (changeFactor * changeVals.r))
 16 | (startVals.g + (changeFactor * changeVals.g))  8 | (startVals.b +
(changeFactor * changeVals.b)));
}
return hexSteps;
}

--

For example, getHexSteps(0xFF, 0xFF, 8) would return an Array that
has 8 steps total, going from red to blue:
[0xff, 0xda0024, 0xb60048, 0x91006d, 0x6d0091, 0x4800b6, 0x2400da,
0xFF]

So a simple use case that builds 30-pixel blocks across the stage, one for
each step would look like:

var colors:Array = getHexSteps(0xFF, 0xFF, 8);
var s:Sprite;
for (var i:int = 0; i  colors.length; i++) {
s = new Sprite();
s.graphics.beginFill(colors[i], 1);
s.graphics.drawRect(0, 0, 30, 30);
s.graphics.endFill();
addChild(s);
s.x = i * s.width;
}

Hope that helps.

Jack


-Original Message-
From: natalia Vikhtinskaya [mailto:natavi.m...@gmail.com] 
Sent: Friday, May 01, 2009 7:38 AM
To: Flash Coders List
Subject: Re: [Flashcoders] Dynamically generate blend colors

Thank you. Yes this class allows to create gradient. But I need code
that allows to have N  MovieClips with blend colors from one to
another.

2009/5/1 Glen Pike g...@engineeredarts.co.uk:
 Have a look at the Greensock Tween classes - they might help.

 natalia Vikhtinskaya wrote:

 Hi to all
 I need dynamically generate blend colors from one color to another.
 For example RGB:
 1Mc 255  255 255
 2?
 3?
 4?
 5?
 6?
 7 136 114 141
 Is there a way to calculate blend colors for 5 steps?
 Thanks you for any help or links.
 ___
 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






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


Re: [Flashcoders] Dynamically generate blend colors

2009-05-01 Thread natalia Vikhtinskaya
Thank you so much!!! That is exactly what I am looking: changeFactor.

2009/5/1 Jack Doyle j...@greensock.com:
 Here's a function that you can feed a start hex color, end hex color, and
 however many steps you want, and it'll generate an Array with hex values for
 that many steps:

 --

 function getHexSteps($start:uint, $end:uint, $steps:uint):Array {
        var startVals:Object = {r:$start  16, g:($start  8)  0xff,
 b:$start  0xff};
        var changeVals:Object = {r:($end  16) - startVals.r, g:(($end 
 8)  0xff) - startVals.g, b:($end  0xff) - startVals.b};
        var hexSteps:Array = [];
        var spacing:Number = 1 / ($steps - 1);
        var changeFactor:Number;
        for (var i:int = 0; i  $steps; i++) {
                changeFactor = i * spacing;
                hexSteps[i] = ((startVals.r + (changeFactor * changeVals.r))
  16 | (startVals.g + (changeFactor * changeVals.g))  8 | (startVals.b +
 (changeFactor * changeVals.b)));
        }
        return hexSteps;
 }

 --

 For example, getHexSteps(0xFF, 0xFF, 8) would return an Array that
 has 8 steps total, going from red to blue:
 [0xff, 0xda0024, 0xb60048, 0x91006d, 0x6d0091, 0x4800b6, 0x2400da,
 0xFF]

 So a simple use case that builds 30-pixel blocks across the stage, one for
 each step would look like:

 var colors:Array = getHexSteps(0xFF, 0xFF, 8);
 var s:Sprite;
 for (var i:int = 0; i  colors.length; i++) {
        s = new Sprite();
        s.graphics.beginFill(colors[i], 1);
        s.graphics.drawRect(0, 0, 30, 30);
        s.graphics.endFill();
        addChild(s);
        s.x = i * s.width;
 }

 Hope that helps.

 Jack


 -Original Message-
 From: natalia Vikhtinskaya [mailto:natavi.m...@gmail.com]
 Sent: Friday, May 01, 2009 7:38 AM
 To: Flash Coders List
 Subject: Re: [Flashcoders] Dynamically generate blend colors

 Thank you. Yes this class allows to create gradient. But I need code
 that allows to have N  MovieClips with blend colors from one to
 another.

 2009/5/1 Glen Pike g...@engineeredarts.co.uk:
 Have a look at the Greensock Tween classes - they might help.

 natalia Vikhtinskaya wrote:

 Hi to all
 I need dynamically generate blend colors from one color to another.
 For example RGB:
 1Mc 255  255 255
 2?
 3?
 4?
 5?
 6?
 7 136 114 141
 Is there a way to calculate blend colors for 5 steps?
 Thanks you for any help or links.
 ___
 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






 ___
 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