Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Color generation Part II
Message
From
10/04/2002 05:50:15
 
 
To
10/04/2002 02:19:42
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00643022
Message ID:
00643063
Views:
17
Hi!

Not sure if this helps, but you might want to investigate in direction of how VFP's GetColor() dialog box works. There are 3 parameters - Hue (color position), Sat (contrast) and Lum (brightness). There are formulae exists to convert these 3 values to RGB color, but I do not have it handy and do not remember where I saw it.

As about dividing to 32x32 - you cannot with RGB approach, just because by nature you have 3 components of the colour. For example, a loop like following gives you all colours:
for RR = 0 to 9
   for GG = 0 to 9
      for BB = 0 to 9
         nColor = RGB(min(RR*(256/9),255), min(GG*(256/9),255), min(BB*(256/9),255))
      endfor
   endfor
endfor
This gives 1000 colors (10x10x10) from 0,0,0 to 255,255,255.

If you can use Hue/Sat/Lum approach, this will give you better looking and approach:
* 4 brightness variations from close to black toclose to white:
* from Lum=256/6 to 256-256/6. Do not use Lum=0 or Lum=255,
* though you might want separate black and white colours
for Lum = 0 to 3
   for Sat = 0 to 7 && 8 different contrasts from 0 (gray) to 255 (high contrast)
      for Hue = 0 to 31 && 32 different colour positions
         nColor = ???
      endfor
   endfor
endfor
Though this might be hard...



>In an attempt to obtain a smooth color generation, I am presently with this code:
>
>
>lcHtml=lcHtml+'<TABLE CELLSPACING=0 CELLPADDING=0 ID=FournierTransformationList><TR>'
>lnPerRow = 32
>Store 255/15 to lnRedInc, lnGreenInc
>lnBlueInc = 255/15
>lnShp=0
>For Blue = 0 to 31
>For green = 0 to 31
>   For red = 0 to 0
>      lnShp  = lnShp+1
>      lnRed = round(red * lnRedInc,0)
>      lnGreen = round(green * lnGreenInc,0)
>      lnBlue = round(blue * lnBlueInc,0)
>      lcWebColor = right(trans(rgb(lnBlue,lnGreen,lnRed),'@0'),6)
>      lcHtml=lcHtml+iif((lnShp-1)%lnPerRow=0,'<TR>','')+;
>       '<TD bgcolor=#'+lcWebColor+[><A HREF="javascript:Assignation(']+;
>       lcWebColor+[')" Class=List TITLE="#]+lcWebColor+;
>       '"><IMG SRC=/Point.gif WIDTH=15 HEIGHT=15 BORDER=0></A>'
>   Endfor
>Endfor
>Next
>lcHtml=lcHtml+'</TABLE>'
>
>
>That generates a smooth color picker but that only includes blue to green. How would I go about this to obtain a smooth color picker to also include the red palette?
>
>I need to have 32 items per row and I would like to obtain approx. 32 items vertically.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform