Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generating 256 color choices
Message
De
17/01/2002 12:12:00
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
17/01/2002 02:13:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00605952
Message ID:
00606182
Vues:
37
This message has been marked as the solution to the initial question of the thread.
>I want to be able to generate 256 color choices to allow the user to select a choice based on visual representation. Those will be HTML colors that a user will be able to select from an HTML page. What kind of formula can I use in order to list 256 choices?

Michel,
You could either use something like this or get HTML directly from MSDN help (named colors) :
lcHTML = '&ltHTML&gt&ltBODY&gt&ltTABLE&gt&ltTR&gt'
oForm=createobject('Form')
With oForm
  .ShowTips = .t.
  lnPerRow = 16
  Store 255/(2^3-1) to lnRedInc, lnGreenInc
  lnBlueInc = 255/(2^2-1)
  lnShp=0
  For blue = 0 to 2^2-1
    For green = 0 to 2^3-1
      For red = 0 to 2^3-1
        lnRed = round(red * lnRedInc,0)
        lnGreen = round(green * lnGreenInc,0)
        lnBlue = round(blue * lnBlueInc,0)
        lnShp  = lnShp+1
        lcName = 'shp'+trans(lnShp)
        lcLblName = 'lbl'+trans(lnShp)
        .addobject(lcName, 'myShape', ;
          lnShp, lnPerRow, lnRed, lnGreen, lnBlue)
        lcWebColor = right(trans(rgb(tnBlue,tnGreen,tnRed),'@0'),6)  
        lcHTML = lcHTML + ;
          iif((lnShp-1)%lnPerRow=0,'&lt/TR&gt&ltTR&gt','') + ;
          '&ltTD bgcolor=#'+lcWebColor+'&gt'+lcWebColor+'&lt/TD&gt'
      Endfor
    Endfor
  Endfor
  lcHTML = lcHTML+'&lt/TR&gt&lt/TABLE&gt&lt/BODY&gt&lt/HTML&gt'
  Strtofile(lcHTML,'256Colors.htm')
  .SetAll('Visible',.t.)
  .Height = 20 * 16
  .Width = 20 * 16
  .Show
Endwith
Read events


Define class myShape as Shape
  Height = 20
  Width = 20
  Procedure Init
  Lparameters tnShp, tnPerRow, tnRed, tnGreen, tnBlue
  With this
    .Left =  ((tnShp-1)%tnPerRow) * .Width
    .Top = (ceiling(tnShp/tnPerRow)-1) * .Height
    .Backcolor = rgb(tnRed, tnGreen, tnBlue)
    .Tooltiptext = trans(tnRed)+' '+trans(tnGreen)+' '+trans(tnBlue)
  Endwith
Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform