Skip to content

Commit

Permalink
fix trk js brush functionality
Browse files Browse the repository at this point in the history
- brush size needs to be rescaled in caliban.py to work correctly
- js brush.draw needs additional arguments
- clip edges of image before drawing brush to prevent edge artifacts
  • Loading branch information
geneva-miller committed Jul 30, 2020
1 parent 0765e34 commit aaefd93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion browser/caliban.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ def action_handle_draw(self, trace, target_value, brush_value, brush_size, erase
x_loc = loc[1]
y_loc = loc[0]

brush_area = circle(y_loc, x_loc, brush_size, (self.height, self.width))
brush_area = circle(y_loc, x_loc,
brush_size // self.scale_factor,
(self.height, self.width))

# do not overwrite or erase labels other than the one you're editing
if not erase:
Expand Down
9 changes: 8 additions & 1 deletion browser/static/js/main_track.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,15 @@ function render_edit_image(ctx) {
ctx.drawImage(seg_image, padding, padding, dimensions[0], dimensions[1]);
ctx.restore();

ctx.save();
let region = new Path2D();
region.rect(padding, padding, dimensions[0], dimensions[1]);
ctx.clip(region);
ctx.imageSmoothingEnabled = true;

// draw brushview on top of cells/annotations
brush.draw(ctx);
brush.draw(ctx, 0, 0, dimensions[0], dimensions[1], 1);
ctx.restore();
}

function render_raw_image(ctx) {
Expand Down

0 comments on commit aaefd93

Please sign in to comment.