Click here to Skip to main content
15,890,185 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: I'm having a good day! Pin
Mike Hankey26-Apr-21 4:44
mveMike Hankey26-Apr-21 4:44 
GeneralRe: I'm having a good day! Pin
den2k8826-Apr-21 4:49
professionalden2k8826-Apr-21 4:49 
GeneralRe: I'm having a good day! Pin
Mike Hankey26-Apr-21 4:55
mveMike Hankey26-Apr-21 4:55 
GeneralRe: I'm having a good day! Pin
  Forogar  26-Apr-21 5:30
professional  Forogar  26-Apr-21 5:30 
GeneralRe: I'm having a good day! Pin
OriginalGriff26-Apr-21 5:01
mveOriginalGriff26-Apr-21 5:01 
GeneralRe: I'm having a good day! Pin
Mike Hankey26-Apr-21 5:38
mveMike Hankey26-Apr-21 5:38 
GeneralRe: I'm having a good day! Pin
Gary R. Wheeler26-Apr-21 11:05
Gary R. Wheeler26-Apr-21 11:05 
QuestionAnyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
honey the codewitch26-Apr-21 0:37
mvahoney the codewitch26-Apr-21 0:37 
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

C#
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)
C++
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

AnswerRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
Sander Rossel26-Apr-21 0:40
professionalSander Rossel26-Apr-21 0:40 
GeneralRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
honey the codewitch26-Apr-21 0:43
mvahoney the codewitch26-Apr-21 0:43 
GeneralRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
Daniel Pfeffer26-Apr-21 0:47
professionalDaniel Pfeffer26-Apr-21 0:47 
GeneralRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
honey the codewitch26-Apr-21 0:53
mvahoney the codewitch26-Apr-21 0:53 
GeneralRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
Sander Rossel26-Apr-21 0:59
professionalSander Rossel26-Apr-21 0:59 
GeneralRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
honey the codewitch26-Apr-21 1:28
mvahoney the codewitch26-Apr-21 1:28 
GeneralRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
CodeWraith26-Apr-21 2:40
CodeWraith26-Apr-21 2:40 
AnswerRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
W Balboos, GHB26-Apr-21 1:30
W Balboos, GHB26-Apr-21 1:30 
AnswerRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
Rick York26-Apr-21 5:42
mveRick York26-Apr-21 5:42 
AnswerRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
Rick York26-Apr-21 11:19
mveRick York26-Apr-21 11:19 
GeneralRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
honey the codewitch26-Apr-21 11:28
mvahoney the codewitch26-Apr-21 11:28 
GeneralRe: Anyone with some graphics/web design plus .NET experience, maybe you can answer this Pin
Rick York26-Apr-21 14:35
mveRick York26-Apr-21 14:35 
GeneralMy musical genre exploration has gone too far... Pin
Sander Rossel26-Apr-21 0:32
professionalSander Rossel26-Apr-21 0:32 
GeneralRe: My musical genre exploration has gone too far... Pin
W Balboos, GHB26-Apr-21 1:32
W Balboos, GHB26-Apr-21 1:32 
GeneralRe: My musical genre exploration has gone too far... Pin
OriginalGriff26-Apr-21 1:35
mveOriginalGriff26-Apr-21 1:35 
GeneralRe: My musical genre exploration has gone too far... Pin
Sander Rossel26-Apr-21 5:16
professionalSander Rossel26-Apr-21 5:16 
GeneralRe: My musical genre exploration has gone too far... Pin
CodeWraith26-Apr-21 2:34
CodeWraith26-Apr-21 2:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.