Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / docs / examples / Canvas_writePixels_2.cpp
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=8b128e067881f9251357653692fa28da
5 REG_FIDDLE(Canvas_writePixels_2, 256, 256, false, 0) {
6 void draw(SkCanvas* canvas) {
7     SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(2, 2);
8     SkBitmap bitmap;
9     bitmap.setInfo(imageInfo);
10     uint32_t pixels[4];
11     bitmap.setPixels(pixels);
12     for (int y = 0; y < 256; y += 2) {
13         for (int x = 0; x < 256;  x += 2) {
14             pixels[0] = SkColorSetRGB(x, y, x | y);
15             pixels[1] = SkColorSetRGB(x ^ y, y, x);
16             pixels[2] = SkColorSetRGB(x, x & y, y);
17             pixels[3] = SkColorSetRGB((~x) & 0xFF, (~y) & 0xFF, x);
18             canvas->writePixels(bitmap, x, y);
19         }
20     }
21 }
22 }  // END FIDDLE