Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine when to use black or white as label forecolor
Message
 
 
À
13/06/2005 10:55:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01022663
Message ID:
01022791
Vues:
16
This message has been marked as a message which has helped to the initial question of the thread.
Malcolm,

I was going to suggest something along those lines.. but I think there is sort of a gray area in that midrange of brightness that might not be too legible you may want to change the breakpoint away from 128, and potentially check each color indepentdently. Like on a rgb(65,65,255) backcolor white is more readble.

>Found a solution thanks to Jim Kearns (FoxToolbox.com) and Shawn Dorian/Dan Covill on Ed Leafe's Profox list.
>
>
>*-- The function "RGBComp" is contained in FoxTools.fll.  laBackColor is the
>*-- user chosen background color.
>
>llReturnValue = RGBComp(laBackColor, @lnRed, @lnGreen, @lnBlue)
>
>*-- We're trying to obtain the ideal forecolor for the user specified
>*-- backcolor.  Thanks to Shawn Dorion and Dan Covill on the ProFox list
>*-- for the basis of this solution.
>
>lnForeColor = RGB(255,255,255) && Default to White
>
>IF (lnRed + lnGreen + lnBlue) > (128 + 128 + 128)
>
>  lnForeColor = RGB(0,0,0)     && Black will be more readable here.
>
>ENDIF
>
>
>A tip for those reading this thread - if you need to find the background color on top of a gradient background where the gradient fade is gradual, you can use ThisForm.Point() method to determine the pixel color underneath or near a specific part of your transparent label.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform