Flutter Engine
The Flutter Engine
Classes | Functions | Variables
hardstop_gradients.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.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/effects/SkGradientShader.h"

Go to the source code of this file.

Classes

class  HardstopGradientShaderGM
 

Functions

static void shade_rect (SkCanvas *canvas, sk_sp< SkShader > shader, int cellRow, int cellCol)
 
static void create_gradient_points (int cellRow, int cellCol, SkPoint points[2])
 

Variables

const int WIDTH = 500
 
const int HEIGHT = 500
 
const int NUM_ROWS = 8
 
const int NUM_COLS = 3
 
const int CELL_WIDTH = WIDTH / NUM_COLS
 
const int CELL_HEIGHT = HEIGHT / NUM_ROWS
 
const int PAD_WIDTH = 3
 
const int PAD_HEIGHT = 3
 
const int RECT_WIDTH = CELL_WIDTH - (2 * PAD_WIDTH)
 
const int RECT_HEIGHT = CELL_HEIGHT - (2 * PAD_HEIGHT)
 

Function Documentation

◆ create_gradient_points()

static void create_gradient_points ( int  cellRow,
int  cellCol,
SkPoint  points[2] 
)
static

Definition at line 80 of file hardstop_gradients.cpp.

80 {
81 const int X_OFFSET = 30;
82
83 auto x0 = SkIntToScalar(cellCol * CELL_WIDTH + PAD_WIDTH + X_OFFSET);
84 auto x1 = SkIntToScalar((cellCol+1) * CELL_WIDTH - PAD_WIDTH - X_OFFSET);
85 auto y = SkIntToScalar(cellRow * CELL_HEIGHT + PAD_HEIGHT + RECT_HEIGHT/2);
86
87 points[0] = SkPoint::Make(x0, y);
88 points[1] = SkPoint::Make(x1, y);
89}
static const int points[]
#define SkIntToScalar(x)
Definition: SkScalar.h:57
const int RECT_HEIGHT
const int CELL_WIDTH
const int PAD_WIDTH
const int PAD_HEIGHT
const int CELL_HEIGHT
double y
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173

◆ shade_rect()

static void shade_rect ( SkCanvas canvas,
sk_sp< SkShader shader,
int  cellRow,
int  cellCol 
)
static

Definition at line 68 of file hardstop_gradients.cpp.

68 {
70 paint.setShader(shader);
71
76
77 canvas->drawRect(rect, paint);
78}
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
const Paint & paint
Definition: color_source.cc:38
const int RECT_WIDTH
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

Variable Documentation

◆ CELL_HEIGHT

const int CELL_HEIGHT = HEIGHT / NUM_ROWS

Definition at line 60 of file hardstop_gradients.cpp.

◆ CELL_WIDTH

const int CELL_WIDTH = WIDTH / NUM_COLS

Definition at line 59 of file hardstop_gradients.cpp.

◆ HEIGHT

const int HEIGHT = 500

Definition at line 54 of file hardstop_gradients.cpp.

◆ NUM_COLS

const int NUM_COLS = 3

Definition at line 57 of file hardstop_gradients.cpp.

◆ NUM_ROWS

const int NUM_ROWS = 8

Definition at line 56 of file hardstop_gradients.cpp.

◆ PAD_HEIGHT

const int PAD_HEIGHT = 3

Definition at line 63 of file hardstop_gradients.cpp.

◆ PAD_WIDTH

const int PAD_WIDTH = 3

Definition at line 62 of file hardstop_gradients.cpp.

◆ RECT_HEIGHT

const int RECT_HEIGHT = CELL_HEIGHT - (2 * PAD_HEIGHT)

Definition at line 66 of file hardstop_gradients.cpp.

◆ RECT_WIDTH

const int RECT_WIDTH = CELL_WIDTH - (2 * PAD_WIDTH)

Definition at line 65 of file hardstop_gradients.cpp.

◆ WIDTH

const int WIDTH = 500

Definition at line 53 of file hardstop_gradients.cpp.