Flutter Engine
The Flutter Engine
Functions
Bitmap_allocN32Pixels.cpp File Reference
#include "tools/fiddle/examples.h"
#include <climits>
#include <random>

Go to the source code of this file.

Functions

 REG_FIDDLE (Bitmap_allocN32Pixels, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Bitmap_allocN32Pixels  ,
256  ,
256  ,
false  ,
 
)

Definition at line 8 of file Bitmap_allocN32Pixels.cpp.

8 {
9void draw(SkCanvas* canvas) {
11 bitmap.allocN32Pixels(64, 64);
12 bitmap.eraseColor(SK_ColorTRANSPARENT);
13 std::default_random_engine rng;
14 const auto randUint = [&rng](uint32_t min, uint32_t max) -> uint32_t {
15 return std::uniform_int_distribution<uint32_t>(min, max)(rng);
16 };
17
18 for (int y = 0; y < 256; y += 64) {
19 for (int x = 0; x < 256; x += 64) {
20 SkColor color = randUint(0, UINT_MAX);
21 uint32_t w = randUint(4, 32);
22 uint32_t cx = randUint(0, 64 - w);
23 uint32_t h = randUint(4, 32);
24 uint32_t cy = randUint(0, 64 - h);
25 bitmap.erase(color, SkIRect::MakeXYWH(cx, cy, w, h));
26 canvas->drawImage(bitmap.asImage(), x, y);
27 }
28 }
29}
30} // END FIDDLE
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorTRANSPARENT
Definition: SkColor.h:99
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
DlColor color
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
double y
double x
Definition: bitmap.py:1
SkScalar w
SkScalar h
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104