Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Fill an array with smooth sequence of colours

Avatar of HarryRogers
HarryRogers asked on
Algorithms
4 Comments1 Solution451 ViewsLast Modified:
Hi
 I wish to populate the elements of an array (of arbitrary length) with a smooth progression of colour values. Using 'BlendColors' I can find a midway colour between two values. What i would like is a neat algorithm to fill each of these intermediate values in a given array.
e.g. for an array of length n
the value at index n div 2  (Call it Vi) is BlendColors( colour[0],color[n]...)
then
the value at index [n div 2] div 2 is the result  BlendColors( colour[0], Vi...)
etc.

 function BlendColors(Color1, Color2: TColor; Opacity: Byte): TColor;
var
  r, g, b: Byte;
  c1, c2: PByteArray;
begin
  Color1 := ColorToRGB(Color1);
  Color2 := ColorToRGB(Color2);
  c1 := @Color1;
  c2 := @Color2;

  r := Trunc(c1[0] + (c2[0] - c1[0]) * Opacity / 256);
  g := Trunc(c1[1] + (c2[1] - c1[1]) * Opacity / 256);
  b := Trunc(c1[2] + (c2[2] - c1[2]) * Opacity / 256);

  Result := RGB(r, g, b);
end;
ASKER CERTIFIED SOLUTION
Avatar of Jose Parrot
Jose ParrotFlag of Brazil imageGraphics Expert

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers