Generate bookmaker indices
First cut at splitting bookmaker documentation into reference
and overview. Reference starts with a hyperlinked index,
generated from a public include.
This moves towards typing once, minimizing the information
duplicated in the .h file and the .bmh file.
TBR=caryclark@google.com
Docs-Preview: https://skia.org/?cl=154630
Change-Id: I836622db9b1786bd28c0bce2536cd3caef6e5a32
Reviewed-on: https://skia-review.googlesource.com/c/154630
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
diff --git a/docs/SkColor_Reference.bmh b/docs/SkColor_Reference.bmh
index cc6f10c..c71ad1f 100644
--- a/docs/SkColor_Reference.bmh
+++ b/docs/SkColor_Reference.bmh
@@ -1,15 +1,7 @@
#Topic Color
#Alias Color_Reference ##
-#File
-Types, consts, functions, and macros for colors.
-##
-
-#Subtopic Overview
-#Populate
-##
-
-#Subtopic Define
+#Code
#Populate
##
@@ -17,21 +9,14 @@
the represent transparency and color values. The use of Color constants is not
required.
-#Subtopic Constant
-#Populate
-##
-
-#Subtopic Function
-#Populate
-##
-
-#Subtopic Typedef
-#Populate
+#Subtopic Functions
+#Line # routines to read, write, and manipulate SkColor ##
##
# ------------------------------------------------------------------------------
#Subtopic Alpha
+#Line # transparency of Color ##
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
@@ -82,7 +67,7 @@
# ------------------------------------------------------------------------------
#Method static constexpr inline SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
-#In Function
+#In Functions
#Line # returns Color_Alpha and RGB combined ##
Returns Color value from 8-bit component values. Asserts if SK_DEBUG is defined
@@ -156,16 +141,16 @@
#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);
- }
+ 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
@@ -190,13 +175,13 @@
#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());
+ 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
@@ -221,12 +206,12 @@
#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->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());
##
@@ -252,12 +237,12 @@
#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->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());
##
@@ -268,7 +253,7 @@
# ------------------------------------------------------------------------------
#Method static constexpr inline SkColor SkColorSetA(SkColor c, U8CPU a)
-#In Function
+#In Functions
#Line # returns Color with transparency ##
Returns Unpremultiplied Color with red, blue, and green set from c; and alpha set
@@ -281,15 +266,15 @@
#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);
- }
- }
+ 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
@@ -604,6 +589,7 @@
# ------------------------------------------------------------------------------
#Subtopic HSV
+#Line # hue saturation value color representation ##
#Subtopic Hue
Hue represents an angle, in degrees, on a color wheel. Hue has a positive value
@@ -621,7 +607,7 @@
##
#Method void SkRGBToHSV(U8CPU red, U8CPU green, U8CPU blue, SkScalar hsv[3])
-#In Function
+#In Functions
#Line # converts RGB to HSV ##
Converts RGB to its HSV components.
@@ -637,17 +623,17 @@
#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());
+ 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
@@ -657,7 +643,7 @@
# ------------------------------------------------------------------------------
#Method void SkColorToHSV(SkColor color, SkScalar hsv[3])
-#In Function
+#In Functions
#Line # converts RGB to HSV ##
Converts ARGB to its HSV components. Alpha in ARGB is ignored.
@@ -672,17 +658,17 @@
#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);
- }
- }
+ 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
@@ -692,7 +678,7 @@
# ------------------------------------------------------------------------------
#Method SkColor SkHSVToColor(U8CPU alpha, const SkScalar hsv[3])
-#In Function
+#In Functions
#Line # converts HSV with Alpha to RGB ##
Converts HSV components to an ARGB color. Alpha is passed through unchanged.
@@ -712,18 +698,18 @@
#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);
- }
- }
+ 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
@@ -733,7 +719,7 @@
# ------------------------------------------------------------------------------
#Method SkColor SkHSVToColor(const SkScalar hsv[3])
-#In Function
+#In Functions
#Line # converts HSV to RGB ##
Converts HSV components to an ARGB color. Alpha is set to 255.
@@ -751,18 +737,18 @@
#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);
- }
- }
+ 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
@@ -774,6 +760,7 @@
# ------------------------------------------------------------------------------
#Subtopic PMColor
+#Line # color components premultiplied by Alpha ##
#Typedef uint32_t SkPMColor
#Line # defines Premultiplied Color as 32 bits ##
@@ -792,7 +779,7 @@
# ------------------------------------------------------------------------------
#Method SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
-#In Function
+#In Functions
#Line # converts Unpremultiplied ARGB to Premultiplied PMColor ##
Returns a SkPMColor value from Unpremultiplied 8-bit component values.
@@ -807,14 +794,14 @@
#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));
+ 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());
##
@@ -825,7 +812,7 @@
# ------------------------------------------------------------------------------
#Method SkPMColor SkPreMultiplyColor(SkColor c)
-#In Function
+#In Functions
#Line # converts Unpremultiplied Color to Premultiplied PMColor ##
Returns PMColor closest to Color c. Multiplies c RGB components by the c Alpha,
@@ -838,19 +825,19 @@
#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));
+ 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());
##