Color_Constants_a.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.
  4. #include "tools/fiddle/examples.h"
  5. // HASH=1c2e38321464818847f953ddd45cb5a1
  6. REG_FIDDLE(Color_Constants_a, 256, 256, false, 0) {
  7. #define SKIA_COLOR_PAIR(name) "SK_Color" #name, SK_Color##name
  8. void draw(SkCanvas* canvas) {
  9. struct ColorCompare {
  10. const char* fSVGName;
  11. SkColor fSVGColor;
  12. const char* fSkiaName;
  13. SkColor fSkiaColor;
  14. } colorCompare[] = { // see https://www.w3.org/TR/SVG/types.html#ColorKeywords
  15. {"black", SkColorSetRGB( 0, 0, 0), SKIA_COLOR_PAIR(BLACK) },
  16. {"darkgray", SkColorSetRGB(169, 169, 169), SKIA_COLOR_PAIR(DKGRAY) },
  17. {"gray", SkColorSetRGB(128, 128, 128), SKIA_COLOR_PAIR(GRAY) },
  18. {"lightgray", SkColorSetRGB(211, 211, 211), SKIA_COLOR_PAIR(LTGRAY) },
  19. {"white", SkColorSetRGB(255, 255, 255), SKIA_COLOR_PAIR(WHITE) },
  20. {"red", SkColorSetRGB(255, 0, 0), SKIA_COLOR_PAIR(RED) },
  21. {"green", SkColorSetRGB( 0, 128, 0), SKIA_COLOR_PAIR(GREEN) },
  22. {"blue", SkColorSetRGB( 0, 0, 255), SKIA_COLOR_PAIR(BLUE) },
  23. {"yellow", SkColorSetRGB(255, 255, 0), SKIA_COLOR_PAIR(YELLOW) },
  24. {"aqua", SkColorSetRGB( 0, 255, 255), SKIA_COLOR_PAIR(CYAN) },
  25. {"fuchsia", SkColorSetRGB(255, 0, 255), SKIA_COLOR_PAIR(MAGENTA) },
  26. };
  27. SkPaint paint;
  28. paint.setAntiAlias(true);
  29. paint.setTextSize(14);
  30. for (auto compare : colorCompare) {
  31. paint.setStyle(SkPaint::kFill_Style);
  32. paint.setColor(compare.fSVGColor);
  33. canvas->drawRect({5, 5, 15, 15}, paint);
  34. paint.setColor(SK_ColorBLACK);
  35. canvas->drawString(compare.fSVGName, 20, 16, paint);
  36. paint.setColor(compare.fSkiaColor);
  37. canvas->drawRect({105, 5, 115, 15}, paint);
  38. paint.setColor(SK_ColorBLACK);
  39. canvas->drawString(compare.fSkiaName, 120, 16, paint);
  40. paint.setStyle(SkPaint::kStroke_Style);
  41. canvas->drawRect({5, 5, 15, 15}, paint);
  42. canvas->drawRect({105, 5, 115, 15}, paint);
  43. canvas->translate(0, 20);
  44. }
  45. }
  46. } // END FIDDLE
  47. #endif // Disabled until updated to use current API.