...  Say I want to draw a color gradiant (shade of colors)
   from RGB(255,127,0) to RGB(0,127,255) [I put arbitrary RGB values
   here since this can be the case: I ask the user the start and end
   colors and (s)he can place &c000000 or click on a Canvas rect to
   choose a color in the OS palettes]

   How can I do that ?

   Doing a simple shade of colors from say RGB(255,0,0) to
   RGB(0,255,0) can be considered as simple (I start to decrease the
   .Red atom from 255 and start to increase the .Green atom from 0).

   But for "complex colors", I'm short of ideas.

I think you've mostly got it.

For example, if you want to draw a color gradient from red to green, you do:

        start   red     255,0,0
                ...
        end     green   0,255,0

each step of the way, you linarly interpolate what color to draw.
Something like:

        color = (1 - step#) * start / #steps + step# * end / #steps

If you look at the source to my Gadget program, it does this a lot
and has the exact code.  See:

        http://www.finseth.com/realbasic/index-gadget.php

If you are doing a Photoshop-like color area, you do the same thing,
but on two axes at once.

Other areas involve other types of scaling math, but the concept is
the same.

Craig

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to