blob: c43096ea3f29b9fa617c5abcb1715602c0ff8f35 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -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.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// HASH=9ca1e2a5b9b4c92ecf4409d0813867d6
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Color_Constants_b, 256, 256, false, 3) {
Hal Canary87515122019-03-15 14:22:51 -04006void draw(SkCanvas* canvas) {
7 std::vector<uint32_t> srcPixels;
8 constexpr int width = 256;
9 constexpr int height = 256;
10 srcPixels.resize(width * height);
11 SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(width, height);
12 SkPixmap pixmap(imageInfo, &srcPixels.front(), imageInfo.minRowBytes());
13 pixmap.erase(SK_ColorTRANSPARENT);
14 pixmap.erase(SK_ColorRED, { 24, 24, 192, 192 } );
15 pixmap.erase(SK_ColorTRANSPARENT, { 48, 48, 168, 168 } );
16 SkBitmap bitmap;
17 bitmap.installPixels(pixmap);
18 canvas->drawBitmap(bitmap, 0, 0);
19 canvas->drawBitmap(bitmap, 48, 48);
20}
21} // END FIDDLE