diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-12-03 03:54:21 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-12-03 03:54:21 +0000 |
commit | d8497022d7566dfeaca92ed7db1af58412409dae (patch) | |
tree | b19d210773d987df75686d720505c687b95db6f4 /Build/source/texk/dvisvgm/dvisvgm-src/src/Color.h | |
parent | dfaf3df32ca4a228b4bd4e44f6cb3c040b206a69 (diff) |
Import dvisvgm 1.12.
git-svn-id: svn://tug.org/texlive/trunk@39005 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/Color.h')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-src/src/Color.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Color.h b/Build/source/texk/dvisvgm/dvisvgm-src/src/Color.h new file mode 100644 index 00000000000..fe7000897d0 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Color.h @@ -0,0 +1,98 @@ +/************************************************************************* +** Color.h ** +** ** +** This file is part of dvisvgm -- the DVI to SVG converter ** +** Copyright (C) 2005-2015 Martin Gieseking <martin.gieseking@uos.de> ** +** ** +** This program is free software; you can redistribute it and/or ** +** modify it under the terms of the GNU General Public License as ** +** published by the Free Software Foundation; either version 3 of ** +** the License, or (at your option) any later version. ** +** ** +** This program 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 General Public License for more details. ** +** ** +** You should have received a copy of the GNU General Public License ** +** along with this program; if not, see <http://www.gnu.org/licenses/>. ** +*************************************************************************/ + +#ifndef DVISVGM_COLOR_H +#define DVISVGM_COLOR_H + +#include <string> +#include <valarray> +#include <vector> +#include "types.h" +#include "VectorIterator.h" + +#ifdef TRANSPARENT +#undef TRANSPARENT +#endif + +class Color +{ + public: + static bool SUPPRESS_COLOR_NAMES; + static const Color BLACK; + static const Color WHITE; + static const Color TRANSPARENT; + + enum ColorSpace {GRAY_SPACE, RGB_SPACE, CMYK_SPACE, LAB_SPACE}; + + public: + Color () : _rgb(0) {} + Color (UInt32 rgb) : _rgb(rgb) {} + Color (UInt8 r, UInt8 g, UInt8 b) {setRGB(r,g,b);} + Color (double r, double g, double b) {setRGB(r,g,b);} + Color (const std::valarray<double> &rgb) {setRGB(rgb);} + Color (const char *name); + Color (const std::string &name); +// Color (ColorSpace colorSpace, std::vector<double>::const_iterator &it) {set(colorSpace, it);} + operator UInt32 () const {return _rgb;} + bool operator == (const Color &c) const {return _rgb == c._rgb;} + bool operator != (const Color &c) const {return _rgb != c._rgb;} + void setRGB (UInt8 r, UInt8 g, UInt8 b) {_rgb = (r << 16) | (g << 8) | b;} + void setRGB (double r, double g, double b); + void setRGB (const std::valarray<double> &rgb) {setRGB(rgb[0], rgb[1], rgb[2]);} + bool setPSName (std::string name, bool case_sensitive=true); + void setGray (UInt8 g) {setRGB(g,g,g);} + void setGray (double g) {setRGB(g,g,g);} + void setGray (const std::valarray<double> &gray) {setRGB(gray[0], gray[0], gray[0]);} + void setHSB (double h, double s, double b); + void setCMYK (double c, double m, double y, double k); + void setCMYK (const std::valarray<double> &cmyk); + void setXYZ (double x, double y, double z); + void setXYZ (const std::valarray<double> &xyz); + void setLab (double l, double a, double b); + void setLab (const std::valarray<double> &lab); + void set (ColorSpace colorSpace, VectorIterator<double> &it); + double getGray () const; + void getGray (std::valarray<double> &gray) const; + void getRGB (double &r, double &g, double &b) const; + void getRGB (std::valarray<double> &rgb) const; + void getCMYK (double &c, double &m, double &y, double &k) const; + void getCMYK (std::valarray<double> &cmyk) const; + void getXYZ (double &x, double &y, double &z) const; + void getLab (double &l, double &a, double &b) const; + void getLab (std::valarray<double> &lab) const; + void operator *= (double c); + double deltaE (const Color &c) const; + std::string rgbString () const; + std::string svgColorString (bool rgbonly) const; + std::string svgColorString () const {return svgColorString(SUPPRESS_COLOR_NAMES);} + static void CMYK2RGB (const std::valarray<double> &cmyk, std::valarray<double> &rgb); + static void RGB2CMYK (const std::valarray<double> &rgb, std::valarray<double> &cmyk); + static void HSB2RGB (const std::valarray<double> &hsb, std::valarray<double> &rgb); + static void RGB2XYZ (std::valarray<double> rgb, std::valarray<double> &xyz); + static void XYZ2RGB (const std::valarray<double> &xyz, std::valarray<double> &rgb); + static void RGB2Lab (const std::valarray<double> &rgb, std::valarray<double> &lab); + static void Lab2XYZ (const std::valarray<double> &lab, std::valarray<double> &xyz); + static int numComponents (ColorSpace colorSpace); + + private: + UInt32 _rgb; +}; + +#endif |