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=edc5fd18d961f7607d2bcbf7f7d427e5
5 REG_FIDDLE(RGBA4f_toSkColor, 256, 256, true, 0) {
draw(SkCanvas * canvas)6 void draw(SkCanvas* canvas) {
7 float red = 0.07f, green = 0.13f, blue = 0.32f, alpha = 0.17f;
8 SkColor4f color4f = { red, green, blue, alpha };
9 SkColor argb = color4f.toSkColor();
10 SkDebugf("red=%d green=%d blue=%d alpha=%d\n", SkColorGetR(argb),
11 SkColorGetG(argb), SkColorGetB(argb), SkColorGetA(argb));
12 SkColor4f fromSkColor = SkColor4f::FromColor(argb);
13 SkDebugf("red=%g green=%g blue=%g alpha=%g\n", fromSkColor.fR, fromSkColor.fG,
14 fromSkColor.fB, fromSkColor.fA);
15 }
16 } // END FIDDLE
17