Fix performance for polygons and curves

main
Isaiah Odhner 2018-06-18 01:12:08 -04:00
parent 9f4e24ce9c
commit 75d81b7913
2 changed files with 26 additions and 14 deletions

12
TODO.md
View File

@ -172,10 +172,6 @@ might be a pointer events spec interpretation issue, and it could easily be that
SVG (or HTML?) with invisible selectable transformed text elements?
* Curve
* Aliasing
* Rectangle
* The stroke should go within the rectangle
@ -187,9 +183,8 @@ might be a pointer events spec interpretation issue, and it could easily be that
* Don't start making the polygon until you click and drag more than the auto-finalization distance
* Cancel the polygon if you end up within the auto-finalization distance on the first gesture
* Preview invertily (like Free-Form Select) when fill-only is selected for the shape style option
* Regression: fix performance of the preview lines (now using WebGL so strokes don't change slightly when finalizing)
* Bug: jumping to 0, 0 (only saw it happen once so far; could it have to do with the dialog box?)
* Bug: unclosed polygon (last segment of stroke) (only saw it happen once so far)
* Investigate bug: jumping to 0, 0 (only saw it happen once so far; could it have had to do with the dialog box?)
* Investigate bug: unclosed polygon (last segment of stroke) (only saw it happen once so far)
* Ellipse
@ -210,6 +205,9 @@ might be a pointer events spec interpretation issue, and it could easily be that
* Support stroke size and shape styles!
* Rectangle, Rounded Rectangle & Ellipse:
* Stroke should be entirely inside the dragged region
* Handle patterns (black and white mode)
* Still needed for line, curve, brush, and fill
* Alignment should be fixed for selection tools (and checked for all of them)
### On-Canvas Objects

View File

@ -139,15 +139,29 @@ function draw_rounded_rectangle(ctx, x, y, width, height, radius){
}
var line_brush_canvas;
var line_brush_canvas_rendered_shape;
var line_brush_canvas_rendered_color;
var line_brush_canvas_rendered_size;
function update_brush_for_drawing_lines(stroke_size){
if(aliasing && stroke_size > 1){
var csz = stroke_size * 2.1; // XXX: magic constant duplicated from tools.js
line_brush_canvas = new Canvas(csz, csz);
line_brush_canvas.width = csz;
line_brush_canvas.height = csz;
line_brush_canvas.ctx.fillStyle = line_brush_canvas.ctx.strokeStyle = stroke_color;
render_brush(line_brush_canvas.ctx, "circle", stroke_size);
// TODO: DRY brush caching code
if(
line_brush_canvas_rendered_shape !== "circle" ||
line_brush_canvas_rendered_color !== stroke_color ||
line_brush_canvas_rendered_size !== stroke_size
){
// don't need to do brush_ctx.disable_image_smoothing() currently because images aren't drawn to the brush
var csz = stroke_size * 2.1; // XXX: magic constant duplicated from tools.js
line_brush_canvas = new Canvas(csz, csz);
line_brush_canvas.width = csz;
line_brush_canvas.height = csz;
line_brush_canvas.ctx.fillStyle = line_brush_canvas.ctx.strokeStyle = stroke_color;
render_brush(line_brush_canvas.ctx, "circle", stroke_size);
line_brush_canvas_rendered_shape = "circle";
line_brush_canvas_rendered_color = stroke_color;
line_brush_canvas_rendered_size = stroke_size;
}
}
}