Hot Door CORE 0.8.4
Adobe® Illustrator® Plug-in Library
Loading...
Searching...
No Matches
hdicoreArtColor.h
Go to the documentation of this file.
1
6
7#ifndef __HDI_CORE_ART_COLOR__
8#define __HDI_CORE_ART_COLOR__
9
10#include "hdicoreAngle.h"
11#include "hdicoreSize.h"
12
13#if defined(HDI_CORE_AIP_MODE)
14 #include "hdicoreArtboardPoint.h"
16#endif
17
18namespace hdi
19{
20 #if defined(HDI_CORE_AIP_MODE)
21 namespace aip
22 {
23 class ArtColor;
24 }
25 #endif
26
27 namespace core
28 {
29 class Color;
30
31 #if defined(HDI_CORE_AIP_MODE)
32 class Gradient;
33 class Pattern;
34 #endif
35
42 {
43 public:
47 enum Type
48 {
49 TypeUnknown = 0,
50
51 // Basic colors
52 TypeNone = 1 << 0,
53 TypeGray = 1 << 1,
54 TypeRGB = 1 << 2,
55 TypeCMYK = 1 << 3,
56 TypeLab = 1 << 4,
57 TypeHSB = 1 << 5, // Same as HSV
58
59 #if defined(HDI_CORE_AIP_MODE)
60 // "Named" colors
61 TypeNamedRGB = 1 << 10,
62 TypeNamedCMYK = 1 << 11,
63 TypeNamedLab = 1 << 12,
64
65 // Other
66 TypePattern = 1 << 20,
67 TypeGradient = 1 << 21,
68 #endif
69 // HDI_CORE_AIP_MODE
70
71 // Helpers
72 AnonymousTypes = (TypeGray | TypeRGB | TypeCMYK | TypeLab | TypeHSB),
73
74 #if defined(HDI_CORE_AIP_MODE)
75 NamedTypes = (TypeNamedRGB | TypeNamedCMYK | TypeNamedLab)
76 #endif
77 };
78
79 #if defined(HDI_CORE_AIP_MODE)
84 {
85 NoFlag = 0,
86 SpotColorFlag = 1 << 0,
87 RegistrationColorFlag = 1 << 1
88 };
89 #endif
90 // HDI_CORE_AIP_MODE
91
97 {
98 public:
102 struct RGB
103 {
107 double red;
108
112 double green;
113
117 double blue;
118
124 (RGB)();
125
133 (RGB)(const RGB& obj_);
134
144 (RGB)(const double r_, const double g_, const double b_);
145
151 virtual (~RGB)();
152
162 RGB& operator=(const RGB& rhs_);
163
172 bool operator==(const RGB& rhs_) const;
173
182 bool operator!=(const RGB& rhs_) const;
183 };
184
185 typedef std::unique_ptr<RGB> RGBUP;
186 typedef std::shared_ptr<RGB> RGBSP;
187 typedef std::weak_ptr<RGB> RGBWP;
188
192 struct CMYK
193 {
197 double cyan;
198
202 double magenta;
203
207 double yellow;
208
212 double black;
213
219 (CMYK)();
220
228 (CMYK)(const CMYK& obj_);
229
240 (CMYK)(const double c_, const double m_, const double y_, const double k_);
241
247 virtual (~CMYK)();
248
258 CMYK& operator=(const CMYK& rhs_);
259
268 bool operator==(const CMYK& rhs_) const;
269
278 bool operator!=(const CMYK& rhs_) const;
279 };
280
281 typedef std::unique_ptr<CMYK> CMYKUP;
282 typedef std::shared_ptr<CMYK> CMYKSP;
283 typedef std::weak_ptr<CMYK> CMYKWP;
284
288 struct Lab
289 {
293 double lightness;
294
298 double a;
299
303 double b;
304
311
319 Lab(const Lab& obj_);
320
330 Lab(const double l_, const double a_, const double b_);
331
337 virtual ~Lab();
338
348 Lab& operator=(const Lab& rhs_);
349
358 bool operator==(const Lab& rhs_) const;
359
368 bool operator!=(const Lab& rhs_) const;
369 };
370
371 typedef std::unique_ptr<Lab> LabUP;
372 typedef std::shared_ptr<Lab> LabSP;
373 typedef std::weak_ptr<Lab> LabWP;
374
378 struct HSB
379 {
384
389
394
401
409 HSB(const HSB& obj_);
410
420 HSB(const Angle& h_, const double s_, const double b_);
421
427 virtual ~HSB();
428
438 HSB& operator=(const HSB& rhs_);
439
448 bool operator==(const HSB& rhs_) const;
449
458 bool operator!=(const HSB& rhs_) const;
459 };
460
461 typedef std::unique_ptr<HSB> HSBUP;
462 typedef std::shared_ptr<HSB> HSBSP;
463 typedef std::weak_ptr<HSB> HSBWP;
464
471
475 double gray;
476
481
486
491
496
503
511 Channels(const Channels& obj_);
512
526 const Type master_,
527 const double gray_,
528 const RGB& rgb_,
529 const CMYK& cmyk_,
530 const Lab& lab_,
531 const HSB& hsb_
532 );
533
539 virtual ~Channels();
540
551 };
552
553 typedef std::unique_ptr<Channels> ChannelsUP;
554 typedef std::shared_ptr<Channels> ChannelsSP;
555 typedef std::weak_ptr<Channels> ChannelsWP;
556
557 #if defined(HDI_CORE_AIP_MODE)
562 {
563 public:
570
576
584
590 double length;
591
600
606
612
619
628
643 const core::Gradient& gradient_,
644 const core::ArtboardPoint& origin_,
645 const core::Angle& angle_,
646 const double length_,
647 const core::TransformMatrix& matrix_,
648 const core::Angle& hiliteAngle_,
649 const double hiliteLength_
650 );
651
657 virtual ~GradientStyle();
658
669 };
670
671 typedef std::unique_ptr<GradientStyle> GradientStyleUP;
672 typedef std::shared_ptr<GradientStyle> GradientStyleSP;
673 typedef std::weak_ptr<GradientStyle> GradientStyleWP;
674
679 {
680 public:
687
693
698
702 double scaleX;
703
707 double scaleY;
708
713
718
723
728
733
738
745
754
773 const core::Pattern& pattern_,
774 const double shiftDist_,
775 const core::Angle& shiftAngle_,
776 const double scaleX_,
777 const double scaleY_,
778 const core::Angle& rotation_,
779 const bool reflect_,
780 const core::Angle& reflectAngle_,
781 const core::Angle& shearAngle_,
782 const core::Angle& shearAxis_,
783 const core::TransformMatrix& transform_
784 );
785
791 virtual ~PatternStyle();
792
803 };
804
805 typedef std::unique_ptr<PatternStyle> PatternStyleUP;
806 typedef std::shared_ptr<PatternStyle> PatternStyleSP;
807 typedef std::weak_ptr<PatternStyle> PatternStyleWP;
808 #endif
809 // HDI_CORE_AIP_MODE
810
818 ArtColor(const ArtColor& c_);
819
829 ArtColor(const Color& c_);
830
838 ArtColor(const double grayVal_);
839
849 ArtColor(const double rVal_, const double gVal_, const double bVal_);
850
861 ArtColor(const double cVal_, const double mVal_, const double yVal_, const double kVal_);
862
863 #if defined(HDI_CORE_AIP_MODE)
872
881 #endif
882 // HDI_CORE_AIP_MODE
883
893
904 static ArtColor FromLab(const double lVal_, const double aVal_, const double bVal_);
905
917 static ArtColor FromHSB(const Angle& hVal_, const double sVal_, const double bVal_);
918
924 virtual ~ArtColor();
925
926 #if defined(HDI_CORE_PSP_MODE)
934 virtual bool isEmpty() const;
935 #endif
936 // HDI_CORE_PSP_MODE
937
945 virtual Type colorType() const;
946
947 #if defined(HDI_CORE_AIP_MODE)
955 virtual std::string name() const;
956 #endif
957 // HDI_CORE_AIP_MODE
958
969 virtual ArtColor asGray() const;
970
981 virtual ArtColor asRGB() const;
982
993 virtual ArtColor asLab() const;
994
1005 virtual ArtColor asHSB() const;
1006
1017 virtual ArtColor asCMYK() const;
1018
1027 virtual Channels channels() const;
1028
1029 #if defined(HDI_CORE_AIP_MODE)
1038 virtual GradientStyle gradient() const;
1039
1048 virtual PatternStyle pattern() const;
1049
1067 virtual bool makeNamed(
1068 const std::string& name_,
1069 const double tint_ = 0.0,
1070 const NamedFlags flags_ = SpotColorFlag
1071 );
1072
1080 virtual double namedTint() const;
1081
1090 virtual NamedFlags namedFlags() const;
1091 #endif
1092 // HDI_CORE_AIP_MODE
1093
1102 virtual ArtColor& operator=(const ArtColor& rhs_);
1103
1114 virtual bool operator==(const ArtColor& rhs_) const;
1115
1126 virtual bool operator!=(const ArtColor& rhs_) const;
1127
1135 static ArtColor red();
1136
1145
1154
1162 static ArtColor green();
1163
1171 static ArtColor cyan();
1172
1180 static ArtColor blue();
1181
1190
1199
1207 static ArtColor white();
1208
1217
1225 static ArtColor gray();
1226
1235
1243 static ArtColor black();
1244
1253 static ArtColor none();
1254
1255 #if defined(HDI_CORE_PSP_MODE)
1289 static bool fastConvert8(
1290 const Type from_,
1291 const uint8_t in1_,
1292 const uint8_t in2_,
1293 const uint8_t in3_,
1294 const uint8_t in4_,
1295 const Type to_,
1296 uint8_t& out1_,
1297 uint8_t& out2_,
1298 uint8_t& out3_,
1299 uint8_t& out4_
1300 );
1301
1335 static bool fastConvert16(
1336 const Type from_,
1337 const uint16_t in1_,
1338 const uint16_t in2_,
1339 const uint16_t in3_,
1340 const uint16_t in4_,
1341 const Type to_,
1342 uint16_t& out1_,
1343 uint16_t& out2_,
1344 uint16_t& out3_,
1345 uint16_t& out4_
1346 );
1347
1370 static bool fastConvertBitmap8(
1371 const Type from_,
1372 const Type to_,
1373 uint32_t* const bitmap__,
1374 const uint32_t nPixels_
1375 );
1376
1399 static bool fastConvertBitmap16(
1400 const Type from_,
1401 const Type to_,
1402 uint64_t* const bitmap__,
1403 const uint32_t nPixels_
1404 );
1405 #endif
1406 // HDI_CORE_PSP_MODE
1407
1408
1409 private:
1410 #if defined(HDI_CORE_AIP_MODE)
1411 friend aip::ArtColor* __accessImpl(const ArtColor&);
1412 friend ArtColor __accessCtor(const aip::ArtColor&);
1413
1417 aip::ArtColor* __impl;
1418
1424 ArtColor(const aip::ArtColor&);
1425 #elif defined(HDI_CORE_PSP_MODE)
1429 void* __impl;
1430 #endif
1431 };
1432
1433 typedef std::unique_ptr<ArtColor> ArtColorUP;
1434 typedef std::shared_ptr<ArtColor> ArtColorSP;
1435 typedef std::weak_ptr<ArtColor> ArtColorWP;
1436
1437 #if defined(HDI_CORE_AIP_MODE)
1438 extern aip::ArtColor* __accessImpl(const ArtColor&);
1439 extern ArtColor __accessCtor(const aip::ArtColor&);
1440 #endif
1441 // HDI_CORE_AIP_MODE
1442 }
1443}
1444
1445#if defined(HDI_CORE_AIP_MODE)
1449 );
1450
1454 );
1455#endif
1456// HDI_CORE_AIP_MODE
1457
1458#endif
1459// __HDI_CORE_ART_COLOR__
Describes an angle, and allows for easy conversion between various units.
Definition hdicoreAngle.h:26
Stores all the possible representations of a color-based ArtColor in all supported color models; the ...
Definition hdicoreArtColor.h:97
Channels & operator=(const Channels &rhs_)
Channels assignment operator.
Channels()
Constructs a new Channels object with default values.
CMYK cmyk
Stores the CMYK channels.
Definition hdicoreArtColor.h:485
virtual ~Channels()
Destructs a Channels object.
Lab lab
Stores the Lab channels.
Definition hdicoreArtColor.h:490
Type master
Stores the "master" type of channel data stored in the target object. The gray, rgb,...
Definition hdicoreArtColor.h:470
double gray
Stores the grayscale color gray channel (0.0 is white, 1.0 is black).
Definition hdicoreArtColor.h:475
HSB hsb
Stores the HSB channels.
Definition hdicoreArtColor.h:495
Channels(const Type master_, const double gray_, const RGB &rgb_, const CMYK &cmyk_, const Lab &lab_, const HSB &hsb_)
Constructs a new Channels object with the given values.
Channels(const Channels &obj_)
Constructs a new Channels object from an existing Channels.
RGB rgb
Stores the RGB channels.
Definition hdicoreArtColor.h:480
Describes a gradient that has been applied to some art.
Definition hdicoreArtColor.h:562
GradientStyle & operator=(const GradientStyle &rhs_)
GradientStyle assignment operator.
core::Angle highlightAngle
For a radial gradient, the angle to the blend highlight point. Not used for linear gradients.
Definition hdicoreArtColor.h:605
core::Gradient * gradient
Gradient to which the style applies. The lifetime of the object is only as long as the GradientStyle ...
Definition hdicoreArtColor.h:569
GradientStyle(const core::Gradient &gradient_, const core::ArtboardPoint &origin_, const core::Angle &angle_, const double length_, const core::TransformMatrix &matrix_, const core::Angle &hiliteAngle_, const double hiliteLength_)
Constructs a new GradientStyle object with the given values.
double length
For a linear gradient, the distance in points over which the gradient ramp is applied....
Definition hdicoreArtColor.h:590
GradientStyle(const GradientStyle &grad_)
Constructs a new GradientStyle object from an existing GradientStyle.
GradientStyle()
Constructs a new GradientStyle object with default values.
core::TransformMatrix matrix
The accumulated transformations of the gradient. It is not necessarily the same as the transformation...
Definition hdicoreArtColor.h:599
core::Angle angle
For a linear gradient, the angle of the gradient in degrees from the X axis. The ramp extends from th...
Definition hdicoreArtColor.h:583
core::ArtboardPoint origin
For a linear gradient, the origin of the gradient in page coordinates, which is 0 on the gradient ram...
Definition hdicoreArtColor.h:575
virtual ~GradientStyle()
Destructs a GradientStyle object.
double highlightLength
For a radial gradient, the distance of the hilight from the origin expressed as a fraction of the rad...
Definition hdicoreArtColor.h:611
Describes a pattern that has been applied to some art.
Definition hdicoreArtColor.h:679
PatternStyle(const PatternStyle &patt_)
Constructs a new PatternStyle object from an existing PatternStyle.
core::TransformMatrix transform
Additional transformation arising from manipulating the path.
Definition hdicoreArtColor.h:737
core::Angle reflectAngle
Axis around which to reflect.
Definition hdicoreArtColor.h:722
virtual ~PatternStyle()
Destructs a PatternStyle object.
core::Angle shearAxis
Axis to shear with respect to.
Definition hdicoreArtColor.h:732
core::Angle shearAngle
Angle to slant the shear by.
Definition hdicoreArtColor.h:727
core::Angle rotation
Angle to rotate the prototype before filling.
Definition hdicoreArtColor.h:712
PatternStyle(const core::Pattern &pattern_, const double shiftDist_, const core::Angle &shiftAngle_, const double scaleX_, const double scaleY_, const core::Angle &rotation_, const bool reflect_, const core::Angle &reflectAngle_, const core::Angle &shearAngle_, const core::Angle &shearAxis_, const core::TransformMatrix &transform_)
Constructs a new PatternStyle object with the given values.
PatternStyle()
Constructs a new PatternStyle object with default values.
bool reflect
When true, the prototype is reflected before filling.
Definition hdicoreArtColor.h:717
double scaleY
Fraction to scale the prototype along the y-axis before filling.
Definition hdicoreArtColor.h:707
double scaleX
Fraction to scale the prototype along the x-axis before filling.
Definition hdicoreArtColor.h:702
double shiftDistance
Distance to translate the unscaled prototype before filling, measured from the ruler origin.
Definition hdicoreArtColor.h:692
PatternStyle & operator=(const PatternStyle &rhs_)
PatternStyle assignment operator.
core::Pattern * pattern
Pattern to which the style applies. The lifetime of the object is only as long as the PatternStyle wh...
Definition hdicoreArtColor.h:686
core::Angle shiftAngle
Angle to translate the unscaled prototype before filling.
Definition hdicoreArtColor.h:697
Describes the color of art on the artboard.
Definition hdicoreArtColor.h:42
static ArtColor purple()
Static accessor to return an ArtColor object for pure purple.
virtual bool operator==(const ArtColor &rhs_) const
Allows two ArtColor objects to be compared with the == operator.
virtual GradientStyle gradient() const
Gets the underlying gradient style for the target ArtColor.
NamedFlags
Option flags for use when creating a named color.
Definition hdicoreArtColor.h:84
virtual ArtColor & operator=(const ArtColor &rhs_)
Allows one ArtColor object to be assigned from another.
static ArtColor cyan()
Static accessor to return an ArtColor object for pure cyan.
virtual ArtColor asGray() const
Gets the target ArtColor object in a grayscale format.
static ArtColor FromHSB(const Angle &hVal_, const double sVal_, const double bVal_)
Constructs a HSB ArtColor object from its color components.
virtual std::string name() const
Gets the name of a custom color.
virtual ArtColor asCMYK() const
Gets the target ArtColor object in a CMYK format.
static ArtColor red()
Static accessor to return an ArtColor object for pure red.
Type
Describes the format/type of an ArtColor object.
Definition hdicoreArtColor.h:48
static ArtColor darkGray()
Static accessor to return an ArtColor object for pure white (75% black).
static ArtColor FromLab(const double lVal_, const double aVal_, const double bVal_)
Constructs a Lab ArtColor object from its color components.
virtual NamedFlags namedFlags() const
Gets the flags for a "named" color, if any.
virtual bool makeNamed(const std::string &name_, const double tint_=0.0, const NamedFlags flags_=SpotColorFlag)
Converts an "anonymous" color to a "named" color.
static ArtColor none()
Static accessor to return an ArtColor object for "none".
virtual ArtColor asRGB() const
Gets the target ArtColor object in an RGB format.
ArtColor(const ArtColor &c_)
Constructs an ArtColor object from an existing ArtColor object (copy constructor).
virtual ~ArtColor()
Destructs an ArtColor object.
static ArtColor yellow()
Static accessor to return an ArtColor object for pure yellow.
ArtColor()
Constructs an ArtColor object that hasn't been assigned.
ArtColor(const double cVal_, const double mVal_, const double yVal_, const double kVal_)
Constructs a CMYK ArtColor object from four color components in the range [0.0,1.0].
static ArtColor blue()
Static accessor to return an ArtColor object for pure blue.
static ArtColor black()
Static accessor to return an ArtColor object for pure white (100% black).
ArtColor(const double rVal_, const double gVal_, const double bVal_)
Constructs an RGB ArtColor object from three color components in the range [0.0,1....
ArtColor(const Color &c_)
Constructs an ArtColor object from an existing Color object.
virtual ArtColor asLab() const
Gets the target ArtColor object in a Lab format.
virtual double namedTint() const
Gets the tint for a "named" color, if any.
static ArtColor magenta()
Static accessor to return an ArtColor object for pure magenta.
static ArtColor gray()
Static accessor to return an ArtColor object for pure white (50% black).
static ArtColor lightGray()
Static accessor to return an ArtColor object for pure white (25% black).
virtual Type colorType() const
Gets the type/format of the color.
static ArtColor green()
Static accessor to return an ArtColor object for pure green.
ArtColor(const double grayVal_)
Constructs a grayscale ArtColor object from a single color component in the range [0....
virtual PatternStyle pattern() const
Gets the underlying pattern for the target ArtColor.
virtual bool operator!=(const ArtColor &rhs_) const
Allows two ArtColor objects to be compared with the != operator.
static ArtColor white()
Static accessor to return an ArtColor object for pure white (0% black).
ArtColor(const PatternStyle &ps_)
Constructs an ArtColor object from a PatternStyle.
virtual ArtColor asHSB() const
Gets the target ArtColor object in a HSB format.
static ArtColor orange()
Static accessor to return an ArtColor object for pure orange.
ArtColor(const GradientStyle &gs_)
Constructs an ArtColor object from a GradientStyle.
virtual Channels channels() const
Gets the underlying channel data for the target ArtColor.
Describes a point on the Illustrator artboard.
Definition hdicoreArtboardPoint.h:31
Describes an RGB color, with opacity, typically for UI purposes.
Definition hdicoreColor.h:34
Handles general gradient-related functionality.
Definition hdicoreGradient.h:27
Handles general pattern-related functionality.
Definition hdicorePattern.h:30
Allows for 2-dimensional transformations in a single application via matrix math.
Definition hdicoreTransformMatrix.h:34
Header file for describing angles.
Header file for geometric point manipulation on the Illustrator artboard.
Header file for describing 2D dimensions (width and height).
Header file for describing a 2D transformation matrix.
Describes a set of CMYK channels.
Definition hdicoreArtColor.h:193
CMYK()
Constructs a CMYK object with default values.
double black
Stores the CMYK color black channel, in the range [0.0,1.0].
Definition hdicoreArtColor.h:212
double cyan
Stores the CMYK color cyan channel, in the range [0.0,1.0].
Definition hdicoreArtColor.h:197
bool operator==(const CMYK &rhs_) const
Tests whether a given CMYK object is the same as another.
double magenta
Stores the CMYK color magenta channel, in the range [0.0,1.0].
Definition hdicoreArtColor.h:202
CMYK & operator=(const CMYK &rhs_)
CMYK assignment operator.
bool operator!=(const CMYK &rhs_) const
Tests whether a given CMYK object is not the same as another.
double yellow
Stores the CMYK color yellow channel, in the range [0.0,1.0].
Definition hdicoreArtColor.h:207
Describes a set of HSB channels.
Definition hdicoreArtColor.h:379
virtual ~HSB()
Destructs a HSB object.
HSB & operator=(const HSB &rhs_)
HSB assignment operator.
Angle hue
Stores the HSB color hue channel.
Definition hdicoreArtColor.h:383
bool operator==(const HSB &rhs_) const
Tests whether a given HSB object is the same as another.
HSB()
Constructs a HSB object with default values.
bool operator!=(const HSB &rhs_) const
Tests whether a given HSB object is not the same as another.
double saturation
Stores the HSB color saturation channel, in the range [0.0,1.0].
Definition hdicoreArtColor.h:388
double brightness
Stores the HSB color brightness channel, in the range [0.0,1.0].
Definition hdicoreArtColor.h:393
HSB(const HSB &obj_)
Constructs a new HSB object from an existing HSB.
HSB(const Angle &h_, const double s_, const double b_)
Constructs a new HSB object with the given values.
Describes a set of Lab channels.
Definition hdicoreArtColor.h:289
double a
Stores the Lab color a-dimension channel, in the range [-1.0,1.0].
Definition hdicoreArtColor.h:298
Lab(const double l_, const double a_, const double b_)
Constructs a new Lab object with the given values.
bool operator==(const Lab &rhs_) const
Tests whether a given Lab object is the same as another.
double lightness
Stores the Lab color lightness channel, in the range [0.0,1.0].
Definition hdicoreArtColor.h:293
bool operator!=(const Lab &rhs_) const
Tests whether a given Lab object is not the same as another.
Lab & operator=(const Lab &rhs_)
Lab assignment operator.
Lab(const Lab &obj_)
Constructs a new Lab object from an existing Lab.
virtual ~Lab()
Destructs a Lab object.
double b
Stores the Lab color b-dimension channel, in the range [-1.0,1.0].
Definition hdicoreArtColor.h:303
Lab()
Constructs a Lab object with default values.
Describes a set of RGB channels.
Definition hdicoreArtColor.h:103
double red
Stores the RGB color red channel, in the range [0.0,1.0].
Definition hdicoreArtColor.h:107
bool operator!=(const RGB &rhs_) const
Tests whether a given RGB object is not the same as another.
RGB()
Constructs an RGB object with default values.
double blue
Stores the RGB color blue channel, in the range [0.0,1.0].
Definition hdicoreArtColor.h:117
RGB & operator=(const RGB &rhs_)
RGB assignment operator.
bool operator==(const RGB &rhs_) const
Tests whether a given RGB object is the same as another.
double green
Stores the RGB color green channel, in the range [0.0,1.0].
Definition hdicoreArtColor.h:112