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
35
// draws a line starting at (x, y), at an angle, with length len
// recursion goes to 11 level
// at the last two levels, line is drawn in green.
void drawTree(int x, int y, int angle, int len, int level, SkCanvas *canvas, SkPaint paint) {
// the other end point of the line, is obtained by moving len distance
// at an angle
int x2 = (int) x - len *cos(2*3.14*angle/360.0);
int y2 = (int) y + len * sin(2*3.14*angle/360.0);
canvas->drawLine(x, y, x2, y2, paint);
paint.setStrokeWidth(10 - level);
if (level <= 10) {
drawTree(x2,y2, angle - 20, (1-level/20.0)*len, level+1, canvas, paint);
drawTree(x2,y2, angle + 20, (1-level/20.0)*len, level +1, canvas, paint);
}
}
void draw(SkCanvas* canvas) {
canvas->drawColor(SK_ColorWHITE);
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(10);
paint.setColor(0xff4285F4);
paint.setAntiAlias(true);
paint.setStrokeCap(SkPaint::kRound_Cap);
//canvas->drawLine(500, 0, 500, 100, paint);
drawTree(500,1000,-90, 100,0, canvas, paint);
}