Author Topic: TINT Function  (Read 7185 times)

0 Members and 1 Guest are viewing this topic.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4735
  • Ideas Visio-lized into solutions
TINT Function
« on: June 10, 2008, 01:50:10 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4735
  • Ideas Visio-lized into solutions
Re: TINT Function
« Reply #1 on: June 10, 2008, 06:06:28 PM »
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 1737
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: TINT Function
« Reply #2 on: June 10, 2008, 06:57:48 PM »
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

  • Hero Member
  • *****
  • Posts: 1708
Re: TINT Function
« Reply #3 on: June 10, 2008, 10:53:25 PM »
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 1737
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: TINT Function
« Reply #4 on: June 11, 2008, 05:19:54 AM »
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