Main Menu

TINT Function

Started by wapperdude, June 10, 2008, 06:50:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wapperdude

I'm trying to use the TINT function in the Fill section of the shape sheet to set the foreground color to be a lighter shade of the background color, but keeping getting an error.  An example of the TINT function syntax would be most appreciated.
Visio 2019 Pro

wapperdude

I think I solved my problem.  I'm using Visio 2003 here at work.  The "TINT" function isn't listed for 2003, just 2007.  Limits backward compatibility.
Visio 2019 Pro

Visio Guy

Hi wapperdude,

Yes, Tint is new for Visio 2007. It won't "break" in Visio 2003--you should still be able to open drawings from 2007 in 2003--but I'm not sure what will happen to Tint formulas. Probably some form of being ignored.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

vojo

if you know the foreground, for a given shape, is lighter or darker than background, you can do the following

fillforegnd = <color from UI...dont use white or black depending on tinting higher or lower>
user.tint = RGB(RED(fillforegnd)+user.delta,GREEN(fillforegnd)+user.delta,BLUE(fillforegnd)+user.delta)
user.delta = <delta of tint...can be pos or neg number...probably should keep it at 15 or less>
fillbackgnd = guard(user.tint)

I actually use this approach to do shading of isometric cubes and vary it based on action buttons highlighting where light source is at.   Works well.

In general, if a color is say RGB (250,250,250), then may want limit so rollover does not give you black
I use the following:  user.backtint = RGB(RED(user.tint)>250,250,RED(user.tint), etc etc)
and plug backtint into fillbackgnd.

Visio Guy

Good tip, Vojo!

The ShapeSheet also has HSL functions (hue, saturation, luminosity), which I think are easier to use for creating lighter/darker shades. For instance, you can make a darker shade of red like this:

User.Red = RGB(255,0,0)
User.DkRed = HSL( HUE(User.Red), SAT(User.Red), LUM(User.Red)*.9 )


Note that luminosity values are good from 0 to 240. 0 makes black, 240 makes white. 120 is full saturation. So LUM(RGB(255,0,0)) = 120.

If you add or subtract values to make your shades, you need to ensure that they don't go below 0 or above 240.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010