Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Namespaces | Functions | Variables
hairmodes.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorPriv.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTileMode.h"
#include "include/core/SkTypes.h"

Go to the source code of this file.

Classes

class  skiagm::HairModesGM
 

Namespaces

namespace  skiagm
 

Functions

static SkScalar drawCell (SkCanvas *canvas, SkBlendMode mode, SkAlpha a0, SkAlpha a1)
 
static sk_sp< SkShadermake_bg_shader ()
 

Variables

constexpr SkBlendMode gModes []
 
const int gWidth = 64
 
const int gHeight = 64
 
const SkScalar W = SkIntToScalar(gWidth)
 
const SkScalar H = SkIntToScalar(gHeight)
 

Function Documentation

◆ drawCell()

static SkScalar drawCell ( SkCanvas canvas,
SkBlendMode  mode,
SkAlpha  a0,
SkAlpha  a1 
)
static

Definition at line 45 of file hairmodes.cpp.

45 {
46
48 paint.setAntiAlias(true);
49
51 r.inset(W/10, H/10);
52
53 paint.setColor(SK_ColorBLUE);
54 paint.setAlpha(a0);
55 canvas->drawOval(r, paint);
56
57 paint.setColor(SK_ColorRED);
58 paint.setAlpha(a1);
59 paint.setBlendMode(mode);
60 for (int angle = 0; angle < 24; ++angle) {
61 SkScalar x = SkScalarCos(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gWidth;
62 SkScalar y = SkScalarSin(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gHeight;
63 paint.setStrokeWidth(SK_Scalar1 * angle * 2 / 24);
64 canvas->drawLine(W/2, H/2, W/2 + x, H/2 + y, paint);
65 }
66
67 return H;
68}
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
#define SkScalarSin(radians)
Definition SkScalar.h:45
#define SK_Scalar1
Definition SkScalar.h:18
#define SkIntToScalar(x)
Definition SkScalar.h:57
#define SkScalarCos(radians)
Definition SkScalar.h:46
#define SK_ScalarPI
Definition SkScalar.h:21
void drawOval(const SkRect &oval, const SkPaint &paint)
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
const Paint & paint
float SkScalar
Definition extension.cpp:12
const SkScalar H
Definition hairmodes.cpp:43
const SkScalar W
Definition hairmodes.cpp:42
const int gWidth
Definition hairmodes.cpp:40
const int gHeight
Definition hairmodes.cpp:41
double y
double x
Definition SkMD5.cpp:130
void inset(float dx, float dy)
Definition SkRect.h:1060
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609

◆ make_bg_shader()

static sk_sp< SkShader > make_bg_shader ( )
static

Definition at line 70 of file hairmodes.cpp.

70 {
71 SkBitmap bm;
72 bm.allocN32Pixels(2, 2);
73 *bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF;
74 *bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCE, 0xCF, 0xCE);
75
76 SkMatrix m;
77 m.setScale(SkIntToScalar(6), SkIntToScalar(6));
79}
static SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition SkBitmap.cpp:669
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition SkBitmap.cpp:232
uint32_t * getAddr32(int x, int y) const
Definition SkBitmap.h:1260

Variable Documentation

◆ gHeight

const int gHeight = 64

Definition at line 41 of file hairmodes.cpp.

◆ gModes

constexpr SkBlendMode gModes[]
constexpr

◆ gWidth

const int gWidth = 64

Definition at line 40 of file hairmodes.cpp.

◆ H

Definition at line 43 of file hairmodes.cpp.

◆ W

Definition at line 42 of file hairmodes.cpp.