blob: 26016e6ea5b2a65753990b66215b1feb699f1345 [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);
Mike Reede1f72f92021-01-27 17:09:40 -050018 canvas->drawImage(bitmap.asImage(), 0, 0);
19 canvas->drawImage(bitmap.asImage(), 48, 48);
Hal Canary87515122019-03-15 14:22:51 -040020}
21} // END FIDDLE