<commit_before>// -*- C++ -*-
/* GG is a GUI for SDL and OpenGL.
   Copyright (C) 2003 <NAME>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public License
   as published by the Free Software Foundation; either version 2.1
   of the License, or (at your option) any later version.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.
    
   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA

   If you do not wish to comply with the terms of the LGPL please
   contact the author as other terms are available for a fee.
    
   <NAME>
   <EMAIL> */

/* $Header$ */

/** \file GGClr.h
    Contains the utility class Clr, which represents colors in GG. */

#ifndef _GGClr_h_
#define _GGClr_h_

#ifndef _GGBase_h_
#include "GGBase.h"
#endif

namespace GG {

/** A simple 32-bit structure that can act as a packed 32-bit unsigned integer representation of a RGBA color, a vector of the four
    unsigned bytes that compose an RGBA color, or the individual unsigned bytes "a", "r", "g", and "b", each of which represents a 
    color channel.  You should not use literals to initialize Color objects; depending on the endian-ness of the machine, 
    0x00FFFFFF would be transparent white (little-endian) or opaque yellow (big-endian).*/
struct GG_API Clr
{
    /** \name Structors */ //@{
    Clr();                                                    ///< default ctor
    Clr(Uint32 clr);                                          ///< ctor that constructs a Clr from a 32-bit value packed with the 4 color channels
    explicit Clr(int _r, int _g, int _b, int _a);             ///< ctor that constructs a Clr from four Uint8s that represent the color channels
    explicit Clr(double _r, double _g, double _b, double _a); ///< ctor that constructs a Clr from four doubles that represent the color channels (each must be >= 0.0 and <= 1.0)
    Clr(Uint8 arr[]);                                         ///< ctor that constructs a Clr from an array of at least four Uint8s that represent the color channels
    Clr(double arr[]);                                        ///< ctor that constructs a Clr from an array of at least four doubles that represent the color channels (each must be >= 0.0 and <= 1.0)
    Clr(const XMLElement& elem); ///< ctor that creates a Clr as defined in XMLElement elem. \throw std::invalid_argument May throw std::invalid_argument if \a elem does not encode a Clr object
    //@}
   
    /** \name Accessors */ //@{
    XMLElement XMLEncode() const; ///< returns an XMLElement that encodes this Clr
    XMLElementValidator XMLValidator() const; ///< creates a Validator object that can validate changes in the XML representation of this Clr
    //@}
   
    union {
        Uint32 i;     ///< represents Clr as a packed RGBA color
        Uint8  v[4];  ///< represents Clr as a vector of RGBA components
        struct {
            Uint8 r;   ///< the red channel
            Uint8 g;   ///< the green channel
            Uint8 b;   ///< the blue channel
            Uint8 a;   ///< the alpha channel
        };
    };
};

GG_API inline bool operator==(const Clr& rhs, const Clr& lhs); ///< returns true iff \a rhs and \a lhs are identical

// some useful color constants<commit_msg>Removed inappropriate inline keyword.<commit_after>// -*- C++ -*-
/* GG is a GUI for SDL and OpenGL.
   Copyright (C) 2003 <NAME>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public License
   as published by the Free Software Foundation; either version 2.1
   of the License, or (at your option) any later version.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.
    
   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA

   If you do not wish to comply with the terms of the LGPL please
   contact the author as other terms are available for a fee.
    
   <NAME>
   <EMAIL> */

/* $Header$ */

/** \file GGClr.h
    Contains the utility class Clr, which represents colors in GG. */

#ifndef _GGClr_h_
#define _GGClr_h_

#ifndef _GGBase_h_
#include "GGBase.h"
#endif

namespace GG {

/** A simple 32-bit structure that can act as a packed 32-bit unsigned integer representation of a RGBA color, a vector of the four
    unsigned bytes that compose an RGBA color, or the individual unsigned bytes "a", "r", "g", and "b", each of which represents a 
    color channel.  You should not use literals to initialize Color objects; depending on the endian-ness of the machine, 
    0x00FFFFFF would be transparent white (little-endian) or opaque yellow (big-endian).*/
struct GG_API Clr
{
    /** \name Structors */ //@{
    Clr();                                                    ///< default ctor
    Clr(Uint32 clr);                                          ///< ctor that constructs a Clr from a 32-bit value packed with the 4 color channels
    explicit Clr(int _r, int _g, int _b, int _a);             ///< ctor that constructs a Clr from four Uint8s that represent the color channels
    explicit Clr(double _r, double _g, double _b, double _a); ///< ctor that constructs a Clr from four doubles that represent the color channels (each must be >= 0.0 and <= 1.0)
    Clr(Uint8 arr[]);                                         ///< ctor that constructs a Clr from an array of at least four Uint8s that represent the color channels
    Clr(double arr[]);                                        ///< ctor that constructs a Clr from an array of at least four doubles that represent the color channels (each must be >= 0.0 and <= 1.0)
    Clr(const XMLElement& elem); ///< ctor that creates a Clr as defined in XMLElement elem. \throw std::invalid_argument May throw std::invalid_argument if \a elem does not encode a Clr object
    //@}
   
    /** \name Accessors */ //@{
    XMLElement XMLEncode() const; ///< returns an XMLElement that encodes this Clr
    XMLElementValidator XMLValidator() const; ///< creates a Validator object that can validate changes in the XML representation of this Clr
    //@}
   
    union {
        Uint32 i;     ///< represents Clr as a packed RGBA color
        Uint8  v[4];  ///< represents Clr as a vector of RGBA components
        struct {
            Uint8 r;   ///< the red channel
            Uint8 g;   ///< the green channel
            Uint8 b;   ///< the blue channel
            Uint8 a;   ///< the alpha channel
        };
    };
};

GG_API bool operator==(const Clr& rhs, const Clr& lhs); ///< returns true iff \a rhs and \a lhs are identical

// some useful color constants
{'fraction_non_alphanumeric': 0.07851973235012973, 'fraction_numerical': 0.013928717738631708, 'mean_word_length': 2.3596330275229356, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '178954', 'n_tokens_mistral': 2070, 'n_tokens_neox': 1941, 'n_words': 993}