ai_color.h
1 /*
2  * Arnold API header file
3  * Copyright (c) 1998-2009 Marcos Fajardo, (c) 2009-2013 Solid Angle SL
4  */
5 
11 #pragma once
12 #include "ai_types.h"
13 #include "ai_constants.h"
14 #include "ai_api.h"
15 
23 struct AtRGB
24 {
25  float r, g, b;
26 
27  /*
28  * NOTE: the absence of a constructor is for a reason - it appears that
29  * older versions of C++ don't like union members to have constructors,
30  * and this struct is used in the AtParamValue union
31  */
32 
33  AtRGB operator+(const AtRGB& rgb) const
34  {
35  AtRGB temp;
36  temp.r = r + rgb.r;
37  temp.g = g + rgb.g;
38  temp.b = b + rgb.b;
39  return temp;
40  }
41 
42  AtRGB& operator+=(const AtRGB& rgb)
43  {
44  r += rgb.r;
45  g += rgb.g;
46  b += rgb.b;
47  return *this;
48  }
49 
50  AtRGB operator+(float f) const
51  {
52  AtRGB temp;
53  temp.r = r + f;
54  temp.g = g + f;
55  temp.b = b + f;
56  return temp;
57  }
58 
59  AtRGB& operator+=(float f)
60  {
61  r += f;
62  g += f;
63  b += f;
64  return *this;
65  }
66 
67  AtRGB operator-(const AtRGB& rgb) const
68  {
69  AtRGB temp;
70  temp.r = r - rgb.r;
71  temp.g = g - rgb.g;
72  temp.b = b - rgb.b;
73  return temp;
74  }
75 
76  AtRGB& operator-=(const AtRGB& rgb)
77  {
78  r -= rgb.r;
79  g -= rgb.g;
80  b -= rgb.b;
81  return *this;
82  }
83 
84  AtRGB operator-(float f) const
85  {
86  AtRGB temp;
87  temp.r = r - f;
88  temp.g = g - f;
89  temp.b = b - f;
90  return temp;
91  }
92 
93  AtRGB& operator-=(float f)
94  {
95  r -= f;
96  g -= f;
97  b -= f;
98  return *this;
99  }
100 
101  AtRGB operator-() const
102  {
103  AtRGB temp;
104  temp.r = -r;
105  temp.g = -g;
106  temp.b = -b;
107  return temp;
108  }
109 
110  AtRGB operator*(const AtRGB& rgb) const
111  {
112  AtRGB temp;
113  temp.r = r * rgb.r;
114  temp.g = g * rgb.g;
115  temp.b = b * rgb.b;
116  return temp;
117  }
118 
119  AtRGB operator*=(const AtRGB& rgb)
120  {
121  r *= rgb.r;
122  g *= rgb.g;
123  b *= rgb.b;
124  return *this;
125  }
126 
127  AtRGB operator*(float f) const
128  {
129  AtRGB temp;
130  temp.r = r * f;
131  temp.g = g * f;
132  temp.b = b * f;
133  return temp;
134  }
135 
136  AtRGB operator*=(float f)
137  {
138  r *= f;
139  g *= f;
140  b *= f;
141  return *this;
142  }
143 
144  AtRGB operator/(const AtRGB& rgb) const
145  {
146  AtRGB temp;
147  temp.r = r / rgb.r;
148  temp.g = g / rgb.g;
149  temp.b = b / rgb.b;
150  return temp;
151  }
152 
153  AtRGB operator/=(const AtRGB& rgb)
154  {
155  r /= rgb.r;
156  g /= rgb.g;
157  b /= rgb.b;
158  return *this;
159  }
160 
161  AtRGB operator/(float f) const
162  {
163  AtRGB temp;
164  float inv = 1.0f / f;
165  temp.r = r * inv;
166  temp.g = g * inv;
167  temp.b = b * inv;
168  return temp;
169  }
170 
171  AtRGB operator/=(float f)
172  {
173  float inv = 1.0f / f;
174  r *= inv;
175  g *= inv;
176  b *= inv;
177  return *this;
178  }
179 
180  bool operator==(const AtRGB& rgb) const
181  {
182  return (r == rgb.r && g == rgb.g && b == rgb.b);
183  }
184 
185  bool operator!=(const AtRGB& rgb) const
186  {
187  return !(*this == rgb);
188  }
189 
190  AtRGB& operator=(float f)
191  {
192  r = f;
193  g = f;
194  b = f;
195  return *this;
196  }
197 
198  float& operator[](unsigned int i)
199  {
200  return *(&r + i); // warning: no bounds checking!
201  }
202 
203  const float& operator[](unsigned int i) const
204  {
205  return *(&r + i); // warning: no bounds checking!
206  }
207 
208  friend AtRGB operator*(float f, const AtRGB& rgb);
209  friend AtRGB operator+(float f, const AtRGB& rgb);
210  friend AtRGB operator-(float f, const AtRGB& rgb);
211 };
212 
213 inline AtRGB operator*(float f, const AtRGB& rgb)
214 {
215  return rgb * f;
216 }
217 
218 inline AtRGB operator+(float f, const AtRGB& rgb)
219 {
220  return rgb + f;
221 }
222 
223 inline AtRGB operator-(float f, const AtRGB& rgb)
224 {
225  AtRGB temp;
226  temp.r = f - rgb.r;
227  temp.g = f - rgb.g;
228  temp.b = f - rgb.b;
229  return temp;
230 }
231 
235 typedef AtRGB AtColor;
236 
240 struct AtRGBA
241 {
242  float r, g, b, a;
243 
244  AtRGB& rgb()
245  {
246  return *static_cast<AtRGB*>(static_cast<void*>(this));
247  }
248 
249  const AtRGB& rgb() const
250  {
251  return *static_cast<const AtRGB*>(static_cast<const void*>(this));
252  }
253 
254  /*
255  * NOTE: the absence of a constructor is for a reason - it appears that
256  * older versions of C++ don't like union members to have constructors,
257  * and this struct is used in the AtParamValue union
258  */
259 
260  AtRGBA operator+(const AtRGBA& rgba) const
261  {
262  AtRGBA temp;
263  temp.r = r + rgba.r;
264  temp.g = g + rgba.g;
265  temp.b = b + rgba.b;
266  temp.a = a + rgba.a;
267  return temp;
268  }
269 
270  AtRGBA& operator+=(const AtRGBA& rgba)
271  {
272  r += rgba.r;
273  g += rgba.g;
274  b += rgba.b;
275  a += rgba.a;
276  return *this;
277  }
278 
279  AtRGBA operator+(float f) const
280  {
281  AtRGBA temp;
282  temp.r = r + f;
283  temp.g = g + f;
284  temp.b = b + f;
285  temp.a = a + f;
286  return temp;
287  }
288 
289  AtRGBA& operator+=(float f)
290  {
291  r += f;
292  g += f;
293  b += f;
294  a += f;
295  return *this;
296  }
297 
298  AtRGBA operator-(const AtRGBA& rgba) const
299  {
300  AtRGBA temp;
301  temp.r = r - rgba.r;
302  temp.g = g - rgba.g;
303  temp.b = b - rgba.b;
304  temp.a = a - rgba.a;
305  return temp;
306  }
307 
308  AtRGBA& operator-=(const AtRGBA& rgba)
309  {
310  r -= rgba.r;
311  g -= rgba.g;
312  b -= rgba.b;
313  a -= rgba.a;
314  return *this;
315  }
316 
317  AtRGBA operator-(float f) const
318  {
319  AtRGBA temp;
320  temp.r = r - f;
321  temp.g = g - f;
322  temp.b = b - f;
323  temp.a = a - f;
324  return temp;
325  }
326 
327  AtRGBA& operator-=(float f)
328  {
329  r -= f;
330  g -= f;
331  b -= f;
332  a -= f;
333  return *this;
334  }
335 
336  AtRGBA operator-() const
337  {
338  AtRGBA temp;
339  temp.r = -r;
340  temp.g = -g;
341  temp.b = -b;
342  temp.a = -a;
343  return temp;
344  }
345 
346  AtRGBA operator*(const AtRGBA& rgba) const
347  {
348  AtRGBA temp;
349  temp.r = r * rgba.r;
350  temp.g = g * rgba.g;
351  temp.b = b * rgba.b;
352  temp.a = a * rgba.a;
353  return temp;
354  }
355 
356  AtRGBA operator*=(const AtRGBA& rgba)
357  {
358  r *= rgba.r;
359  g *= rgba.g;
360  b *= rgba.b;
361  a *= rgba.a;
362  return *this;
363  }
364 
365  AtRGBA operator*(float f) const
366  {
367  AtRGBA temp;
368  temp.r = r * f;
369  temp.g = g * f;
370  temp.b = b * f;
371  temp.a = a * f;
372  return temp;
373  }
374 
375  AtRGBA operator*=(float f)
376  {
377  r *= f;
378  g *= f;
379  b *= f;
380  a *= f;
381  return *this;
382  }
383 
384  AtRGBA operator/(const AtRGBA& rgba) const
385  {
386  AtRGBA temp;
387  temp.r = r / rgba.r;
388  temp.g = g / rgba.g;
389  temp.b = b / rgba.b;
390  temp.a = a / rgba.a;
391  return temp;
392  }
393 
394  AtRGBA operator/=(const AtRGBA& rgba)
395  {
396  r /= rgba.r;
397  g /= rgba.g;
398  b /= rgba.b;
399  a /= rgba.a;
400  return *this;
401  }
402 
403  AtRGBA operator/(float f) const
404  {
405  AtRGBA temp;
406  float inv = 1.0f / f;
407  temp.r = r * inv;
408  temp.g = g * inv;
409  temp.b = b * inv;
410  temp.a = a * inv;
411  return temp;
412  }
413 
414  AtRGBA operator/=(float f)
415  {
416  float inv = 1.0f / f;
417  r *= inv;
418  g *= inv;
419  b *= inv;
420  a *= inv;
421  return *this;
422  }
423 
424 
425  bool operator==(const AtRGBA& rgba) const
426  {
427  return (r == rgba.r && g == rgba.g && b == rgba.b && a == rgba.a);
428  }
429 
430  bool operator!=(const AtRGBA& rgba) const
431  {
432  return !(*this == rgba);
433  }
434 
435  AtRGBA& operator=(float f)
436  {
437  r = f;
438  g = f;
439  b = f;
440  a = f;
441  return *this;
442  }
443 
444  float& operator[](unsigned int i)
445  {
446  return *(&r + i); // warning: no bounds checking!
447  }
448 
449  const float& operator[](unsigned int i) const
450  {
451  return *(&r + i); // warning: no bounds checking!
452  }
453  friend AtRGBA operator*(float f, const AtRGBA& rgba);
454  friend AtRGBA operator+(float f, const AtRGBA& rgba);
455  friend AtRGBA operator-(float f, const AtRGBA& rgba);
456 };
457 
458 inline AtRGBA operator*(float f, const AtRGBA& rgba)
459 {
460  return rgba * f;
461 }
462 
463 inline AtRGBA operator+(float f, const AtRGBA& rgba)
464 {
465  return rgba + f;
466 }
467 
468 inline AtRGBA operator-(float f, const AtRGBA& rgba)
469 {
470  AtRGBA temp;
471  temp.r = f - rgba.r;
472  temp.g = f - rgba.g;
473  temp.b = f - rgba.b;
474  temp.a = f - rgba.a;
475  return temp;
476 }
477 
478 
479 
487 inline AtColor AiColor(float f)
488 {
489  AtColor out = {f, f, f};
490  return out;
491 }
492 
496 inline AtColor AiColor(float r, float g, float b)
497 {
498  AtColor out = {r, g, b};
499  return out;
500 }
501 
505 inline AtRGBA AiRGBACreate(const float r, float g, float b, float a)
506 {
507  AtRGBA out = {r, g, b, a};
508  return out;
509 }
510 
514 inline void AiColorReset(AtColor& c)
515 {
516  c.r = 0.f;
517  c.g = 0.f;
518  c.b = 0.f;
519 }
520 
524 inline void AiRGBAReset(AtRGBA& rgba)
525 {
526  rgba.r = 0.f;
527  rgba.g = 0.f;
528  rgba.b = 0.f;
529  rgba.a = 0.f;
530 }
531 
536 inline AtColor AiColorLerp(float t, const AtColor& lo, const AtColor& hi)
537 {
538  AtColor out;
539  out.r = LERP(t, lo.r, hi.r);
540  out.g = LERP(t, lo.g, hi.g);
541  out.b = LERP(t, lo.b, hi.b);
542  return out;
543 }
544 
549 inline AtRGBA AiColorLerp(float t, const AtRGBA& lo, const AtRGBA& hi)
550 {
551  AtRGBA out;
552  out.r = LERP(t, lo.r, hi.r);
553  out.g = LERP(t, lo.g, hi.g);
554  out.b = LERP(t, lo.b, hi.b);
555  out.a = LERP(t, lo.a, hi.a);
556  return out;
557 }
558 
563 inline AtColor AiColorHerp(float t, const AtColor& lo, const AtColor& hi)
564 {
565  AtColor out;
566  out.r = HERP(t, lo.r, hi.r);
567  out.g = HERP(t, lo.g, hi.g);
568  out.b = HERP(t, lo.b, hi.b);
569  return out;
570 }
571 
576 inline AtRGBA AiColorHerp(float t, const AtRGBA& lo, const AtRGBA& hi)
577 {
578  AtRGBA out;
579  out.r = HERP(t, lo.r, hi.r);
580  out.g = HERP(t, lo.g, hi.g);
581  out.b = HERP(t, lo.b, hi.b);
582  out.a = HERP(t, lo.a, hi.a);
583  return out;
584 }
585 
590 inline AtRGBA AiRGBALerp(float t, const AtRGBA& lo, const AtRGBA& hi)
591 {
592  AtRGBA out;
593  out.r = LERP(t, lo.r, hi.r);
594  out.g = LERP(t, lo.g, hi.g);
595  out.b = LERP(t, lo.b, hi.b);
596  out.a = LERP(t, lo.a, hi.a);
597  return out;
598 }
599 
604 inline AtRGBA AiRGBAHerp(float t, const AtRGBA& lo, const AtRGBA& hi)
605 {
606  AtRGBA out;
607  out.r = HERP(t, lo.r, hi.r);
608  out.g = HERP(t, lo.g, hi.g);
609  out.b = HERP(t, lo.b, hi.b);
610  out.a = HERP(t, lo.a, hi.a);
611  return out;
612 }
613 
619 inline AtColor AiColorBiLerp(float s, float t, const AtColor& c00, const AtColor& c10, const AtColor& c01, const AtColor& c11)
620 {
621  return AiColorLerp(s, AiColorLerp(t, c00, c01), AiColorLerp(t, c10, c11));
622 }
623 
629 inline AtColor AiColorBiHerp(float s, float t, const AtColor& c00, const AtColor& c10, const AtColor& c01, const AtColor& c11)
630 {
631  return AiColorHerp(s, AiColorHerp(t, c00, c01), AiColorHerp(t, c10, c11));
632 }
633 
639 inline AtRGBA AiRGBAbiLerp(float s, float t, const AtRGBA& c00, const AtRGBA& c10, const AtRGBA& c01, const AtRGBA& c11)
640 {
641  return AiRGBALerp(s, AiRGBALerp(t, c00, c01), AiRGBALerp(t, c10, c11));
642 }
643 
649 inline AtRGBA AiRGBAbiHerp(float s, float t, const AtRGBA& c00, const AtRGBA& c10, const AtRGBA& c01, const AtRGBA& c11)
650 {
651  return AiRGBAHerp(s, AiRGBAHerp(t, c00, c01), AiRGBAHerp(t, c10, c11));
652 }
653 
657 inline AtColor AiColorClamp(const AtColor& c, float lo, float hi)
658 {
659  AtColor out;
660  out.r = CLAMP(c.r, lo, hi);
661  out.g = CLAMP(c.g, lo, hi);
662  out.b = CLAMP(c.b, lo, hi);
663  return out;
664 }
665 
669 inline AtRGBA AiRGBAClamp(const AtRGBA& c, float lo, float hi)
670 {
671  AtRGBA out;
672  out.r = CLAMP(c.r, lo, hi);
673  out.g = CLAMP(c.g, lo, hi);
674  out.b = CLAMP(c.b, lo, hi);
675  out.a = CLAMP(c.a, lo, hi);
676  return out;
677 }
678 
682 inline void AiColorClipToZero(AtColor& c)
683 {
684  c.r = MAX(0.0f, c.r);
685  c.g = MAX(0.0f, c.g);
686  c.b = MAX(0.0f, c.b);
687 }
688 
692 inline bool AiColorIsSmall(const AtRGB& c, float epsilon = AI_EPSILON)
693 {
694  return ABS(c.r) < epsilon && ABS(c.g) < epsilon && ABS(c.b) < epsilon;
695 }
696 
700 #define AiColorIsZero AiColorIsSmall
701 
705 inline bool AiColorEqual(const AtColor& a, const AtColor& b)
706 {
707  return (a.r == b.r) && (a.g == b.g) && (a.b == b.b);
708 }
709 
713 inline bool AiColorEqual(const AtRGBA& a, const AtRGBA& b)
714 {
715  return (a.r == b.r) && (a.g == b.g) && (a.b == b.b);
716 }
717 
721 inline AtColor AiColorABS(const AtColor& c)
722 {
723  AtColor out;
724  out.r = ABS(c.r);
725  out.g = ABS(c.g);
726  out.b = ABS(c.b);
727  return out;
728 }
729 
733 inline AtRGBA AiColorABS(const AtRGBA& c)
734 {
735  AtRGBA out;
736  out.r = ABS(c.r);
737  out.g = ABS(c.g);
738  out.b = ABS(c.b);
739  out.a = ABS(c.a);
740  return out;
741 }
742 
746 inline float AiColorMaxRGB(const AtColor& c)
747 {
748  return MAX3(c.r, c.g, c.b);
749 }
750 
754 inline float AiColorMaxRGB(const AtRGBA& c)
755 {
756  return MAX3(c.r, c.g, c.b);
757 }
758 
762 inline bool AiColorThreshold(const AtColor& c1, const AtColor& c2, float t)
763 {
764  return ABS(c1.r - c2.r) >= t || ABS(c1.g - c2.g) >= t || ABS(c1.b - c2.b) >= t;
765 }
766 
770 inline AtColor AiRGBAtoRGB(const AtRGBA& rgba)
771 {
772  AtColor out;
773  out.r = rgba.r;
774  out.g = rgba.g;
775  out.b = rgba.b;
776  return out;
777 }
778 
782 inline AtRGBA AiRGBtoRGBA(const AtColor& c)
783 {
784  AtRGBA out;
785  out.r = c.r;
786  out.g = c.g;
787  out.b = c.b;
788  out.a = 1.f;
789  return out;
790 }
791 
795 inline float AiColorToGrey(const AtColor& c)
796 {
797  return (c.r + c.g + c.b) / 3;
798 }
799 
803 inline float AiColorToGrey(const AtRGBA& rgba)
804 {
805  return (rgba.r + rgba.g + rgba.b) / 3;
806 }
807 
811 AI_API bool AiRGBCorrupted(const AtRGB& rgba);
812 
816 AI_API bool AiRGBACorrupted(const AtRGBA& rgba);
817 
821 inline bool AiColorCorrupted(const AtColor& c)
822 {
823  return AiRGBCorrupted(c);
824 }
825 
829 inline bool AiColorCorrupted(const AtRGBA& rgba)
830 {
831  return AiRGBACorrupted(rgba);
832 }
833 
837 inline AtColor AiBerpRGB(float a, float b, const AtColor& c0, const AtColor& c1, const AtColor& c2)
838 {
839  float c = 1 - (a+b);
840  return c*c0 + a*c1 + b*c2;
841 }
842 
843 AI_API void AiColorGamma(AtColor* color, float gamma);
844 AI_API void AiRGBAGamma(AtRGBA* color, float gamma);
845 AI_API AtColor AiColorHeatMap(const AtColor* map_colors, const float* map_values, unsigned int map_length, float lookup);
846 
847 /*\}*/
848 
853 inline void AiColorLerp(AtColor& out, float t, const AtColor& lo, const AtColor& hi)
854 {
855  out = AiColorLerp(t, lo, hi);
856 }
857 
858 inline void AiColorLerp(AtRGBA& out, float t, const AtRGBA& lo, const AtRGBA& hi)
859 {
860  //out = AiColorLerp(t, lo, hi);
861  // this would overwrite out.a, unlike the macro we are replacing,
862  // so let's do it in a bit more convoluted but safer way:
863 
864  AtRGBA temp = AiColorLerp(t, lo, hi);
865  out.r = temp.r;
866  out.g = temp.g;
867  out.b = temp.b;
868 }
869 
870 inline void AiColorLerp(AtColor& out, float t, const AtRGBA& lo, const AtRGBA& hi)
871 {
872  AtRGBA temp = AiColorLerp(t, lo, hi);
873  out.r = temp.r;
874  out.g = temp.g;
875  out.b = temp.b;
876 }
877 
878 inline void AiColorHerp(AtColor& out, float t, const AtColor& lo, const AtColor& hi)
879 {
880  out = AiColorHerp(t, lo, hi);
881 }
882 
883 inline void AiColorHerp(AtRGBA& out, float t, const AtRGBA& lo, const AtRGBA& hi)
884 {
885  //out = AiColorHerp(t, lo, hi);
886  // this would overwrite out.a, unlike the macro we are replacing,
887  // so let's do it in a bit more convoluted but safer way:
888 
889  AtRGBA temp = AiColorHerp(t, lo, hi);
890  out.r = temp.r;
891  out.g = temp.g;
892  out.b = temp.b;
893 }
894 
895 inline void AiRGBALerp(AtRGBA& out, float t, const AtRGBA& lo, const AtRGBA& hi)
896 {
897  out = AiRGBALerp(t, lo, hi);
898 }
899 
900 inline void AiRGBAHerp(AtRGBA& out, float t, const AtRGBA& lo, const AtRGBA& hi)
901 {
902  out = AiRGBAHerp(t, lo, hi);
903 }
904 
905 inline void AiColorBiLerp(AtColor& out, float s, float t, const AtColor& c00, const AtColor& c10, const AtColor& c01, const AtColor& c11)
906 {
907  out = AiColorBiLerp(s, t, c00, c10, c01, c11);
908 }
909 
910 inline void AiColorBiHerp(AtColor& out, float s, float t, const AtColor& c00, const AtColor& c10, const AtColor& c01, const AtColor& c11)
911 {
912  out = AiColorBiHerp(s, t, c00, c10, c01, c11);
913 }
914 
915 inline void AiRGBAbiLerp(AtRGBA& out, float s, float t, const AtRGBA& c00, const AtRGBA& c10, const AtRGBA& c01, const AtRGBA& c11)
916 {
917  out = AiRGBAbiLerp(s, t, c00, c10, c01, c11);
918 }
919 
920 inline void AiRGBAbiHerp(AtRGBA& out, float s, float t, const AtRGBA& c00, const AtRGBA& c10, const AtRGBA& c01, const AtRGBA& c11)
921 {
922  out = AiRGBAbiHerp(s, t, c00, c10, c01, c11);
923 }
924 
925 inline void AiColorClamp(AtColor& out, const AtColor& c, float lo, float hi)
926 {
927  out = AiColorClamp(c, lo, hi);
928 }
929 
930 inline void AiRGBAClamp(AtRGBA& out, const AtRGBA& c, float lo, float hi)
931 {
932  out = AiRGBAClamp(c, lo, hi);
933 }
934 
935 inline void AiColorABS(AtColor& out, const AtColor& c)
936 {
937  out = AiColorABS(c);
938 }
939 
940 inline void AiColorABS(AtRGBA& out, const AtRGBA& c)
941 {
942  // out = AiColorABS(c);
943  // this would overwrite out.a, unlike the macro we are replacing,
944  // so let's do it in a bit more convoluted but safer way:
945 
946  AtRGBA temp = AiColorABS(c);
947  out.r = temp.r;
948  out.g = temp.g;
949  out.b = temp.b;
950 }
951 
952 inline void AiRGBAtoRGB(const AtRGBA& rgba, AtColor& out)
953 {
954  out = AiRGBAtoRGB(rgba);
955 }
956 
957 inline void AiRGBtoRGBA(const AtColor& c, AtRGBA& out)
958 {
959  out = AiRGBtoRGBA(c);
960 }
961 
962 inline void AiBerpRGB(float a, float b, const AtColor& c0, const AtColor& c1, const AtColor& c2, AtColor& out)
963 {
964  out = AiBerpRGB(a, b, c0, c1, c2);
965 }
966 
967 // Use the identical (but shorter) AiColor() instead
968 inline AtColor AiColorCreate(float r, float g, float b)
969 {
970  AtColor out = {r, g, b};
971  return out;
972 }
973 
974 inline void AiColorCreate(AtColor& out, float r, float g, float b)
975 {
976  out.r = r;
977  out.g = g;
978  out.b = b;
979 }
980 
981 inline void AiRGBACreate(AtRGBA& out, float r, float g, float b, float a)
982 {
983  out.r = r;
984  out.g = g;
985  out.b = b;
986  out.a = a;
987 }
988 
989 inline void AiColorAdd(AtColor& a, const AtColor& b, const AtColor& c)
990 {
991  a = b + c;
992 }
993 
994 inline void AiColorSub(AtColor& a, const AtColor& b, const AtColor& c)
995 {
996  a = b - c;
997 }
998 
999 inline void AiColorScale(AtColor& a, const AtColor& b, float k)
1000 {
1001  a = b * k;
1002 }
1003 
1004 inline void AiColorAddScale(AtColor& a, const AtColor& b, const AtColor& c, float k)
1005 {
1006  a = b + c * k;
1007 }
1008 
1009 inline void AiColorMult(AtColor& a, const AtColor& b, const AtColor& c)
1010 {
1011  a = b * c;
1012 }
1013 
1014 inline void AiColorDiv(AtColor& a, const AtColor& b, const AtColor& c)
1015 {
1016  a = b / c;
1017 }
1018 
1019 /*\}*/
1020 
1024 AI_API AtRGB AI_RGB_BLACK;
1025 AI_API AtRGB AI_RGB_RED;
1026 AI_API AtRGB AI_RGB_GREEN;
1027 AI_API AtRGB AI_RGB_BLUE;
1028 AI_API AtRGB AI_RGB_50GREY;
1029 AI_API AtRGB AI_RGB_WHITE;
1030 
1031 AI_API AtRGBA AI_RGBA_BLACK;
1032 AI_API AtRGBA AI_RGBA_RED;
1033 AI_API AtRGBA AI_RGBA_GREEN;
1034 AI_API AtRGBA AI_RGBA_BLUE;
1035 AI_API AtRGBA AI_RGBA_50GREY;
1036 AI_API AtRGBA AI_RGBA_WHITE;
1037 /*\}*/
1038 
1039 /*\}*/

© 2009-2013 Solid Angle SL · all rights reserved · www.solidangle.com