aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs/SkColor_Reference.bmh
blob: cc6f10c4f1d845b0fb467c9caeb167690453d0a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
#Topic Color
#Alias Color_Reference ##

#File
Types, consts, functions, and macros for colors.
##

#Subtopic Overview
#Populate
##

#Subtopic Define
#Populate
##

Color constants can be helpful to write code, documenting the meaning of values
the represent transparency and color values. The use of Color constants is not
required.

#Subtopic Constant
#Populate
##

#Subtopic Function
#Populate
##

#Subtopic Typedef
#Populate
##

# ------------------------------------------------------------------------------

#Subtopic Alpha

Alpha represents the transparency of Color. Color with Alpha of zero is fully
transparent. Color with Alpha of 255 is fully opaque. Some, but not all pixel
formats contain Alpha. Pixels with Alpha may store it as unsigned integers or
floating point values. Unsigned integer Alpha ranges from zero, fully
transparent, to all bits set, fully opaque. Floating point Alpha ranges from
zero, fully transparent, to one, fully opaque.

#Alias Alpha 
#Substitute alpha
##

#Typedef uint8_t SkAlpha
#Line # defines Alpha as eight bits ##

#Code
typedef uint8_t SkAlpha;
##

8-bit type for an alpha value. 255 is 100% opaque, zero is 100% transparent.

#Typedef ##

#Subtopic ##

# ------------------------------------------------------------------------------

#Typedef uint32_t SkColor
#Line # defines Color as 32 bits ##

#Code
typedef uint32_t SkColor;
##

32-bit ARGB Color value, Unpremultiplied. Color components are always in
a known order. This is different from SkPMColor, which has its bytes in a configuration
dependent order, to match the format of kBGRA_8888_SkColorType bitmaps. SkColor
is the type used to specify colors in SkPaint and in gradients.

Color that is Premultiplied has the same component values as Color
that is Unpremultiplied if Alpha is 255, fully opaque, although may have the
component values in a different order.

#SeeAlso SkPMColor

#Typedef ##

# ------------------------------------------------------------------------------

#Method static constexpr inline SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#In Function
#Line # returns Color_Alpha and RGB combined ##

Returns Color value from 8-bit component values. Asserts if SK_DEBUG is defined
if a, r, g, or b exceed 255. Since Color is Unpremultiplied, a may be smaller
than the largest of r, g, and b.

#Param a    amount of Alpha, from fully transparent (0) to fully opaque (255) ##
#Param r    amount of red, from no red (0) to full red (255) ##
#Param g    amount of green, from no green (0) to full green (255) ##
#Param b    amount of blue, from no blue (0) to full blue (255) ##

#Return color and alpha, Unpremultiplied ##

#Example
    canvas->drawColor(SK_ColorRED);
    canvas->clipRect(SkRect::MakeWH(150, 150));
    canvas->drawColor(SkColorSetARGB(0x80, 0x00, 0xFF, 0x00));
    canvas->clipRect(SkRect::MakeWH(75, 75));
    canvas->drawColor(SkColorSetARGB(0x80, 0x00, 0x00, 0xFF));
##

#SeeAlso SkColorSetRGB SkPaint::setARGB SkPaint::setColor SkColorSetA

#Method ##

# ------------------------------------------------------------------------------

#Define SkColorSetRGB
#Line # returns opaque Color ##

#Code
###$
    #define SkColorSetRGB(r, g, b)  SkColorSetARGB(0xFF, r, g, b)
$$$#
##

Returns Color value from 8-bit component values, with Alpha set
fully opaque to 255.

#Param r    amount of red, from no red (0) to full red (255) ##
#Param g    amount of green, from no green (0) to full green (255) ##
#Param b    amount of blue, from no blue (0) to full blue (255) ##

#Return     color with opaque alpha ##

#Example
    canvas->drawColor(SK_ColorRED);
    canvas->clipRect(SkRect::MakeWH(150, 150));
    canvas->drawColor(SkColorSetRGB(0x00, 0xFF, 0x00));
    canvas->clipRect(SkRect::MakeWH(75, 75));
    canvas->drawColor(SkColorSetRGB(0x00, 0x00, 0xFF));
##

#SeeAlso SkColorSetARGB 

#Define ##

# ------------------------------------------------------------------------------

#Define SkColorGetA
#Line # returns Alpha component ##

#Code
###$
    #define SkColorGetA(color)      (((color) >> 24) & 0xFF)
$$$#
##

Returns Alpha byte from Color value.

#Param color SkColor, a 32-bit unsigned int, in 0xAARRGGBB format ##

#Example
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setColor(SK_ColorRED);
    for (int alpha = 255; alpha >= 0; alpha -= 17) {
        paint.setAlpha(alpha);
        canvas->drawRect({5, 5, 100, 20}, paint);
        SkAlpha alphaInPaint = SkColorGetA(paint.getColor());
        canvas->drawString(std::to_string(alphaInPaint).c_str(), 110, 18, paint);
        canvas->translate(0, 15);
    }
##

#SeeAlso SkPaint::getAlpha

#Define ##

# ------------------------------------------------------------------------------

#Define SkColorGetR
#Line # returns red component ##

#Code
###$
    #define SkColorGetR(color)      (((color) >> 16) & 0xFF)
$$$#
##

Returns red component of Color, from zero to 255.

#Param color SkColor, a 32-bit unsigned int, in 0xAARRGGBB format ##
#Return red byte ##

#Example
#Image 3
   canvas->drawBitmap(source, 0, 0);
   SkPaint bgPaint;
   bgPaint.setColor(0xafffffff);
   canvas->drawRect({20, 50, 80, 70}, bgPaint);
   uint8_t red = SkColorGetR(source.getColor(226, 128));
   canvas->drawString(std::to_string(red).c_str(), 40, 65, SkPaint());
   canvas->drawLine(80, 70, 226, 128, SkPaint());
##

#SeeAlso SkColorGetG SkColorGetB

#Define ##

# ------------------------------------------------------------------------------

#Define SkColorGetG
#Line # returns green component ##

#Code
###$
    #define SkColorGetG(color)      (((color) >>  8) & 0xFF)
$$$#
##

Returns green component of Color, from zero to 255.

#Param color SkColor, a 32-bit unsigned int, in 0xAARRGGBB format ##
#Return green byte ##

#Example
#Image 3
   canvas->drawBitmap(source, 0, 0);
   SkPaint bgPaint;
   bgPaint.setColor(0xafffffff);
   canvas->drawRect({20, 50, 80, 70}, bgPaint);
   uint8_t green = SkColorGetG(source.getColor(57, 192));
   canvas->drawString(std::to_string(green).c_str(), 40, 65, SkPaint());
   canvas->drawLine(80, 70, 57, 192, SkPaint());
##

#SeeAlso SkColorGetR SkColorGetB

#Define ##

# ------------------------------------------------------------------------------

#Define SkColorGetB
#Line # returns blue component ##

#Code
###$
    #define SkColorGetB(color)      (((color) >>  0) & 0xFF)
$$$#
##

Returns blue component of Color, from zero to 255.

#Param color SkColor, a 32-bit unsigned int, in 0xAARRGGBB format ##
#Return blue byte ##

#Example
#Image 3
   canvas->drawBitmap(source, 0, 0);
   SkPaint bgPaint;
   bgPaint.setColor(0xafffffff);
   canvas->drawRect({20, 50, 80, 70}, bgPaint);
   uint8_t blue = SkColorGetB(source.getColor(168, 170));
   canvas->drawString(std::to_string(blue).c_str(), 40, 65, SkPaint());
   canvas->drawLine(80, 70, 168, 170, SkPaint());
##

#SeeAlso SkColorGetR SkColorGetG

#Define ##

# ------------------------------------------------------------------------------

#Method static constexpr inline SkColor SkColorSetA(SkColor c, U8CPU a)
#In Function
#Line # returns Color with transparency ##

Returns Unpremultiplied Color with red, blue, and green set from c; and alpha set
from a. Alpha component of c is ignored and is replaced by a in result.

#Param c  packed RGB, eight bits per component ##
#Param a  Alpha: transparent at zero, fully opaque at 255 ##

#Return Color with transparency ##

#Example
#Image 3
   canvas->drawBitmap(source, 0, 0);
   for (int y = 0; y < 256; y += 16) {
      for (int x = 0; x < 256; x += 16) {
        SkColor color = source.getColor(x + 8, y + 8);
        SkPaint paint;
        paint.setColor(SkColorSetA(color, x + y));
        canvas->drawRect(SkRect::MakeXYWH(x, y, 16, 16), paint);
     }
   }
##

#SeeAlso SkColorSetARGB

#Method ##

# ------------------------------------------------------------------------------

#Subtopic Alpha_Constants
#In Constant
#Line # constants for Alpha ##

#Code
    constexpr SkAlpha SK_AlphaTRANSPARENT = 0x00;
    constexpr SkAlpha SK_AlphaOPAQUE      = 0xFF;
##

Alpha constants are conveniences to represent fully transparent and fully
opaque colors and masks. Their use is not required.

#Const SK_AlphaTRANSPARENT 0x00
#Line # fully transparent SkAlpha ##
#Details Transparent
Represents fully transparent SkAlpha value. SkAlpha ranges from zero,
fully transparent; to 255, fully opaque.
##
#Const SK_AlphaOPAQUE 0xFF
#Line # fully opaque SkAlpha ##
#Details Opaque
Represents fully opaque SkAlpha value. SkAlpha ranges from zero,
fully transparent; to 255, fully opaque.
##

#Subtopic Transparent

#Example
#Image 1
#Height 128
#Description
Color the parts of the bitmap red if they mostly contain transparent pixels.
##
    std::vector<int32_t> srcPixels;
    srcPixels.resize(source.height() * source.rowBytes());
    SkPixmap pixmap(SkImageInfo::MakeN32Premul(source.width(), source.height()),
                    &srcPixels.front(), source.rowBytes());
    source.readPixels(pixmap, 0, 0);
    for (int y = 0; y < 16; ++y) {
        for (int x = 0; x < 16; ++x) {
            int32_t* blockStart = &srcPixels.front() + y * source.width() * 16 + x * 16;
            size_t transparentCount = 0;
            for (int fillY = 0; fillY < source.height() / 16; ++fillY) {
                for (int fillX = 0; fillX < source.width() / 16; ++fillX) {
                    const SkColor color = SkUnPreMultiply::PMColorToColor(blockStart[fillX]);
                    transparentCount += SkColorGetA(color) == SK_AlphaTRANSPARENT;
                }
                blockStart += source.width();
            }
            if (transparentCount > 200) {
                blockStart = &srcPixels.front() + y * source.width() * 16 + x * 16;
                for (int fillY = 0; fillY < source.height() / 16; ++fillY) {
                    for (int fillX = 0; fillX < source.width() / 16; ++fillX) {
                        blockStart[fillX] = SK_ColorRED;
                    }
                    blockStart += source.width();
                }
            }
        }
    }
    SkBitmap bitmap;
    bitmap.installPixels(pixmap);
    canvas->drawBitmap(bitmap, 0, 0);
##

#SeeAlso SkAlpha SK_ColorTRANSPARENT SK_AlphaOPAQUE

#Subtopic Transparent ##

# ------------------------------------------------------------------------------

#Subtopic Opaque

#Example
#Image 1
#Height 128
    std::vector<int32_t> srcPixels;
    srcPixels.resize(source.height() * source.rowBytes());
    SkPixmap pixmap(SkImageInfo::MakeN32Premul(source.width(), source.height()),
                    &srcPixels.front(), source.rowBytes());
    source.readPixels(pixmap, 0, 0);
    for (int y = 0; y < source.height(); ++y) {
        for (int x = 0; x < source.width(); ++x) {
            SkPMColor pixel = srcPixels[y * source.width() + x];
            const SkColor color = SkUnPreMultiply::PMColorToColor(pixel);
            if (SkColorGetA(color) == SK_AlphaOPAQUE) {
                srcPixels[y * source.width() + x] = SK_ColorGREEN;
            }
        }
    }
    SkBitmap bitmap;
    bitmap.installPixels(pixmap);
    canvas->drawBitmap(bitmap, 0, 0);
##

#SeeAlso SkAlpha SK_AlphaTRANSPARENT

#Subtopic Opaque ##
#Subtopic Alpha_Constants ##

#Subtopic Color_Constants
#In Constant
#Line # constants for Color ##

# ------------------------------------------------------------------------------
#Code
    constexpr SkColor SK_ColorTRANSPARENT = SkColorSetARGB(0x00, 0x00, 0x00, 0x00);
    constexpr SkColor SK_ColorBLACK       = SkColorSetARGB(0xFF, 0x00, 0x00, 0x00);
    constexpr SkColor SK_ColorDKGRAY      = SkColorSetARGB(0xFF, 0x44, 0x44, 0x44);
    constexpr SkColor SK_ColorGRAY        = SkColorSetARGB(0xFF, 0x88, 0x88, 0x88);
    constexpr SkColor SK_ColorLTGRAY      = SkColorSetARGB(0xFF, 0xCC, 0xCC, 0xCC);
    constexpr SkColor SK_ColorWHITE       = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF);
    constexpr SkColor SK_ColorRED         = SkColorSetARGB(0xFF, 0xFF, 0x00, 0x00);
    constexpr SkColor SK_ColorGREEN       = SkColorSetARGB(0xFF, 0x00, 0xFF, 0x00);
    constexpr SkColor SK_ColorBLUE        = SkColorSetARGB(0xFF, 0x00, 0x00, 0xFF);
    constexpr SkColor SK_ColorYELLOW      = SkColorSetARGB(0xFF, 0xFF, 0xFF, 0x00);
    constexpr SkColor SK_ColorCYAN        = SkColorSetARGB(0xFF, 0x00, 0xFF, 0xFF);
    constexpr SkColor SK_ColorMAGENTA     = SkColorSetARGB(0xFF, 0xFF, 0x00, 0xFF);
##

Color names are provided as conveniences, but are not otherwise special.
The values chosen for names may not be the same as values used by
SVG, HTML, CSS, or colors named by a platform.

#Example
###$
$Function
#define SKIA_COLOR_PAIR(name) "SK_Color" #name, SK_Color##name
$$
void draw(SkCanvas* canvas) {
    struct ColorCompare {
        const char* fSVGName;
        SkColor fSVGColor;
        const char* fSkiaName;
        SkColor fSkiaColor;
    } colorCompare[] = {  // see https://www.w3.org/TR/SVG/types.html#ColorKeywords
        {"black",     SkColorSetRGB(  0,   0,   0),    SKIA_COLOR_PAIR(BLACK) },
        {"darkgray",  SkColorSetRGB(169, 169, 169),    SKIA_COLOR_PAIR(DKGRAY) },
        {"gray",      SkColorSetRGB(128, 128, 128),    SKIA_COLOR_PAIR(GRAY) },
        {"lightgray", SkColorSetRGB(211, 211, 211),    SKIA_COLOR_PAIR(LTGRAY) },
        {"white",     SkColorSetRGB(255, 255, 255),    SKIA_COLOR_PAIR(WHITE) },
        {"red",       SkColorSetRGB(255,   0,   0),    SKIA_COLOR_PAIR(RED) },
        {"green",     SkColorSetRGB(  0, 128,   0),    SKIA_COLOR_PAIR(GREEN) },
        {"blue",      SkColorSetRGB(  0,   0, 255),    SKIA_COLOR_PAIR(BLUE) },
        {"yellow",    SkColorSetRGB(255, 255,   0),    SKIA_COLOR_PAIR(YELLOW) },
        {"aqua",      SkColorSetRGB(  0, 255, 255),    SKIA_COLOR_PAIR(CYAN) },
        {"fuchsia",   SkColorSetRGB(255,   0, 255),    SKIA_COLOR_PAIR(MAGENTA) },
    };
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setTextSize(14);
    for (auto compare : colorCompare) {
        paint.setStyle(SkPaint::kFill_Style);
        paint.setColor(compare.fSVGColor);
        canvas->drawRect({5, 5, 15, 15}, paint);
        paint.setColor(SK_ColorBLACK);
        canvas->drawString(compare.fSVGName, 20, 16, paint);
        paint.setColor(compare.fSkiaColor);
        canvas->drawRect({105, 5, 115, 15}, paint);
        paint.setColor(SK_ColorBLACK);
        canvas->drawString(compare.fSkiaName, 120, 16, paint);
        paint.setStyle(SkPaint::kStroke_Style);
        canvas->drawRect({5, 5, 15, 15}, paint);
        canvas->drawRect({105, 5, 115, 15}, paint);
        canvas->translate(0, 20);
    }
}
$$$#
##

# ------------------------------------------------------------------------------

#Const SK_ColorTRANSPARENT 0x00000000
#Line # transparent Color ##
#Details Transparent
    Represents fully transparent SkColor. May be used to initialize a destination
    containing a mask or a non-rectangular image.
##
#Const SK_ColorBLACK 0xFF000000
#Line # black Color ##
#Details Black
    Represents fully opaque black.
##
#Const SK_ColorDKGRAY 0xFF444444
#Line # dark gray Color ##
    Represents fully opaque dark gray.
    Note that SVG_darkgray is equivalent to 0xFFA9A9A9.
##
#Const SK_ColorGRAY 0xFF888888
#Line # gray Color ##
    Represents fully opaque gray.
    Note that HTML_Gray is equivalent to 0xFF808080.
##
#Const SK_ColorLTGRAY 0xFFCCCCCC
#Line # light gray Color ##
    Represents fully opaque light gray. HTML_Silver is equivalent to 0xFFC0C0C0.
    Note that SVG_lightgray is equivalent to 0xFFD3D3D3.
##
#Const SK_ColorWHITE 0xFFFFFFFF
#Line # white Color ##
    Represents fully opaque white.
##
#Const SK_ColorRED 0xFFFF0000
#Line # red Color ##
    Represents fully opaque red.
##
#Const SK_ColorGREEN 0xFF00FF00
#Line # green Color ##
    Represents fully opaque green. HTML_Lime is equivalent.
    Note that HTML_Green is equivalent to 0xFF008000.
##
#Const SK_ColorBLUE 0xFF0000FF
#Line # blue Color ##
    Represents fully opaque blue.
##
#Const SK_ColorYELLOW 0xFFFFFF00
#Line # yellow Color ##
    Represents fully opaque yellow.
##
#Const SK_ColorCYAN 0xFF00FFFF
#Line # cyan Color ##
    Represents fully opaque cyan. HTML_Aqua is equivalent.
##
#Const SK_ColorMAGENTA 0xFFFF00FF
#Line # magenta Color ##
    Represents fully opaque magenta. HTML_Fuchsia is equivalent.
##

# ------------------------------------------------------------------------------

#Subtopic Transparent

#Example
#Image 3
    std::vector<uint32_t> srcPixels;
    constexpr int width = 256;
    constexpr int height = 256;
    srcPixels.resize(width * height);
    SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(width, height);
    SkPixmap pixmap(imageInfo, &srcPixels.front(), imageInfo.minRowBytes());
    pixmap.erase(SK_ColorTRANSPARENT);
    pixmap.erase(SK_ColorRED, { 24, 24, 192, 192 } );
    pixmap.erase(SK_ColorTRANSPARENT, { 48, 48, 168, 168 } );
    SkBitmap bitmap;
    bitmap.installPixels(pixmap);
    canvas->drawBitmap(bitmap, 0, 0);
    canvas->drawBitmap(bitmap, 48, 48);
##

#SeeAlso SK_AlphaTRANSPARENT SkCanvas::clear

##

# ------------------------------------------------------------------------------

#Subtopic Black

#Example
    std::vector<uint32_t> srcPixels;
    constexpr int width = 256;
    constexpr int height = 256;
    srcPixels.resize(width * height);
    SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(width, height);
    SkPixmap pixmap(imageInfo, &srcPixels.front(), imageInfo.minRowBytes());
    pixmap.erase(SK_ColorTRANSPARENT);
    pixmap.erase(SK_ColorRED, { 24, 24, 192, 192 } );
    pixmap.erase(SK_ColorBLACK, { 48, 48, 168, 168 } );
    SkBitmap bitmap;
    bitmap.installPixels(pixmap);
    canvas->drawBitmap(bitmap, 0, 0);
    canvas->drawBitmap(bitmap, 48, 48);
##

#SeeAlso SK_ColorTRANSPARENT

##

# ------------------------------------------------------------------------------

#Subtopic White

#Example
    std::vector<uint32_t> srcPixels;
    constexpr int width = 256;
    constexpr int height = 256;
    srcPixels.resize(width * height);
    SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(width, height);
    SkPixmap pixmap(imageInfo, &srcPixels.front(), imageInfo.minRowBytes());
    pixmap.erase(SK_ColorTRANSPARENT);
    pixmap.erase(SK_ColorRED, { 24, 24, 192, 192 } );
    pixmap.erase(SK_ColorWHITE, { 48, 48, 168, 168 } );
    SkBitmap bitmap;
    bitmap.installPixels(pixmap);
    canvas->drawBitmap(bitmap, 0, 0);
    canvas->drawBitmap(bitmap, 48, 48);
##

#SeeAlso SK_ColorTRANSPARENT

##

#Subtopic Color_Constants ##

# ------------------------------------------------------------------------------

#Subtopic HSV

#Subtopic Hue
Hue represents an angle, in degrees, on a color wheel. Hue has a positive value
modulo 360, where zero degrees is red.
##

#Subtopic Saturation
Saturation represents the intensity of the color. Saturation varies from zero,
with no Hue contribution; to one, with full Hue contribution.
##

#Subtopic Value
Value represents the lightness of the color. Value varies from zero, black; to
one, full brightness.
##

#Method void SkRGBToHSV(U8CPU red, U8CPU green, U8CPU blue, SkScalar hsv[3])
#In Function
#Line # converts RGB to HSV ##

Converts RGB to its HSV components.
hsv[0] contains HSV_Hue, a value from zero to less than 360.
hsv[1] contains HSV_Saturation, a value from zero to one.
hsv[2] contains HSV_Value, a value from zero to one.

#Param red  red component value from zero to 255 ##
#Param green  green component value from zero to 255 ##
#Param blue  blue component value from zero to 255 ##
#Param hsv  three element array which holds the resulting HSV components
##

#Example
#Image 3
   canvas->drawBitmap(source, 0, 0);
   SkPaint bgPaint;
   bgPaint.setColor(0xafffffff);
   canvas->drawRect({20, 30, 110, 90}, bgPaint);
   SkScalar hsv[3];
   SkColor c = source.getColor(226, 128);
   SkRGBToHSV(SkColorGetR(c), SkColorGetG(c), SkColorGetB(c), hsv);
   canvas->drawString(("h: " + std::to_string(hsv[0]).substr(0, 6)).c_str(), 27, 45, SkPaint());
   canvas->drawString(("s: " + std::to_string(hsv[1]).substr(0, 6)).c_str(), 27, 65, SkPaint());
   canvas->drawString(("v: " + std::to_string(hsv[2]).substr(0, 6)).c_str(), 27, 85, SkPaint());
   canvas->drawLine(110, 90, 226, 128, SkPaint());
##

#SeeAlso SkColorToHSV SkHSVToColor

#Method ##

# ------------------------------------------------------------------------------

#Method void SkColorToHSV(SkColor color, SkScalar hsv[3])
#In Function
#Line # converts RGB to HSV ##

Converts ARGB to its HSV components. Alpha in ARGB is ignored.
hsv[0] contains HSV_Hue, and is assigned a value from zero to less than 360.
hsv[1] contains HSV_Saturation, a value from zero to one.
hsv[2] contains HSV_Value, a value from zero to one.

#Param color  ARGB color to convert
##
#Param hsv  three element array which holds the resulting HSV components
##

#Example
#Image 3
   canvas->drawBitmap(source, 0, 0);
   for (int y = 0; y < 256; ++y) {
      for (int x = 0; x < 256; ++x) {
        SkScalar hsv[3];
        SkColorToHSV(source.getColor(x, y), hsv);
        hsv[1] = 1 - hsv[1];
        SkPaint paint;
        paint.setColor(SkHSVToColor(hsv));
        canvas->drawRect(SkRect::MakeXYWH(x, y, 1, 1), paint);
     }
   }
##

#SeeAlso SkRGBToHSV SkHSVToColor

#Method ##

# ------------------------------------------------------------------------------

#Method SkColor SkHSVToColor(U8CPU alpha, const SkScalar hsv[3])
#In Function
#Line # converts HSV with Alpha to RGB ##

Converts HSV components to an ARGB color. Alpha is passed through unchanged.
hsv[0] represents HSV_Hue, an angle from zero to less than 360.
hsv[1] represents HSV_Saturation, and varies from zero to one.
hsv[2] represents HSV_Value, and varies from zero to one.

Out of range hsv values are pinned.

#Param alpha  Alpha component of the returned ARGB color
##
#Param hsv  three element array which holds the input HSV components
##

#Return  ARGB equivalent to HSV
##

#Example
#Image 3
   canvas->drawBitmap(source, 0, 0);
   for (int y = 0; y < 256; ++y) {
      for (int x = 0; x < 256; ++x) {
        SkColor color = source.getColor(x, y);
        SkScalar hsv[3];
        SkColorToHSV(color, hsv);
        hsv[0] = hsv[0] + 90 >= 360 ? hsv[0] - 270 : hsv[0] + 90;
        SkPaint paint;
        paint.setColor(SkHSVToColor(x + y, hsv));
        canvas->drawRect(SkRect::MakeXYWH(x, y, 1, 1), paint);
     }
   }
##

#SeeAlso SkColorToHSV SkRGBToHSV

#Method ##

# ------------------------------------------------------------------------------

#Method SkColor SkHSVToColor(const SkScalar hsv[3])
#In Function
#Line # converts HSV to RGB ##

Converts HSV components to an ARGB color. Alpha is set to 255.
hsv[0] represents HSV_Hue, an angle from zero to less than 360.
hsv[1] represents HSV_Saturation, and varies from zero to one.
hsv[2] represents HSV_Value, and varies from zero to one.

Out of range hsv values are pinned.

#Param hsv  three element array which holds the input HSV components
##

#Return  RGB equivalent to HSV
##

#Example
#Image 3
   canvas->drawBitmap(source, 0, 0);
   for (int y = 0; y < 256; ++y) {
      for (int x = 0; x < 256; ++x) {
        SkColor color = source.getColor(x, y);
        SkScalar hsv[3];
        SkColorToHSV(color, hsv);
        hsv[0] = hsv[0] + 90 >= 360 ? hsv[0] - 270 : hsv[0] + 90;
        SkPaint paint;
        paint.setColor(SkHSVToColor(hsv));
        canvas->drawRect(SkRect::MakeXYWH(x, y, 1, 1), paint);
     }
   }
##

#SeeAlso SkColorToHSV SkRGBToHSV

#Method ##

#Subtopic HSV ##

# ------------------------------------------------------------------------------

#Subtopic PMColor

#Typedef uint32_t SkPMColor
#Line # defines Premultiplied Color as 32 bits ##

#Code
typedef uint32_t SkPMColor;
##

32-bit ARGB color value, Premultiplied. The byte order for this value is
configuration dependent, matching the format of kBGRA_8888_SkColorType bitmaps.
This is different from SkColor, which is Unpremultiplied, and is always in the
same byte order.

#Typedef ##

# ------------------------------------------------------------------------------

#Method SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#In Function
#Line # converts Unpremultiplied ARGB to Premultiplied PMColor ##

Returns a SkPMColor value from Unpremultiplied 8-bit component values.

#Param a    amount of Alpha, from fully transparent (0) to fully opaque (255) ##
#Param r    amount of red, from no red (0) to full red (255) ##
#Param g    amount of green, from no green (0) to full green (255) ##
#Param b    amount of blue, from no blue (0) to full blue (255) ##

#Return Premultiplied Color ##

#Example
#Height 128
#Width 300
    SkPMColor premultiplied = SkPreMultiplyARGB(160, 128, 160, 192);
    canvas->drawString("Unpremultiplied:", 20, 20, SkPaint());
    canvas->drawString("alpha=160 red=128 green=160 blue=192", 20, 40, SkPaint());
    canvas->drawString("Premultiplied:", 20, 80, SkPaint());
    std::string str = "alpha=" + std::to_string(SkColorGetA(premultiplied));
    str += " red=" + std::to_string(SkColorGetR(premultiplied));
    str += " green=" + std::to_string(SkColorGetG(premultiplied));
    str += " blue=" + std::to_string(SkColorGetB(premultiplied));
    canvas->drawString(str.c_str(), 20, 100, SkPaint());
##

#SeeAlso SkPreMultiplyColor

#Method ##

# ------------------------------------------------------------------------------

#Method SkPMColor SkPreMultiplyColor(SkColor c)
#In Function
#Line # converts Unpremultiplied Color to Premultiplied PMColor ##

Returns PMColor closest to Color c. Multiplies c RGB components by the c Alpha,
and arranges the bytes to match the format of kN32_SkColorType.

#Param c  Unpremultiplied ARGB Color  ##

#Return Premultiplied Color ##

#Example
#Height 128
#Width 300
    SkColor unpremultiplied = SkColorSetARGB(160, 128, 160, 192);
    SkPMColor premultiplied = SkPreMultiplyColor(unpremultiplied);
    canvas->drawString("Unpremultiplied:", 20, 20, SkPaint());
    std::string str = "alpha=" + std::to_string(SkColorGetA(unpremultiplied));
    str += " red=" + std::to_string(SkColorGetR(unpremultiplied));
    str += " green=" + std::to_string(SkColorGetG(unpremultiplied));
    str += " blue=" + std::to_string(SkColorGetB(unpremultiplied));
    canvas->drawString(str.c_str(), 20, 40, SkPaint());
    canvas->drawString("Premultiplied:", 20, 80, SkPaint());
    str = "alpha=" + std::to_string(SkColorGetA(premultiplied));
    str += " red=" + std::to_string(SkColorGetR(premultiplied));
    str += " green=" + std::to_string(SkColorGetG(premultiplied));
    str += " blue=" + std::to_string(SkColorGetB(premultiplied));
    canvas->drawString(str.c_str(), 20, 100, SkPaint());
##

#SeeAlso SkPreMultiplyARGB

#Method ##

#Subtopic PMColor ##

#Topic Color ##