Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 1 | #if 0 // Disabled until updated to use current API. |
| 2 | // Copyright 2019 Google LLC. |
| 3 | // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 4 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 5 | // HASH=1c2e38321464818847f953ddd45cb5a1 |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 6 | REG_FIDDLE(Color_Constants_a, 256, 256, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 7 | #define SKIA_COLOR_PAIR(name) "SK_Color" #name, SK_Color##name |
| 8 | |
| 9 | void draw(SkCanvas* canvas) { |
| 10 | struct ColorCompare { |
| 11 | const char* fSVGName; |
| 12 | SkColor fSVGColor; |
| 13 | const char* fSkiaName; |
| 14 | SkColor fSkiaColor; |
| 15 | } colorCompare[] = { // see https://www.w3.org/TR/SVG/types.html#ColorKeywords |
| 16 | {"black", SkColorSetRGB( 0, 0, 0), SKIA_COLOR_PAIR(BLACK) }, |
| 17 | {"darkgray", SkColorSetRGB(169, 169, 169), SKIA_COLOR_PAIR(DKGRAY) }, |
| 18 | {"gray", SkColorSetRGB(128, 128, 128), SKIA_COLOR_PAIR(GRAY) }, |
| 19 | {"lightgray", SkColorSetRGB(211, 211, 211), SKIA_COLOR_PAIR(LTGRAY) }, |
| 20 | {"white", SkColorSetRGB(255, 255, 255), SKIA_COLOR_PAIR(WHITE) }, |
| 21 | {"red", SkColorSetRGB(255, 0, 0), SKIA_COLOR_PAIR(RED) }, |
| 22 | {"green", SkColorSetRGB( 0, 128, 0), SKIA_COLOR_PAIR(GREEN) }, |
| 23 | {"blue", SkColorSetRGB( 0, 0, 255), SKIA_COLOR_PAIR(BLUE) }, |
| 24 | {"yellow", SkColorSetRGB(255, 255, 0), SKIA_COLOR_PAIR(YELLOW) }, |
| 25 | {"aqua", SkColorSetRGB( 0, 255, 255), SKIA_COLOR_PAIR(CYAN) }, |
| 26 | {"fuchsia", SkColorSetRGB(255, 0, 255), SKIA_COLOR_PAIR(MAGENTA) }, |
| 27 | }; |
| 28 | SkPaint paint; |
| 29 | paint.setAntiAlias(true); |
| 30 | paint.setTextSize(14); |
| 31 | for (auto compare : colorCompare) { |
| 32 | paint.setStyle(SkPaint::kFill_Style); |
| 33 | paint.setColor(compare.fSVGColor); |
| 34 | canvas->drawRect({5, 5, 15, 15}, paint); |
| 35 | paint.setColor(SK_ColorBLACK); |
| 36 | canvas->drawString(compare.fSVGName, 20, 16, paint); |
| 37 | paint.setColor(compare.fSkiaColor); |
| 38 | canvas->drawRect({105, 5, 115, 15}, paint); |
| 39 | paint.setColor(SK_ColorBLACK); |
| 40 | canvas->drawString(compare.fSkiaName, 120, 16, paint); |
| 41 | paint.setStyle(SkPaint::kStroke_Style); |
| 42 | canvas->drawRect({5, 5, 15, 15}, paint); |
| 43 | canvas->drawRect({105, 5, 115, 15}, paint); |
| 44 | canvas->translate(0, 20); |
| 45 | } |
| 46 | } |
| 47 | } // END FIDDLE |
| 48 | #endif // Disabled until updated to use current API. |