1 // 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"
4 // HASH=33b029064e8d1928e42a587c953d0e4e
5 REG_FIDDLE(RGBA4f_FromColor, 256, 256, true, 0) {
draw(SkCanvas * canvas)6 void draw(SkCanvas* canvas) {
7     uint8_t red = 77, green = 101, blue = 153, alpha = 43;
8     SkColor argb = SkColorSetARGB(alpha, red, green, blue);
9     SkColor4f color4f = SkColor4f::FromColor(argb);
10     SkDebugf("red=%g green=%g blue=%g alpha=%g\n", color4f.fR, color4f.fG, color4f.fB, color4f.fA);
11     SkColor fromColor4f = color4f.toSkColor();
12     SkDebugf("red=%d green=%d blue=%d alpha=%d\n", SkColorGetR(fromColor4f),
13              SkColorGetG(fromColor4f), SkColorGetB(fromColor4f), SkColorGetA(fromColor4f));
14 }
15 }  // END FIDDLE
16