Options
These globals are now defined:
double duration; // The requested duration of the animation. double frame; // A value in [0, 1] of where we are in the animation.
This global is now defined:
GrBackendRenderTarget backEndRenderTarget;
GrBackendTexture backEndTextureRenderTarget;
Optional source image
These globals are now defined:
SkBitmap source; sk_sp<SkImage> image; GrBackendTexture backEndTexture; // GPU Only.
Note:
Adding comments with SK_FOLD_START and SK_FOLD_END creates foldable code
blocks.
These blocks will be folded by default and are useful for highlighting specific lines of code.
You can also use the keyboard shortcuts Ctrl+S and Ctrl+E in the code editor to set them.
These blocks will be folded by default and are useful for highlighting specific lines of code.
You can also use the keyboard shortcuts Ctrl+S and Ctrl+E in the code editor to set them.
xxxxxxxxxx
30
void draw(SkCanvas* canvas) {
SkPoint pts[] = {{ 10, 50 }, { 110, 80 }, { 10, 110 }};
SkVector v[] = { pts[0] - pts[1], pts[2] - pts[1] };
SkScalar angle1 = SkScalarATan2(v[0].fY, v[0].fX);
SkScalar angle2 = SkScalarATan2(v[1].fY, v[1].fX);
const SkScalar strokeWidth = 20;
SkScalar miterLimit = 1 / SkScalarSin((angle2 - angle1) / 2);
SkScalar miterLength = strokeWidth * miterLimit;
SkPath path;
path.moveTo(pts[0]);
path.lineTo(pts[1]);
path.lineTo(pts[2]);
SkPaint paint; // set to default kMiter_Join
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeMiter(miterLimit);
paint.setStrokeWidth(strokeWidth);
canvas->drawPath(path, paint);
paint.setStrokeWidth(1);
canvas->drawLine(pts[1].fX - miterLength / 2, pts[1].fY + 50,
pts[1].fX + miterLength / 2, pts[1].fY + 50, paint);
canvas->translate(200, 0);
miterLimit *= 0.99f;
paint.setStrokeMiter(miterLimit);
paint.setStrokeWidth(strokeWidth);
canvas->drawPath(path, paint);
paint.setStrokeWidth(1);
canvas->drawLine(pts[1].fX - miterLength / 2, pts[1].fY + 50,
pts[1].fX + miterLength / 2, pts[1].fY + 50, paint);
}