Text Background (TextBkgnd) Color Indices off by 1?

Started by gwideman, January 11, 2012, 10:58:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gwideman

Hi folks, especially Chris :-)

Does anyone know why the TextBkgnd cell requires that "+1" be added to RGB() in order to show the desired color?  When no other color cell that I could find has that requirement? 

So that "RGB(0,255,0)" produces Green everywhere but TextBkgnd, where it produces black.  But in  TextBkgnd, "RGB(0,255,0)+1" produces the desired green color.

Here's Help:

For Fill Bkgnd: "To enter a custom color, use the RGB or HSL function. The value of a custom color is its RGB color, and RGB(r, g, b), rather than a number, will be shown in the ShapeSheet window."

For TextBkgnd: "To enter a custom color, use the RGB or HSL function plus oneā€”for example, RGB(255,127,255)+1. The value of a custom color is its RGB color, and RGB(r, g, b)+1, rather than a number, will be shown in the ShapeSheet window."

And perhaps needless to say, setting a formula in a sensible color cell to equal TextBkgnd picks some random unintended color. Though you can set:

SensibleColorCell = TextBkgnd -1

Awesome.

-- Graham






AndyW

#1
Because the text background, besides colour also indicates no background. So 0 seems to have been used for that, thus requiring colours to start from 1. It does seem strange they chose to combine whether or not there is a text background with its colour!
Live life with an open mind

gwideman

#2
Quote from: AndyW on January 11, 2012, 11:53:02 AM
Because the text background, besides colour also indicates no background. So 0 seems to have been used for that, thus requiring colours to start from 1. It does seem strange they chose to combine whether or not there is a text background with its colour!

You may well have the answer there! This is a color setting where there's no corresonding fill pattern, so no other cell through which to specify "no fill".  You'd think maybe the value "-1" would have occurred to someone :-).

-- Graham

wapperdude

#3
For reference, check this link:  http://msdn.microsoft.com/en-us/library/ms406518(v=office.12).aspx

Other observations:  only "+1" gives the desired color. 

Only negative numbers will alter the value, e.g., -3, -10.

As noted by Graham and AndyW, strange functionality, and why is this behavior different than all other fill functions???   :o
Visio 2019 Pro

Visio Guy

I think you guys have figured this all out already, but I'll restate for those who read from the bottom-up :), and add some technical history to the discussion.

Visio color cells hold an index to a color in the document's color table. Even if you enter RGB(255,0,0), Visio evaluates that to some integer, somewhere. You can demonstrate this for yourselves by doing this:

FillForegnd = RGB(255,0,0)
User.SillyColorIndexTest = 0 + FillForegnd

User.SillyColorIndexTest evaluates to 24 for a default, blank drawing in Visio Premium 2010. You'll also notice that Visio didn't detect that RGB(255,0,0) is the same as color #2. It added a new color to the color table. The reason for this is probably that color #2 can be changed if you edit the default colors and redefine colors 0-23 if you dig around in the color dialogs long enough.

To have no fill for a shape, you set FillPattern to 0. But there is no TextBkgndPattern cell, so the Creators doubled-up (ie: hacked) the TextBkgnd cell so that it is getting the color TextBkgnd-1 from the color table, unless the value is 0, whereupon a the text background is transparent.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

wapperdude

Rhetorical question, or perhaps statement, but it seems it would have been less confusing, even more logical, to set the fill transparency to 100% rather than this "doubling up".

Wapperdude
Visio 2019 Pro

gwideman

Quote from: wapperdude on January 13, 2012, 03:15:18 PM
Rhetorical question, or perhaps statement, but it seems it would have been less confusing, even more logical, to set the fill transparency to 100% rather than this "doubling up".
Wapperdude

... except that I'm pretty sure the appearance of the TextBkgnd cell predates transparency.  I'm still thinking TextBkgnd = -1 would have been the better choice for "no background fill", but maybe there was some reason that wasn't feasible.
-- Graham