Hot Door CORE  0.7.0
Adobe® Illustrator® Plug-in Library
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 "hdicoreArtboardPoint.h"
12 #include "hdicoreSize.h"
13 #include "hdicoreTransformMatrix.h"
14 
15 namespace hdi
16 {
17  namespace plugin
18  {
19  class ArtColor;
20  }
21 
22  namespace core
23  {
24  class Gradient;
25  class Pattern;
26 
32  class ArtColor
33  {
34  public:
38  enum Type
39  {
40  TypeUnknown = 0,
41  // Basic colors
42  TypeNone = 1 << 0,
43  TypeGray = 1 << 1,
44  TypeRGB = 1 << 2,
45  TypeCMYK = 1 << 3,
46  TypeLab = 1 << 4,
47  TypeHSB = 1 << 5, // Same as HSV
48  // "Named" colors
49  TypeNamedRGB = 1 << 10,
50  TypeNamedCMYK = 1 << 11,
51  TypeNamedLab = 1 << 12,
52  // Other
53  TypePattern = 1 << 20,
54  TypeGradient = 1 << 21,
55  // Helpers
56  AnonymousTypes = (TypeGray | TypeRGB | TypeCMYK | TypeLab | TypeHSB),
57  NamedTypes = (TypeNamedRGB | TypeNamedCMYK | TypeNamedLab)
58  };
59 
64  {
65  SpotColor = 1 << 0,
66  RegistrationColor = 1 << 1
67  };
68 
73  class Channels
74  {
75  public:
79  struct RGB
80  {
84  double red;
85 
89  double green;
90 
94  double blue;
95 
101  (RGB)();
102 
110  (RGB)(const RGB& obj_);
111 
121  (RGB)(const double r_, const double g_, const double b_);
122 
128  virtual (~RGB)();
129 
139  RGB& operator=(const RGB& rhs_);
140 
149  bool operator==(const RGB& rhs_) const;
150 
159  bool operator!=(const RGB& rhs_) const;
160  };
161 
162  typedef std::auto_ptr<RGB> RGBAP;
163 
167  struct CMYK
168  {
172  double cyan;
173 
177  double magenta;
178 
182  double yellow;
183 
187  double black;
188 
194  (CMYK)();
195 
203  (CMYK)(const CMYK& obj_);
204 
215  (CMYK)(const double c_, const double m_, const double y_, const double k_);
216 
222  virtual (~CMYK)();
223 
233  CMYK& operator=(const CMYK& rhs_);
234 
243  bool operator==(const CMYK& rhs_) const;
244 
253  bool operator!=(const CMYK& rhs_) const;
254  };
255 
256  typedef std::auto_ptr<CMYK> CMYKAP;
257 
261  struct Lab
262  {
266  double lightness;
267 
271  double a;
272 
276  double b;
277 
283  Lab();
284 
292  Lab(const Lab& obj_);
293 
303  Lab(const double l_, const double a_, const double b_);
304 
310  virtual ~Lab();
311 
321  Lab& operator=(const Lab& rhs_);
322 
331  bool operator==(const Lab& rhs_) const;
332 
341  bool operator!=(const Lab& rhs_) const;
342  };
343 
344  typedef std::auto_ptr<Lab> LabAP;
345 
349  struct HSB
350  {
355 
359  double saturation;
360 
364  double brightness;
365 
371  HSB();
372 
380  HSB(const HSB& obj_);
381 
391  HSB(const Angle& h_, const double s_, const double b_);
392 
398  virtual ~HSB();
399 
409  HSB& operator=(const HSB& rhs_);
410 
419  bool operator==(const HSB& rhs_) const;
420 
429  bool operator!=(const HSB& rhs_) const;
430  };
431 
432  typedef std::auto_ptr<HSB> HSBAP;
433 
440 
444  double gray;
445 
450 
455 
460 
465 
471  Channels();
472 
480  Channels(const Channels& obj_);
481 
494  Channels(
495  const Type master_,
496  const double gray_,
497  const RGB& rgb_,
498  const CMYK& cmyk_,
499  const Lab& lab_,
500  const HSB& hsb_
501  );
502 
508  virtual ~Channels();
509 
519  Channels& operator=(const Channels& rhs_);
520  };
521 
522  typedef std::auto_ptr<Channels> ChannelsAP;
523 
528  {
529  public:
536 
542 
550 
556  double length;
557 
566 
572 
578 
584  GradientStyle();
585 
593  GradientStyle(const GradientStyle& grad_);
594 
609  const core::Gradient& gradient_,
610  const core::ArtboardPoint& origin_,
611  const core::Angle& angle_,
612  const double length_,
613  const core::TransformMatrix& matrix_,
614  const core::Angle& hiliteAngle_,
615  const double hiliteLength_
616  );
617 
623  virtual ~GradientStyle();
624 
634  GradientStyle& operator=(const GradientStyle& rhs_);
635  };
636 
637  typedef std::auto_ptr<GradientStyle> GradientStyleAP;
638 
643  {
644  public:
651 
657 
662 
666  double scaleX;
667 
671  double scaleY;
672 
677 
681  bool reflect;
682 
687 
692 
697 
702 
708  PatternStyle();
709 
717  PatternStyle(const PatternStyle& patt_);
718 
736  PatternStyle(
737  const core::Pattern& pattern_,
738  const double shiftDist_,
739  const core::Angle& shiftAngle_,
740  const double scaleX_,
741  const double scaleY_,
742  const core::Angle& rotation_,
743  const bool reflect_,
744  const core::Angle& reflectAngle_,
745  const core::Angle& shearAngle_,
746  const core::Angle& shearAxis_,
747  const core::TransformMatrix& transform_
748  );
749 
755  virtual ~PatternStyle();
756 
766  PatternStyle& operator=(const PatternStyle& rhs_);
767  };
768 
769  typedef std::auto_ptr<PatternStyle> PatternStyleAP;
770 
778  ArtColor(const ArtColor& c_);
779 
787  ArtColor(const double grayVal_);
788 
798  ArtColor(const double rVal_, const double gVal_, const double bVal_);
799 
810  ArtColor(const double cVal_, const double mVal_, const double yVal_, const double kVal_);
811 
819  ArtColor(const GradientStyle& gs_);
820 
828  ArtColor(const PatternStyle& ps_);
829 
835  ArtColor();
836 
848  static ArtColor FromLab(const double lVal_, const double aVal_, const double bVal_);
849 
859  static ArtColor FromHSB(const Angle& hVal_, const double sVal_, const double bVal_);
860 
866  virtual ~ArtColor();
867 
875  virtual Type colorType() const;
876 
884  virtual std::string name() const;
885 
896  virtual ArtColor asGray() const;
897 
908  virtual ArtColor asRGB() const;
909 
920  virtual ArtColor asLab() const;
921 
932  virtual ArtColor asHSB() const;
933 
944  virtual ArtColor asCMYK() const;
945 
954  virtual Channels channels() const;
955 
964  virtual GradientStyle gradient() const;
965 
974  virtual PatternStyle pattern() const;
975 
994  virtual bool makeNamed(
995  const std::string& name_,
996  const double tint_ = 0.0,
997  const NamedFlags flags_ = SpotColor
998  );
999 
1008  virtual ArtColor& operator=(const ArtColor& rhs_);
1009 
1020  virtual bool operator==(const ArtColor& rhs_) const;
1021 
1032  virtual bool operator!=(const ArtColor& rhs_) const;
1033 
1039  static ArtColor red();
1040 
1046  static ArtColor orange();
1047 
1053  static ArtColor yellow();
1054 
1060  static ArtColor green();
1061 
1067  static ArtColor cyan();
1068 
1074  static ArtColor blue();
1075 
1081  static ArtColor purple();
1082 
1088  static ArtColor magenta();
1089 
1095  static ArtColor white();
1096 
1102  static ArtColor lightGray();
1103 
1109  static ArtColor gray();
1110 
1116  static ArtColor darkGray();
1117 
1123  static ArtColor black();
1124 
1131  static ArtColor none();
1132 
1133 
1134  private:
1135  friend plugin::ArtColor* __accessImpl(const ArtColor&);
1136  friend ArtColor __accessCtor(const plugin::ArtColor&);
1137 
1141  plugin::ArtColor* __impl;
1142 
1148  ArtColor(const plugin::ArtColor&);
1149  };
1150 
1151  typedef std::auto_ptr<ArtColor> ArtColorAP;
1152 
1153  extern plugin::ArtColor* __accessImpl(const ArtColor&);
1154  extern ArtColor __accessCtor(const plugin::ArtColor&);
1155  }
1156 }
1157 
1158 #endif
1159 // __HDI_CORE_ART_COLOR__
bool operator==(const HSB &rhs_) const
Tests whether a given HSB object is the same as another.
virtual ArtColor & operator=(const ArtColor &rhs_)
Allows one ArtColor object to be assigned from another.
Stores all the possible representations of a color-based ArtColor in all supported color models; the ...
Definition: hdicoreArtColor.h:73
virtual ArtColor asRGB() const
Gets the target ArtColor object in an RGB format.
virtual ~GradientStyle()
Destructs a GradientStyle object.
Header file for describing angles.
double scaleX
Fraction to scale the prototype along the x-axis before filling.
Definition: hdicoreArtColor.h:666
core::Angle shearAxis
Axis to shear with respect to.
Definition: hdicoreArtColor.h:696
virtual PatternStyle pattern() const
Gets the underlying pattern for the target ArtColor.
Lab lab
Stores the Lab channels.
Definition: hdicoreArtColor.h:459
double highlightLength
For a radial gradient, the distance of the hilight from the origin expressed as a fraction of the rad...
Definition: hdicoreArtColor.h:577
Describes a set of CMYK channels.
Definition: hdicoreArtColor.h:167
virtual ArtColor asHSB() const
Gets the target ArtColor object in a HSB format.
HSB()
Constructs a HSB object with default values.
double blue
Stores the RGB color blue channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:94
CMYK cmyk
Stores the CMYK channels.
Definition: hdicoreArtColor.h:454
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:549
HSB hsb
Stores the HSB channels.
Definition: hdicoreArtColor.h:464
core::Angle highlightAngle
For a radial gradient, the angle to the blend highlight point. Not used for linear gradients...
Definition: hdicoreArtColor.h:571
Describes a set of Lab channels.
Definition: hdicoreArtColor.h:261
core::Angle shearAngle
Angle to slant the shear by.
Definition: hdicoreArtColor.h:691
double gray
Stores the grayscale color gray channel (0.0 is white, 1.0 is black)
Definition: hdicoreArtColor.h:444
NamedFlags
Option flags for use when creating a named color.
Definition: hdicoreArtColor.h:63
virtual ~ArtColor()
Destructs an ArtColor object.
Lab()
Constructs a Lab object with default values.
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:541
PatternStyle()
Constructs a new PatternStyle object with default values.
virtual ArtColor asGray() const
Gets the target ArtColor object in a grayscale format.
static ArtColor purple()
Static accessor to return an ArtColor object for pure purple.
ArtColor()
Constructs an ArtColor object that hasn't been assigned; that is, a stroke/fill set to "none"...
core::Gradient * gradient
Gradient to which the style applies. The lifetime of the object is only as long as the GradientStyle ...
Definition: hdicoreArtColor.h:535
core::Angle shiftAngle
Angle to translate the unscaled prototype before filling.
Definition: hdicoreArtColor.h:661
Handles general pattern-related functionality.
Definition: hdicorePattern.h:27
double red
Stores the RGB color red channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:84
() RGB()
Constructs an RGB object with default values.
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:650
core::Angle rotation
Angle to rotate the prototype before filling.
Definition: hdicoreArtColor.h:676
Header file for describing a 2D transformation matrix.
Describes a set of HSB channels.
Definition: hdicoreArtColor.h:349
virtual ArtColor asCMYK() const
Gets the target ArtColor object in a CMYK format.
static ArtColor lightGray()
Static accessor to return an ArtColor object for pure white (25% black)
static ArtColor green()
Static accessor to return an ArtColor object for pure green.
virtual ~Lab()
Destructs a Lab object.
Type
Describes the format/type of an ArtColor object.
Definition: hdicoreArtColor.h:38
static ArtColor cyan()
Static accessor to return an ArtColor object for pure cyan.
double yellow
Stores the CMYK color yellow channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:182
virtual ~HSB()
Destructs a HSB object.
() CMYK()
Constructs a CMYK object with default values.
static ArtColor white()
Static accessor to return an ArtColor object for pure white (0% black)
bool operator!=(const CMYK &rhs_) const
Tests whether a given CMYK object is not the same as another.
double scaleY
Fraction to scale the prototype along the y-axis before filling.
Definition: hdicoreArtColor.h:671
bool operator!=(const HSB &rhs_) const
Tests whether a given HSB object is not the same as another.
Angle hue
Stores the HSB color hue channel.
Definition: hdicoreArtColor.h:354
Allows for 2-dimensional transformations in a single application via matrix math. ...
Definition: hdicoreTransformMatrix.h:26
core::TransformMatrix transform
Additional transformation arising from manipulating the path.
Definition: hdicoreArtColor.h:701
static ArtColor FromHSB(const Angle &hVal_, const double sVal_, const double bVal_)
Constructs a HSB ArtColor object from its color components.
CMYK & operator=(const CMYK &rhs_)
CMYK assignment operator.
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:266
core::Angle reflectAngle
Axis around which to reflect.
Definition: hdicoreArtColor.h:686
double brightness
Stores the HSB color brightness channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:364
Header file for describing 2D dimensions (width and height)
static ArtColor none()
Static accessor to return an ArtColor object for "none".
double shiftDistance
Distance to translate the unscaled prototype before filling, measured from the ruler origin...
Definition: hdicoreArtColor.h:656
Header file for geometric point manipulation on the Illustrator artboard.
virtual ~Channels()
Destructs a Channels object.
core::TransformMatrix matrix
The accumulated transformations of the gradient. It is not necessarily the same as the transformation...
Definition: hdicoreArtColor.h:565
static ArtColor magenta()
Static accessor to return an ArtColor object for pure magenta.
HSB & operator=(const HSB &rhs_)
HSB assignment operator.
Channels & operator=(const Channels &rhs_)
Channels assignment operator.
static ArtColor gray()
Static accessor to return an ArtColor object for pure white (50% black)
double magenta
Stores the CMYK color magenta channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:177
double b
Stores the Lab color b-dimension channel, in the range [-1.0,1.0].
Definition: hdicoreArtColor.h:276
static ArtColor darkGray()
Static accessor to return an ArtColor object for pure white (75% black)
Definition: hdicoreaiArray.h:12
virtual bool operator==(const ArtColor &rhs_) const
Allows two ArtColor objects to be compared with the == operator.
virtual ArtColor asLab() const
Gets the target ArtColor object in a Lab format.
Describes a set of RGB channels.
Definition: hdicoreArtColor.h:79
double saturation
Stores the HSB color saturation channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:359
virtual Type colorType() const
Gets the type/format of the color.
bool operator!=(const RGB &rhs_) const
Tests whether a given RGB object is not the same as another.
bool operator==(const CMYK &rhs_) const
Tests whether a given CMYK object is the same as another.
virtual bool operator!=(const ArtColor &rhs_) const
Allows two ArtColor objects to be compared with the != operator.
virtual ~CMYK()
Destructs a CMYK object.
bool operator!=(const Lab &rhs_) const
Tests whether a given Lab object is not the same as another.
static ArtColor blue()
Static accessor to return an ArtColor object for pure blue.
static ArtColor FromLab(const double lVal_, const double aVal_, const double bVal_)
Constructs a Lab ArtColor object from its color components.
Handles general gradient-related functionality.
Definition: hdicoreGradient.h:24
static ArtColor red()
Static accessor to return an ArtColor object for pure red.
double green
Stores the RGB color green channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:89
virtual GradientStyle gradient() const
Gets the underlying gradient style for the target ArtColor.
RGB & operator=(const RGB &rhs_)
RGB assignment operator.
GradientStyle()
Constructs a new GradientStyle object with default values.
Channels()
Constructs a new Channels object with default values.
GradientStyle & operator=(const GradientStyle &rhs_)
GradientStyle assignment operator.
RGB rgb
Stores the RGB channels.
Definition: hdicoreArtColor.h:449
static ArtColor orange()
Static accessor to return an ArtColor object for pure orange.
virtual ~RGB()
Destructs an RGB object.
static ArtColor yellow()
Static accessor to return an ArtColor object for pure yellow.
double a
Stores the Lab color a-dimension channel, in the range [-1.0,1.0].
Definition: hdicoreArtColor.h:271
double cyan
Stores the CMYK color cyan channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:172
Describes a gradient that has been applied to some art.
Definition: hdicoreArtColor.h:527
Lab & operator=(const Lab &rhs_)
Lab assignment operator.
static ArtColor black()
Static accessor to return an ArtColor object for pure white (100% black)
double length
For a linear gradient, the distance in points over which the gradient ramp is applied. The ramp is scaled so that 100% of its value is this length. For a radial gradient, the radius of the containing circle.
Definition: hdicoreArtColor.h:556
Describes an angle, and allows for easy conversion between various units.
Definition: hdicoreAngle.h:25
Describes a point on the Illustrator artboard.
Definition: hdicoreArtboardPoint.h:28
bool reflect
When true, the prototype is reflected before filling.
Definition: hdicoreArtColor.h:681
double black
Stores the CMYK color black channel, in the range [0.0,1.0].
Definition: hdicoreArtColor.h:187
virtual ~PatternStyle()
Destructs a PatternStyle object.
Describes the color of art on the artboard.
Definition: hdicoreArtColor.h:32
virtual Channels channels() const
Gets the underlying channel data for the target ArtColor.
bool operator==(const RGB &rhs_) const
Tests whether a given RGB object is the same as another.
Type master
Stores the "master" type of channel data stored in the target object. The gray, rgb, cmyk, or lab member that matches this member will have the most accurate values as all other members were derived via color conversion.
Definition: hdicoreArtColor.h:439
PatternStyle & operator=(const PatternStyle &rhs_)
PatternStyle assignment operator.
virtual std::string name() const
Gets the name of a custom color.
virtual bool makeNamed(const std::string &name_, const double tint_=0.0, const NamedFlags flags_=SpotColor)
Converts an "anonymous" color to a "named" color.
Describes a pattern that has been applied to some art.
Definition: hdicoreArtColor.h:642