473,385 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Setting colors on components

I've used the Colors class to access a bunch
of colors for my applications. Now, i'd like
to create a family for of each such color as
follows.

public Color Normal
{get{return Colors.Orange;}}
public Color Washed
{get{return Colors.Yellow;}}
public Color Satured
{get{return Colors.Red;}}

However, i don't really feel like setting up
a static map for each (most) of the colors.
I'd strongly prefer a facility that would
simply give me a washed and a saturated
version of whatever i put in.

Hints other than "write it yourself, you
lazy bum!", may i hope?

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Oct 23 '08 #1
4 1314
Lee
How are you determining which color is the Washed and Satured version
of the original color?

L. Lee Saunders
http://oldschooldotnet.blogspot.com

On Oct 23, 7:56*am, "K Viltersten" <t...@viltersten.comwrote:
I've used the Colors class to access a bunch
of colors for my applications. Now, i'd like
to create a family for of each such color as
follows.

* public Color Normal
* * {get{return Colors.Orange;}}
* public Color Washed
* * {get{return Colors.Yellow;}}
* public Color Satured
* * {get{return Colors.Red;}}

However, i don't really feel like setting up
a static map for each (most) of the colors.
I'd strongly prefer a facility that would
simply give me a washed and a saturated
version of whatever i put in.

Hints other than "write it yourself, you
lazy bum!", may i hope?

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Oct 23 '08 #2
On Thu, 23 Oct 2008 05:56:38 -0700, K Viltersten <tm**@viltersten.com>
wrote:
I've used the Colors class to access a bunch
of colors for my applications. Now, i'd like
to create a family for of each such color as
follows.

public Color Normal
{get{return Colors.Orange;}}
public Color Washed
{get{return Colors.Yellow;}}
public Color Satured
{get{return Colors.Red;}}

However, i don't really feel like setting up
a static map for each (most) of the colors.
I'd strongly prefer a facility that would
simply give me a washed and a saturated
version of whatever i put in.

Hints other than "write it yourself, you
lazy bum!", may i hope?
Unfortunately, as far as I know, neither .NET nor Windows provide built-in
conversion functions to go from HSV to RGB. The most natural way to
approach your problem would be to adjust the colors saturation in the HSV
color space and then generate an equivalent RGB value. (Oddly enough, you
_can_ go from RGB to HSV using the .NET Color structure, as it has
GetSaturation(), GetHue(), and GetBrightness() methods).

I find this especially odd, considering the built-in color picker dialog
does present the HSV model as an option.

If you want to write your own HSV to RGB function, you may find these
references useful:
http://www.cs.rit.edu/~ncs/color/t_convert.html
http://blogs.msdn.com/cjacks/archive...12/575476.aspx
http://splinter.com.au/blog/?p=29

Just take the color you want to saturate or desaturate, use the .NET
methods to get the HSV values, adjust the S component as desired up or
down, and then convert back to RGB using one of those algorithms (they are
all based on the same source, so they ought to be equivalent...I didn't
check them closely to make sure though).

Pete
Oct 23 '08 #3
"K Viltersten" <tm**@viltersten.comwrote in message
news:6m************@mid.individual.net...
However, i don't really feel like setting up
a static map for each (most) of the colors.
I'd strongly prefer a facility that would
simply give me a washed and a saturated
version of whatever i put in.

Hints other than "write it yourself, you
lazy bum!", may i hope?
Color matrices are wonderful for this. But it'll be up to you to decide on
the matrix...!

Check out this guy's excellent page, and consider posting further questions
on this in microsoft.public.dotnet.framework.drawing:
http://www.bobpowell.net/faqmain.htm

I found another excellent page on matrices when I was doing something a
while back, but if I have the link at all it's at home, not here, so if I
remember to dig it up I'll post it too. Of course, there's always Google....
Oct 23 '08 #4
>However, i don't really feel like setting up
>a static map for each (most) of the colors.
I'd strongly prefer a facility that would
simply give me a washed and a saturated
version of whatever i put in.

Hints other than "write it yourself, you
lazy bum!", may i hope?

Color matrices are wonderful for this. But it'll be up to you to decide on
the matrix...!

Check out this guy's excellent page, and consider posting further
questions on this in microsoft.public.dotnet.framework.drawing:
http://www.bobpowell.net/faqmain.htm

I found another excellent page on matrices when I was doing something a
while back, but if I have the link at all it's at home, not here, so if I
remember to dig it up I'll post it too. Of course, there's always
Google....

Thanks to all!

--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy

Oct 23 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Franklin | last post by:
WITHOUT KNOWING ANYTHING ABOUT THE CURRENT COLORS, I want to swap the foreground/background colors of a link when someone hovers over it. Is this possible with HTML, CSS, DOM, & JavaScript? If...
7
by: TomHL | last post by:
hello, - I have a Bitmap Object named: bmp1 - I already have the numerical values of:red,blue and green colors + I have the X and Y cordinates. How do I set the pixel value via safe code on...
2
by: Cliff Lane | last post by:
I have an application that allows the user to select fore and back ground colors for command buttons. I use the dialog to select the colors and store the value returned in the db as a string. For...
4
by: Starbuck | last post by:
HI In a previous versino of one of our apps we would store numeric values such as 16777088 which we used to set the grid colors of a job on a TrueGrid grid in VB6. Now in VB.Net we are...
1
by: fripper | last post by:
In VB 2005ave a I have a picture control ("pix") on which I want to set each pixel color according to a variable, X, that has been calculated (I'm drawing fractals from the Mandelbrot Set). I use...
1
by: Demi | last post by:
I want to be able to define standard colors in a base form, then have child forms use those values instead of standard colors. Ex in my base form I want to do this: Color myColor =...
6
by: vijai.kalyan | last post by:
Hello, I wrote a trivial program to set the console title in a console application. Here is the code:- namespace myns { class SetTitle { static void Main ( string args )
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
8
by: Jeff | last post by:
ASP.NET 2.0 I'm wondering how to set the color of a visited HyperLinkField (the link text) in a GridView?? Here is the markup of the HyperLinkField I have problems with: <asp:HyperLinkField...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.