blob: e76a90f6baeafe8bd675ea028b44296a2a4045d3 [file] [log] [blame]
Hal Canaryccab1cc2019-05-03 14:07:22 -04001// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3#include "tools/fiddle/examples.h"
4REG_FIDDLE(Colors, 128, 256, false, 0) {
5void draw(SkCanvas* canvas) {
6 const struct { SkColor4f fColor; const char* fName; } kColors[] = {
7 {SkColors::kBlack, "SkColors::kBlack"},
8 {SkColors::kDkGray, "SkColors::kDkGray"},
9 {SkColors::kGray, "SkColors::kGray"},
10 {SkColors::kLtGray, "SkColors::kLtGray"},
11 {SkColors::kWhite, "SkColors::kWhite"},
12 {SkColors::kRed, "SkColors::kRed"},
13 {SkColors::kGreen, "SkColors::kGreen"},
14 {SkColors::kBlue, "SkColors::kBlue"},
15 {SkColors::kYellow, "SkColors::kYellow"},
16 {SkColors::kCyan, "SkColors::kCyan"},
17 {SkColors::kMagenta, "SkColors::kMagenta"},
18 };
19 float y = 0;
20 constexpr float kSize = 256.0f / (sizeof(kColors) / sizeof(kColors[0]));
21 const SkColor4f kBrown{0.5f, 0.25f, 0, 1};
22 for (const auto& c : kColors) {
23 canvas->drawRect(SkRect{0, y, 128, y + kSize}, SkPaint(c.fColor));
24 canvas->drawString(c.fName, 4, y + kSize * 0.7f, SkFont(), SkPaint(kBrown));
25 y += kSize;
26 }
27}
28} // END FIDDLE