|
Mike Hankey wrote: putting on socks the same color is an acheivement Allow me to share the wisdom of the ages, my son... Twice a year, I buy a 12 pack of Hanes crew socks. They are all the same color (white with some gray) and therefore go with everything.
If there's ever a case where I'm wearing something other than these socks, I wonder when I died and no one told me.
Software Zen: delete this;
|
|
|
|
|
This *almost* qualifies as a programming question, but not quite, so I apologize for playing footsie with breaking the rules.
Under System.Drawing in .NET there's a Color enumeration that has a bunch of predefined colors like DarkKhaki and AliceBlue , and such.
Is that enumeration based on anything other than some arbitrary list of colors microsoft's coders came up with?
What I mean is, is there some sort of named color palette for web colors or something that this enumeration is based on.
I'm asking in part, because I'm doing this to generate C++ code for a rather large enumeration of color values, I am shamelessly ripping from .NET
bool cpp17 = true;
Console.WriteLine("\t// predefined color values");
Console.WriteLine("\ttemplate<typename PixelType>");
Console.WriteLine("\tstruct color final {");
Console.WriteLine("\t\t// we use a super precise max-bit RGB pixel for this");
Console.WriteLine("\t\tusing source_type = rgb_pixel<HTCW_MAX_WORD>;");
var pia = typeof(Color).GetProperties(BindingFlags.Public | BindingFlags.Static);
for(var i = 0;i<pia.Length;i++)
{
var name = pia[i].Name;
if ("Transparent" != name)
{
if(cpp17)
{
Color c = (Color)pia[i].GetValue(null);
Console.WriteLine("\t\tconstexpr static const PixelType {0} = source_type(true,{1},{2},{3}).convert<PixelType>();", _ConvertCase(name), c.R / 255.0, c.G / 255.0, c.B / 255.0);
} else
Console.WriteLine("\t\tstatic const PixelType {0};",_ConvertCase(name));
}
}
Console.WriteLine("};");
if (!cpp17)
{
for (var i = 0; i < pia.Length; i++)
{
var name = pia[i].Name;
if ("Transparent" != name)
{
Color c = (Color)pia[i].GetValue(null);
Console.WriteLine("\ttemplate<typename PixelType> const PixelType color<PixelType>::{0} = color<PixelType>::source_type(true,{1},{2},{3}).convert<PixelType>();", _ConvertCase(name), c.R / 255.0, c.G / 255.0, c.B / 255.0);
}
}
}
That creates a templated "enumeration" of known color values in C++17 or C++14 depending on the cpp17 flag.
In essence creating code like this (C++17)
constexpr static const PixelType alice_blue = source_type(true,0.941176470588235,0.972549019607843,1).convert<PixelType>();
constexpr static const PixelType antique_white = source_type(true,0.980392156862745,0.92156862745098,0.843137254901961).convert<PixelType>();
constexpr static const PixelType aqua = source_type(true,0,1,1).convert<PixelType>();
constexpr static const PixelType aquamarine = source_type(true,0.498039215686275,1,0.831372549019608).convert<PixelType>();
constexpr static const PixelType azure = source_type(true,0.941176470588235,1,1).convert<PixelType>();
And the bottom line is I want to know how much trouble I'll get in by doing this. If the color values are standardized then I think I'm safe from any team of lawyers microsoft sics on me.
If they're not then I may need to come up with an alternative.
Real programmers use butterflies
|
|
|
|
|
|
Your google fu is stronger than mine. I bow to you, Sander-san**
**Yes I know, I'm mixing chinese and japanese things, but whatever. I don't know how to express "teacher" in mandarinized english.
Real programmers use butterflies
|
|
|
|
|
- Teacher in Japanese would be sensei
- If Google can be believed, teacher in Chinese (pinyin transliteration) is lǎo shī (which also translates to something like "old master" )
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Yeah I used to take karate, but I forgot what the san suffix meant at the end of the name. Your post sent me to google to look up. It's a title of respect, often used when addressing people in positions of respect, or otherwise formally. Like sir, for example. It would be used by a student addressing a teacher, but does not mean teacher per se. I overstated it on account of bad organic RAM between the ears.
I would have wanted something similar in Chinese, but I have no idea what it would be or if there's an even equivalent way to mangle Sander's name like that.
Real programmers use butterflies
|
|
|
|
|
Observe and learn, my young Padawan.
Your question was "Is that enumeration based on anything other than some arbitrary list of colors microsoft's coders came up with?"
So I thought, well CSS has the same colors and CSS is based on something.
So I googled "where do css named colors come from"
Searching "where do system.drawing named colors come from" gives you the same answer "NET Framework, Windows Forms, and Microsoft Internet Explorer. These colors and their names are based on the UNIX X11 color values."
It sounds almost too simple to work, yet it does
|
|
|
|
|
I know jack about CSS. Some of it comes back to me a little if I stare at it, but I never retain it.
So I wouldn't have made it past your first step.
Real programmers use butterflies
|
|
|
|
|
'Dark, the dark side it is! Very dark!'
'Shut up, Yoda! Get the bread out of the toaster earlier next time!'
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
I love sending you a W3Schools [^] reference !
Aside from it harking to Q&A, therefore legitimizing your posting in The Lounge, it is the second of many consecutive pages of color info. Don't miss out on the others. Many are nice in that they're interactive allowing a gradient of fixed values for your start and end colors.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I found the previous two lists mentioned and after a bit more searching I came across a graphics design company that had a list of over seven hundred shades so I merged the three lists and came up with my own superset. Then I added some macros and have a list I can use with GDI, GDI+, and OpenGL which are the three I work with and have different color schemes. It is unlikely you need the full list so one of the previous two should suffice. I wanted to be a bit more comprehensive.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
One of the nicer things in my list is I made the macros such that one can get a list of the colors in text format which I use to populate lists and combo boxes. I will be happy to share that list and its associated files with you if you want them.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
I would but honestly, I can just add to the generator to get friendly names for the colors. The reason I don't is I'm deadly suspicious of strings in my source code unintentionally winding up in the .text section of my executable even when I think I didn't use them. I'm probably being paranoid about it, but every time I add a string to the source code for this library I go to the asm output on code that doesn't use it just to see that it didn't wind up in the asm.
I also don't even store the facename of fonts for a similar reason. I'm just deathly afraid of string pollution.
The reason it matters is sometimes I'm targeting devices with as little as 256kB of nonvolatile storage and I have to share it with the rest of the firmware.
Real programmers use butterflies
|
|
|
|
|
I understand. That part of the implementation is optional. All parts are really meaning if you never use OpenGL or GDI+ stuff that's OK - comment it out. If you need a different color data format that's OK to - you can redefine the macro. It's redefined for each type of color used and namespaces are used extensively.
I should probably write an article about this stuff some day. It's really helped me a lot.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
|
Perhaps unknowingly, but I am sure you hurt Bob's feelings.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Sander Rossel wrote: what's better than a guinea pig fronted metal band
A Hamster-fronted metal band, of course!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You're right! Unfortunately, that's not included in the list
|
|
|
|
|
Sander Rossel wrote: But let's be honest, what's better than a guinea pig fronted metal band? CatMetal?
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Cattera (a poor word play on Pantera) is included in the list
|
|
|
|
|
Sander Rossel wrote: 8 Best Animal-Fronted Metal Bands[^]
Aren't they all?
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
My advice to you is to run. Now.
Software Zen: delete this;
|
|
|
|
|
Woe 0) Someone in our leadership was sold a bill of goods, and as a result, they're moving our flagship web ASP.Net/ MSSQL app into ServiceNow - an off-the-shelf no/low code system that uses MySql and Angular.
Woe 1) Back in 2019, I spent six months on a MVC5 project template to serve as a basis for a rewrite of all of our apps, which included some database changes to facilitate the "better way" to do some things. We also started redesigning the import/refresh process (the business rules that lives in the database) to normalize the data and use the database correctly (when I started working there, there were very few views, and we have one table with over 600 columns). The actual "woe" came when I realized that during our migration to the cloud, they did NOT migrate the new database code we were working on.
Woe 2) Me and the other contract programmers decided that we would perform parallel development - on our own time - to serve as a fall-back for when the ServiceNow migration fails. To this end, I spent all weekend refactoring the dependency libraries and making the project template compile with the refactored libraries, only to be stopped cold by the fact that the database no longer contains the database components that the template relies on (this is when I discovered Woe 1 above).
I sent an email last night to one of the DBAs to see if by chance they still had the backup, but I'm not very hopeful...
What great work someone did to effectively quash the morale of quite possibly the hardest working person on the team.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
#realJSOP wrote: on our own time Bad.
#realJSOP wrote: I spent all weekend refactoring Worse.
If it ain't paid it ain't work time.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
You and I obviously have a wildly different work ethic.
I like the work (writing code - hell, I do it as a hobby). I just don't like stupid management decisions.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|