Skip to content

Instantly share code, notes, and snippets.

@wieslawsoltes
Last active June 9, 2019 13:35
Show Gist options
  • Save wieslawsoltes/65d5570ec266e97557e90cef40203b37 to your computer and use it in GitHub Desktop.
Save wieslawsoltes/65d5570ec266e97557e90cef40203b37 to your computer and use it in GitHub Desktop.
void draw(SkCanvas* canvas) {
SkPaint paint1;
SkPaint paint2;
float width = 120.0f;
float height = 90.0f;
float cw = 15.0f;
float ch = 15.0f;
SkMatrix lattice1;
lattice1.setScale(cw, ch);
lattice1.preRotate(0.0f);
lattice1.preTranslate(-cw, 0.0f);
SkMatrix lattice2;
lattice2.setScale(cw, ch);
lattice2.preRotate(90.0f);
lattice2.preTranslate(0.0f, -ch);
canvas->clear(SK_ColorWHITE);
paint1.setAntiAlias(false);
paint1.setPathEffect(SkLine2DPathEffect::Make(1.0f, lattice1));
SkRect bounds1 = SkRect::MakeXYWH(cw, -ch, width, height);
paint2.setAntiAlias(false);
paint2.setPathEffect(SkLine2DPathEffect::Make(1.0f, lattice2));
SkRect bounds2 = SkRect::MakeXYWH(-cw, ch, width, height);
canvas->drawRect(bounds1, paint1);
canvas->drawRect(bounds2, paint2);
SkPaint strokePaint;
strokePaint.setAntiAlias(false);
strokePaint.setStrokeWidth(1.0f);
strokePaint.setColor(SkColorSetARGB(0xFF, 0xFF, 0x00, 0x00));
strokePaint.setStyle(SkPaint::kStroke_Style);
canvas->drawRect(SkRect::MakeXYWH(0.0f, 0.0f, width, height), strokePaint);
}
void draw(SkCanvas* canvas) {
SkPaint paint1;
SkPaint paint2;
float width = 120.0f;
float height = 90.0f;
float cw = 15.0f;
float ch = 15.0f;
SkMatrix lattice1;
lattice1.setScale(cw, ch);
lattice1.preRotate(0.0f);
//lattice1.preTranslate(-cw, 0.0f);
SkMatrix lattice2;
lattice2.setScale(cw, ch);
lattice2.preRotate(90.0f);
//lattice2.preTranslate(0.0f, -ch);
canvas->clear(SK_ColorWHITE);
paint1.setAntiAlias(false);
paint1.setPathEffect(SkLine2DPathEffect::Make(1.0f, lattice1));
SkRect bounds1 = SkRect::MakeXYWH(0.0f, ch, width, height - ch);
paint2.setAntiAlias(false);
paint2.setPathEffect(SkLine2DPathEffect::Make(1.0f, lattice2));
SkRect bounds2 = SkRect::MakeXYWH(cw, 0.0f, width - cw, height);
canvas->drawRect(bounds1, paint1);
canvas->drawRect(bounds2, paint2);
SkPaint strokePaint;
strokePaint.setAntiAlias(false);
strokePaint.setStrokeWidth(1.0f);
strokePaint.setColor(SkColorSetARGB(0xFF, 0xFF, 0x00, 0x00));
strokePaint.setStyle(SkPaint::kStroke_Style);
canvas->drawRect(SkRect::MakeXYWH(0.0f, 0.0f, width, height), strokePaint);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment