By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,505 Members | 1,517 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,505 IT Pros & Developers. It's quick & easy.

Question of Color

100+
P: 675
I have 2 rectangles side-by-side and I want them to be colored.

I select both and use the Color Dialog Box to assign a color, say green with medium saturation. In other words, the scale along the right side of the dialog box is about mid-point. This gave me the BackColor = 8893580.

I now select one of the rectangles and call the color dialog again, and without changing the color (hue), I only move the pointer to a lighter (less saturated) color. This gave me 14411996. But side by side in my rectangles, this color is blue, not green. The dialog box does not give me a lighter color, but a different color.

I would like an algorithm to change the saturation of any color while preserving the hue. It doesn't have to be a dialog box.

Thank you
OldBirdman
Dec 16 '08 #1
Share this Question
Share on Google+
4 Replies


100+
P: 675
This is in the wrong forum. It belongs in Access. My apologies. Thank you.
Dec 16 '08 #2

Nepomuk
Expert 2.5K+
P: 3,112
No problem, I've moved to the Access Forum it for you.

Greetings,
Nepomuk
Dec 16 '08 #3

ADezii
Expert 5K+
P: 8,599
@OldBirdman
Try experimenting with the RGB() Function which returns a Long whole number representing an RGB color value, and can represent 16,000,000+ color variations. The syntax is:

RGB(red, green, blue) where the red, green , and blue Arguments have values between 0 and 255. It's getting near bedtime, so I'll just post a simple code example of its use:
Expand|Select|Wrap|Line Numbers
  1. Dim lngRetVal As Long
  2.  
  3. lngRetVal = RGB(255, 0, 255)
  4.  
  5. Debug.Print lngRetVal
  6.  
  7. 'Set the BackColor of the Detail Section of a Form to Magenta
  8. Me.Section(acDetail).BackColor = lngRetVal
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. 16711935
P.S. - Reference the Help Files for further information.
Dec 17 '08 #4

100+
P: 675
This question is not about what the single number representing color means, nor how to generate it. It is about finding an algorithm to change intensity without changing hue.
I tried to write an algorithm to lighten the color by 50%, and although slightly better than the MS color dialog, still altered the hue.
Using RGB is trial & error, which I am now doing with the color dialog box.

I started a program using sliders to generate values to run thru my algorithm quickly, displaying the colors in rectangles. Then I would not have to do so much cut&paste, but I get messages "The expression Change you entered as the event property setting produced the following error: There was an error loading an ActiveX control . . .

Altho I might like to figure this out, I don't want to get distracted here with ActiveX controls, which I can never make work, which is another topic. So I'm looking for an algorithm that I could put in a global procedure to call from the immediate window.

I am working on another algorithm now, but was hoping this had already been done.

OldBirdman
Dec 17 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.