I would like to find the system color for an object. Then as appropriate use that color as a basis for the color of my own objects either as:
- The same color
- A little lighter
- A little darker.
Can anyone tell me how to do this?
Well, there are quite a few functions to pull specific system colors, such as FillColor for a window background.
Once you have a color, the HSV model is probably the best way to play with the color. The full “bright” colors have saturation and value of 1. Reducing the saturation is the equivalent of mixing a bit of white with it; reducing value adds a bit of black.
I see that this post is rather old. But what I did was the following:
Public Function Brightness(c as Color, value as Double = 1) as color
if value = 1 then Return c
dim NewColor as color = color.HSVA( c.Hue, c.Saturation, c.Value * value, c.Alpha )
The NewColor is generated by changing the HSV values, the c.Value will change the brightness.
If the brightness value is 1 nothing changes to the color. So I will just return the passed color value.
I can call this function anywhere in the software, like this, a window with three Oval shape controls:
Oval1.FillColor = Brightness(HighlightColor , 0.5) ' Makes it 50% darker
Oval2.FillColor = Brightness(HighlightColor , 1.0) ' Makes it the same color
Oval3.FillColor = Brightness(HighlightColor , 1.5) ' Makes it 50% lighter
This code will give the Oval shapes different colors, based on the system’s HighlightColor.