Author Topic: Text Background (TextBkgnd) Color Indices off by 1?  (Read 3899 times)

0 Members and 1 Guest are viewing this topic.

gwideman

  • Jr. Member
  • **
  • Posts: 50
Text Background (TextBkgnd) Color Indices off by 1?
« on: January 11, 2012, 05:58:21 AM »
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





« Last Edit: January 13, 2012, 04:46:50 AM by Visio Guy »

AndyW

  • Sr. Member
  • ****
  • Posts: 320
    • PC Mimic Diagram
Re: Text Background (TextBkgnd) Color Indices off by 1?
« Reply #1 on: January 11, 2012, 06: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!
« Last Edit: January 13, 2012, 04:46:38 AM by Visio Guy »
Live life with an open mind

gwideman

  • Jr. Member
  • **
  • Posts: 50
Re: Text Background (TextBkgnd) Color Indices off by 1?
« Reply #2 on: January 11, 2012, 07:55:26 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
« Last Edit: January 13, 2012, 04:46:26 AM by Visio Guy »

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3826
  • Ideas Visio-lized into solutions
Re: Text Background (TextBkgnd) Color Indices off by 1?
« Reply #3 on: January 11, 2012, 11:40:57 AM »
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
« Last Edit: January 13, 2012, 04:46:19 AM by Visio Guy »
Visio 2019 Pro

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1718
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Text Background (TextBkgnd) Color Indices off by 1?
« Reply #4 on: January 13, 2012, 04:45:15 AM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3826
  • Ideas Visio-lized into solutions
Re: Text Background (TextBkgnd) Color Indices off by 1?
« Reply #5 on: January 13, 2012, 10:15:18 AM »
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

  • Jr. Member
  • **
  • Posts: 50
Re: Text Background (TextBkgnd) Color Indices off by 1?
« Reply #6 on: January 15, 2012, 07:02:32 AM »
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