Hot Door CORE 0.8.2
Adobe® Illustrator® Plug-in Library
Loading...
Searching...
No Matches
hdicoreArtColor.h
Go to the documentation of this file.
1
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 #if defined(HDI_CORE_AIP_MODE)
30 class Gradient;
31 class Pattern;
32 #endif
33
40 {
41 public:
45 enum Type
46 {
47 TypeUnknown = 0,
48
49 // Basic colors
50 TypeNone = 1 << 0,
51 TypeGray = 1 << 1,
52 TypeRGB = 1 << 2,
53 TypeCMYK = 1 << 3,
54 TypeLab = 1 << 4,
55 TypeHSB = 1 << 5, // Same as HSV
56
57 #if defined(HDI_CORE_AIP_MODE)
58 // "Named" colors
59 TypeNamedRGB = 1 << 10,
60 TypeNamedCMYK = 1 << 11,
61 TypeNamedLab = 1 << 12,
62
63 // Other
64 TypePattern = 1 << 20,
65 TypeGradient = 1 << 21,
66 #endif
67 // HDI_CORE_AIP_MODE
68
69 // Helpers
70 AnonymousTypes = (TypeGray | TypeRGB | TypeCMYK | TypeLab | TypeHSB),
71
72 #if defined(HDI_CORE_AIP_MODE)
73 NamedTypes = (TypeNamedRGB | TypeNamedCMYK | TypeNamedLab)
74 #endif
75 };
76
77 #if defined(HDI_CORE_AIP_MODE)
82 {
83 NoFlag = 0,
84 SpotColorFlag = 1 << 0,
85 RegistrationColorFlag = 1 << 1
86 };
87 #endif
88 // HDI_CORE_AIP_MODE
89
95 {
96 public:
100 struct RGB
101 {
105 double red;
106
110 double green;
111
115 double blue;
116
122 (RGB)();
123
131 (RGB)(const RGB& obj_);
132
142 (RGB)(const double r_, const double g_, const double b_);
143
149 virtual (~RGB)();
150
160 RGB& operator=(const RGB& rhs_);
161
170 bool operator==(const RGB& rhs_) const;
171
180 bool operator!=(const RGB& rhs_) const;
181 };
182
183 typedef std::unique_ptr<RGB> RGBUP;
184 typedef std::shared_ptr<RGB> RGBSP;
185 typedef std::weak_ptr<RGB> RGBWP;
186
190 struct CMYK
191 {
195 double cyan;
196
200 double magenta;
201
205 double yellow;
206
210 double black;
211
217 (CMYK)();
218
226 (CMYK)(const CMYK& obj_);
227
238 (CMYK)(const double c_, const double m_, const double y_, const double k_);
239
245 virtual (~CMYK)();
246
256 CMYK& operator=(const CMYK& rhs_);
257
266 bool operator==(const CMYK& rhs_) const;
267
276 bool operator!=(const CMYK& rhs_) const;
277 };
278
279 typedef std::unique_ptr<CMYK> CMYKUP;
280 typedef std::shared_ptr<CMYK> CMYKSP;
281 typedef std::weak_ptr<CMYK> CMYKWP;
282
286 struct Lab
287 {
291 double lightness;
292
296 double a;
297
301 double b;
302
309
317 Lab(const Lab& obj_);
318
328 Lab(const double l_, const double a_, const double b_);
329
335 virtual ~Lab();
336
346 Lab& operator=(const Lab& rhs_);
347
356 bool operator==(const Lab& rhs_) const;
357
366 bool operator!=(const Lab& rhs_) const;
367 };
368
369 typedef std::unique_ptr<Lab> LabUP;
370 typedef std::shared_ptr<Lab> LabSP;
371 typedef std::weak_ptr<Lab> LabWP;
372
376 struct HSB
377 {
382
387
392
399
407 HSB(const HSB& obj_);
408
418 HSB(const Angle& h_, const double s_, const double b_);
419
425 virtual ~HSB();
426
436 HSB& operator=(const HSB& rhs_);
437
446 bool operator==(const HSB& rhs_) const;
447
456 bool operator!=(const HSB& rhs_) const;
457 };
458
459 typedef std::unique_ptr<HSB> HSBUP;
460 typedef std::shared_ptr<HSB> HSBSP;
461 typedef std::weak_ptr<HSB> HSBWP;
462
469
473 double gray;
474
479
484
489
494
501
509 Channels(const Channels& obj_);
510
524 const Type master_,
525 const double gray_,
526 const RGB& rgb_,
527 const CMYK& cmyk_,
528 const Lab& lab_,
529 const HSB& hsb_
530 );
531
537 virtual ~Channels();
538
549 };
550
551 typedef std::unique_ptr<Channels> ChannelsUP;
552 typedef std::shared_ptr<Channels> ChannelsSP;
553 typedef std::weak_ptr<Channels> ChannelsWP;
554
555 #if defined(HDI_CORE_AIP_MODE)
560 {
561 public:
568
574
582
588 double length;
589
598
604
610
617
626
641 const core::Gradient& gradient_,
642 const core::ArtboardPoint& origin_,
643 const core::Angle& angle_,
644 const double length_,
645 const core::TransformMatrix& matrix_,
646 const core::Angle& hiliteAngle_,
647 const double hiliteLength_
648 );
649
655 virtual ~GradientStyle();
656
667 };
668
669 typedef std::unique_ptr<GradientStyle> GradientStyleUP;
670 typedef std::shared_ptr<GradientStyle> GradientStyleSP;
671 typedef std::weak_ptr<GradientStyle> GradientStyleWP;
672
677 {
678 public:
685
691
696
700 double scaleX;
701
705 double scaleY;
706
711
716
721
726
731
736
743
752
771 const core::Pattern& pattern_,
772 const double shiftDist_,
773 const core::Angle& shiftAngle_,
774 const double scaleX_,
775 const double scaleY_,
776 const core::Angle& rotation_,
777 const bool reflect_,
778 const core::Angle& reflectAngle_,
779 const core::Angle& shearAngle_,
780 const core::Angle& shearAxis_,
781 const core::TransformMatrix& transform_
782 );
783
789 virtual ~PatternStyle();
790
801 };
802
803 typedef std::unique_ptr<PatternStyle> PatternStyleUP;
804 typedef std::shared_ptr<PatternStyle> PatternStyleSP;
805 typedef std::weak_ptr<PatternStyle> PatternStyleWP;
806 #endif
807 // HDI_CORE_AIP_MODE
808
816 ArtColor(const ArtColor& c_);
817
825 ArtColor(const double grayVal_);
826
836 ArtColor(const double rVal_, const double gVal_, const double bVal_);
837
848 ArtColor(const double cVal_, const double mVal_, const double yVal_, const double kVal_);
849
850 #if defined(HDI_CORE_AIP_MODE)
859
868 #endif
869 // HDI_CORE_AIP_MODE
870
880
892 static ArtColor FromLab(const double lVal_, const double aVal_, const double bVal_);
893
903 static ArtColor FromHSB(const Angle& hVal_, const double sVal_, const double bVal_);
904
910 virtual ~ArtColor();
911
912 #if defined(HDI_CORE_PSP_MODE)
920 virtual bool isEmpty() const;
921 #endif
922 // HDI_CORE_PSP_MODE
923
931 virtual Type colorType() const;
932
933 #if defined(HDI_CORE_AIP_MODE)
941 virtual std::string name() const;
942 #endif
943 // HDI_CORE_AIP_MODE
944
955 virtual ArtColor asGray() const;
956
967 virtual ArtColor asRGB() const;
968
979 virtual ArtColor asLab() const;
980
991 virtual ArtColor asHSB() const;
992
1003 virtual ArtColor asCMYK() const;
1004
1013 virtual Channels channels() const;
1014
1015 #if defined(HDI_CORE_AIP_MODE)
1024 virtual GradientStyle gradient() const;
1025
1034 virtual PatternStyle pattern() const;
1035
1053 virtual bool makeNamed(
1054 const std::string& name_,
1055 const double tint_ = 0.0,
1056 const NamedFlags flags_ = SpotColorFlag
1057 );
1058
1066 virtual double namedTint() const;
1067
1076 virtual NamedFlags namedFlags() const;
1077 #endif
1078 // HDI_CORE_AIP_MODE
1079
1088 virtual ArtColor& operator=(const ArtColor& rhs_);
1089
1100 virtual bool operator==(const ArtColor& rhs_) const;
1101
1112 virtual bool operator!=(const ArtColor& rhs_) const;
1113
1119 static ArtColor red();
1120
1127
1134
1140 static ArtColor green();
1141
1147 static ArtColor cyan();
1148
1154 static ArtColor blue();
1155
1162
1169
1175 static ArtColor white();
1176
1183
1189 static ArtColor gray();
1190
1197
1203 static ArtColor black();
1204
1211 static ArtColor none();
1212
1213 #if defined(HDI_CORE_PSP_MODE)
1247 static bool fastConvert8(
1248 const Type from_,
1249 const uint8_t in1_,
1250 const uint8_t in2_,
1251 const uint8_t in3_,
1252 const uint8_t in4_,
1253 const Type to_,
1254 uint8_t& out1_,
1255 uint8_t& out2_,
1256 uint8_t& out3_,
1257 uint8_t& out4_
1258 );
1259
1293 static bool fastConvert16(
1294 const Type from_,
1295 const uint16_t in1_,
1296 const uint16_t in2_,
1297 const uint16_t in3_,
1298 const uint16_t in4_,
1299 const Type to_,
1300 uint16_t& out1_,
1301 uint16_t& out2_,
1302 uint16_t& out3_,
1303 uint16_t& out4_
1304 );
1305
1328 static bool fastConvertBitmap8(
1329 const Type from_,
1330 const Type to_,
1331 uint32_t* const bitmap__,
1332 const uint32_t nPixels_
1333 );
1334
1357 static bool fastConvertBitmap16(
1358 const Type from_,
1359 const Type to_,
1360 uint64_t* const bitmap__,
1361 const uint32_t nPixels_
1362 );
1363 #endif
1364 // HDI_CORE_PSP_MODE
1365
1366
1367 private:
1368 #if defined(HDI_CORE_AIP_MODE)
1369 friend aip::ArtColor* __accessImpl(const ArtColor&);
1370 friend ArtColor __accessCtor(const aip::ArtColor&);
1371
1375 aip::ArtColor* __impl;
1376
1382 ArtColor(const aip::ArtColor&);
1383 #elif defined(HDI_CORE_PSP_MODE)
1387 void* __impl;
1388 #endif
1389 };
1390
1391 typedef std::unique_ptr<ArtColor> ArtColorUP;
1392 typedef std::shared_ptr<ArtColor> ArtColorSP;
1393 typedef std::weak_ptr<ArtColor> ArtColorWP;
1394
1395 #if defined(HDI_CORE_AIP_MODE)
1396 extern aip::ArtColor* __accessImpl(const ArtColor&);
1397 extern ArtColor __accessCtor(const aip::ArtColor&);
1398 #endif
1399 // HDI_CORE_AIP_MODE
1400 }
1401}
1402
1403#if defined(HDI_CORE_AIP_MODE)
1407 );
1408
1412 );
1413#endif
1414// HDI_CORE_AIP_MODE
1415
1416#endif
1417// __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:95
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:483
virtual ~Channels()
Destructs a Channels object.
Lab lab
Stores the Lab channels.
Definition: hdicoreArtColor.h:488
Type master
Stores the "master" type of channel data stored in the target object. The gray, rgb,...
Definition: hdicoreArtColor.h:468
double gray
Stores the grayscale color gray channel (0.0 is white, 1.0 is black)
Definition: hdicoreArtColor.h:473
HSB hsb
Stores the HSB channels.
Definition: hdicoreArtColor.h:493
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:478
Describes a gradient that has been applied to some art.
Definition: hdicoreArtColor.h:560
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:603
core::Gradient * gradient
Gradient to which the style applies. The lifetime of the object is only as long as the GradientStyle ...
Definition: hdicoreArtColor.h:567
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:588
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:597
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:581
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:573
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:609
Describes a pattern that has been applied to some art.
Definition: hdicoreArtColor.h:677
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:735
core::Angle reflectAngle
Axis around which to reflect.
Definition: hdicoreArtColor.h:720
virtual ~PatternStyle()
Destructs a PatternStyle object.
core::Angle shearAxis
Axis to shear with respect to.
Definition: hdicoreArtColor.h:730
core::Angle shearAngle
Angle to slant the shear by.
Definition: hdicoreArtColor.h:725
core::Angle rotation
Angle to rotate the prototype before filling.
Definition: hdicoreArtColor.h:710
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:715
double scaleY
Fraction to scale the prototype along the y-axis before filling.
Definition: hdicoreArtColor.h:705
double scaleX
Fraction to scale the prototype along the x-axis before filling.
Definition: hdicoreArtColor.h:700
double shiftDistance
Distance to translate the unscaled prototype before filling, measured from the ruler origin.
Definition: hdicoreArtColor.h:690
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:684
core::Angle shiftAngle
Angle to translate the unscaled prototype before filling.
Definition: hdicoreArtColor.h:695
Describes the color of art on the artboard.
Definition: hdicoreArtColor.h:40
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:82
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:46
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....
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
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:191
double black
Stores the CMYK color black channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:210
() CMYK()
Constructs a CMYK object with default values.
virtual ~CMYK()
Destructs a CMYK object.
double cyan
Stores the CMYK color cyan channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:195
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:200
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:205
Describes a set of HSB channels.
Definition: hdicoreArtColor.h:377
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:381
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:386
double brightness
Stores the HSB color brightness channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:391
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:287
double a
Stores the Lab color a-dimension channel, in the range [-1.0,1.0].
Definition: hdicoreArtColor.h:296
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:291
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:301
Lab()
Constructs a Lab object with default values.
Describes a set of RGB channels.
Definition: hdicoreArtColor.h:101
double red
Stores the RGB color red channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:105
bool operator!=(const RGB &rhs_) const
Tests whether a given RGB object is not the same as another.
virtual ~RGB()
Destructs an RGB object.
double blue
Stores the RGB color blue channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:115
RGB & operator=(const RGB &rhs_)
RGB assignment operator.
() RGB()
Constructs an RGB object with default values.
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:110