BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Painting a map

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
dimitris
Guest





PostPosted: Mon Mar 14, 2005 12:51 pm    Post subject: Painting a map Reply with quote



I have a 3d function z:=f(x,y) over an area and I want to paint a map of
this area using all the spectrum. What is the best method for picking colors
for values from -1 to 0 and from 0 to 1 ?


Back to top
Jens Gruschel
Guest





PostPosted: Mon Mar 14, 2005 3:54 pm    Post subject: Re: Painting a map Reply with quote



Quote:
I have a 3d function z:=f(x,y) over an area and I want to paint a map of
this area using all the spectrum. What is the best method for picking colors
for values from -1 to 0 and from 0 to 1 ?

Depends Wink Sometimes red colors are used for high values, blue or green
colors for low values, medium values might be represented with yellow
(just like temperature maps known from the weather forecast). To get the
color for a value (in range -1..1) you could use something like:

function GetMyColor(Value: Double): TColor;
begin
if Value < 0 then
Result := $00FF00 + Round((1.0 + Value) * $FF)
else
Result := $0000FF + (Round((1.0 - Value) * $FF) shl Cool;
end;

To get more special color gradient, you can use my TColorGradient class
(see b.p.attachments "Color gradients). You can use it like that:

var
Gradient: TPegtopColorGradient;
Colors: TPegtopColorArray;
begin
// do this at the beginning:
Gradient := TPegtopColorGradient.Create(
[clBlue, clGreen, clYellow, clRed]);
try
SetLength(Colors, 2001);
Gradient.GetColors(Colors);

// do this while painting:
// (-1.0 <= MyValue <= 1.0)
MyColor := Colors[Round(MyValue * 1000) + 1000];

// don't forget to clean up:
finally
Gradient.Free;
end;
end;

Jens

Back to top
dimitris
Guest





PostPosted: Mon Mar 14, 2005 8:17 pm    Post subject: Re: Painting a map Reply with quote



Thx a lot Jens for the quick reply.
I'll try both methods to see which one works better.


"Jens Gruschel" <nospam (AT) thisurldoesnotexist (DOT) com> wrote

Quote:
I have a 3d function z:=f(x,y) over an area and I want to paint a map of
this area using all the spectrum. What is the best method for picking
colors
for values from -1 to 0 and from 0 to 1 ?

Depends Wink Sometimes red colors are used for high values, blue or green
colors for low values, medium values might be represented with yellow
(just like temperature maps known from the weather forecast). To get the
color for a value (in range -1..1) you could use something like:

function GetMyColor(Value: Double): TColor;
begin
if Value < 0 then
Result := $00FF00 + Round((1.0 + Value) * $FF)
else
Result := $0000FF + (Round((1.0 - Value) * $FF) shl Cool;
end;

To get more special color gradient, you can use my TColorGradient class
(see b.p.attachments "Color gradients). You can use it like that:

var
Gradient: TPegtopColorGradient;
Colors: TPegtopColorArray;
begin
// do this at the beginning:
Gradient := TPegtopColorGradient.Create(
[clBlue, clGreen, clYellow, clRed]);
try
SetLength(Colors, 2001);
Gradient.GetColors(Colors);

// do this while painting:
// (-1.0 <= MyValue <= 1.0)
MyColor := Colors[Round(MyValue * 1000) + 1000];

// don't forget to clean up:
finally
Gradient.Free;
end;
end;

Jens



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.