FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DRAWING

Blend colours


Here is a function from a demo that I posted a while ago. It blends two RGB colors. Call it like this:

FN mixColors(@RGBcol1,mix,@RGBcol2)

It will blend the two colors based on the value of mix. mix=255 (100% of RGBcol1), mix=0 (100% of RGBcol2), mix=127 (50/50 mix of the two RGB colors).
The new color is returned in RGBcol1.
You can call thid function in a loop then CALL RGBFORECOLOR(#@RGBcol1) and draw your object with a slight offset each time to get a blend shadow effect.

If you would like a copy of the color demo please let me know.

'-----------
LOCAL FN mixColors(RGB1&,mix,RGB2&)
  SELECT
    CASE mix>=255 'RGB1& is answer so do nothing
    CASE mix<=0 : BLOCKMOVE RGB2&, RGB1&, _rgbColor'RGB2& is answer
    CASE ELSE 'mix the two colors
      red1%=PEEK(@RGB1&.red%) : gre1%=PEEK(@RGB1&.green%) :
      blu1%=PEEK(@RGB1&.blue%)
      red2%=PEEK(@RGB2&.red%) : gre2%=PEEK(@RGB2&.green%) :
      blu2%=PEEK(@RGB2&.blue%)

      red1%=red1%*mix/255 : red2%=red2%*(255-mix)/255 : red1%=red1%+red2%
      gre1%=gre1%*mix/255 : gre2%=gre2%*(255-mix)/255 : gre1%=gre1%+gre2%
      blu1%=blu1%*mix/255 : blu2%=blu2%*(255-mix)/255 : blu1%=blu1%+blu2%

      RGB1&.red%=red1%<<8 : RGB1&.green%=gre1%<<8 : RGB1&.blue%=blu1%<<8
  END SELECT
END FN
'-----------

Joe Lertola