18#define BG_COLOR 0xFFDDDDDD
39 paint->setPathEffect(compose);
43 paint->setStrokeWidth(0);
47 paint->setStrokeWidth(0);
52 paint->setStrokeWidth(12);
57 SkScalar inter[] = { 20, 10, 10, 10 };
58 paint->setStrokeWidth(12);
63static const int gXY[] = {
644, 0, 0, -4, 8, -4, 12, 0, 8, 4, 0, 4
76 for (
unsigned i = 2; i < std::size(
gXY); i += 2)
92 paint->setPathEffect(
nullptr);
117 paint.setAntiAlias(
true);
122 path.lineTo(70, 120);
123 path.lineTo(120, 30);
124 path.lineTo(170, 80);
125 path.lineTo(240, 50);
129 for (i = 0; i < std::size(
gPE); i++) {
137 SkRect r = { 0, 0, 250, 120 };
143 for (i = 0; i < std::size(
gPE2); i++) {
186 data.fPos, data.fCount, tm);
203 center0, (pts[1].fX - pts[0].fX) / 2,
204 data.fColors, data.fPos, data.fCount, tm);
220 paint.setAntiAlias(
true);
221 paint.setDither(
true);
224 for (
size_t i = 0; i < std::size(
gGradData); i++) {
226 for (
size_t j = 0; j < std::size(
gGradMakers); j++) {
265 Rec() : fCount(0), fVerts(nullptr), fTexs(nullptr) {}
266 ~Rec() {
delete[] fVerts;
delete[] fTexs; }
275 rec->fVerts =
new SkPoint[rec->fCount];
277 for (
int i = 0; i < n; i++) {
278 SkPoint* v = &rec->fVerts[i*3];
279 for (
int j = 0; j < 3; j++) {
285static void make_fan(Rec* rec,
int texWidth,
int texHeight) {
292 rec->fVerts =
new SkPoint[rec->fCount];
293 rec->fTexs =
new SkPoint[rec->fCount];
300 for (
int i = 0; i < n; i++) {
304 v[i+1].
set(cos, sin);
305 t[i+1].
set(i*tx/n, ty);
313 m.mapPoints(v, rec->fCount);
316static void make_strip(Rec* rec,
int texWidth,
int texHeight) {
322 rec->fCount = 2 * (n + 1);
323 rec->fVerts =
new SkPoint[rec->fCount];
324 rec->fTexs =
new SkPoint[rec->fCount];
329 for (
int i = 0; i < n; i++) {
333 v[i*2 + 0].
set(cos/2, sin/2);
334 v[i*2 + 1].
set(cos, sin);
336 t[i*2 + 0].
set(tx * i / n, ty);
337 t[i*2 + 1].
set(tx * i / n, 0);
342 t[2*n + 0].
set(tx, ty);
343 t[2*n + 1].
set(tx, 0);
348 m.mapPoints(v, rec->fCount);
359 make_fan(&fRecs[1], size.fX, size.fY);
363 paint.setDither(
true);
365 for (
size_t i = 0; i < std::size(fRecs); i++) {
367 fRecs[i].fVerts, fRecs[i].fTexs,
nullptr);
370 paint.setShader(
nullptr);
375 paint.setShader(fShader0);
380 paint.setShader(fShader1);
415 for (
size_t i = 0; i < std::size(
gProc); i++) {
421 str.
printf(
"/skimages/slide_%zu.png", i);
427 gProc[fIndex](canvas);
432 fIndex = (fIndex + 1) % std::size(
gProc);
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorGREEN
constexpr SkColor SK_ColorWHITE
sk_sp< T > sk_ref_sp(T *obj)
#define SkScalarSin(radians)
#define SkScalarAve(a, b)
#define SkScalarCos(radians)
static SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t)
static void fill_pe(SkPaint *paint)
sk_sp< SkShader >(* GradMaker)(const SkPoint pts[2], const GradData &, SkTileMode)
static const GradData gGradData[]
static void one_d_pe(SkPaint *paint)
void(* PE_Proc)(SkPaint *)
static const SlideProc gProc[]
static sk_sp< SkShader > Make2Conical(const SkPoint pts[2], const GradData &data, SkTileMode tm)
static void hair_pe(SkPaint *paint)
static const GradMaker gGradMakers[]
static void tile_pe(SkPaint *paint)
static void mesh_slide(SkCanvas *canvas)
static sk_sp< SkShader > MakeSweep(const SkPoint pts[2], const GradData &data, SkTileMode tm)
static const SkScalar gPos2[]
static void stroke_pe(SkPaint *paint)
static void discrete_pe(SkPaint *paint)
void(* SlideProc)(SkCanvas *)
static void compose_pe(SkPaint *paint)
static void dash_pe(SkPaint *paint)
static sk_sp< SkShader > make_shader0(SkIPoint *size)
static sk_sp< SkPathEffect > MakeTileEffect()
static void make_strip(Rec *rec, int texWidth, int texHeight)
static const PE_Proc gPE2[]
static void gradient_slide(SkCanvas *canvas)
static const SkScalar gPos1[]
static void make_fan(Rec *rec, int texWidth, int texHeight)
static const SkScalar gPos0[]
static sk_sp< SkShader > make_shader1(const SkIPoint &size)
static void make_tris(Rec *rec)
static const SkColor gColors[]
static void patheffect_slide(SkCanvas *canvas)
static const PE_Proc gPE[]
static void hair2_pe(SkPaint *paint)
static SkScalar center(float pos0, float pos1)
static sk_sp< SkShader > MakeRadial()
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
void allocN32Pixels(int width, int height, bool isOpaque=false)
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
void drawPath(const SkPath &path, const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
static sk_sp< SkPathEffect > Make(SkScalar radius)
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
static sk_sp< SkPathEffect > Make(SkScalar segLength, SkScalar dev, uint32_t seedAssist=0)
static sk_sp< SkShader > MakeTwoPointConical(const SkPoint &start, SkScalar startRadius, const SkPoint &end, SkScalar endRadius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static sk_sp< SkShader > MakeSweep(SkScalar cx, SkScalar cy, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, SkScalar startAngle, SkScalar endAngle, uint32_t flags, const SkMatrix *localMatrix)
static sk_sp< SkShader > MakeRadial(const SkPoint ¢er, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
@ kStroke_Style
set to stroke geometry
@ kFill_Style
set to fill geometry
static sk_sp< SkPathEffect > Make(const SkPath &path, SkScalar advance, SkScalar phase, Style)
static sk_sp< SkPathEffect > Make(const SkMatrix &matrix, const SkPath &path)
static sk_sp< SkPathEffect > MakeCompose(sk_sp< SkPathEffect > outer, sk_sp< SkPathEffect > inner)
void printf(const char format[],...) SK_PRINTF_LIKE(2
const char * c_str() const
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])
@ kTriangleStrip_VertexMode
@ kTriangleFan_VertexMode
void load(SkScalar w, SkScalar h) override
void draw(SkCanvas *canvas) override
bool onClick(ClickHandlerSlide::Click *) override
Click * onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey) override
static sk_sp< SkShader > MakeLinear()
SkVertices::VertexMode fMode
void set(float x, float y)
void inset(float dx, float dy)