Skip to content

Commit

Permalink
fix(gui): mask canvas should not tile small images
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 19, 2023
1 parent 5e23f84 commit f1484dc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gui/src/components/input/MaskCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ConfigContext, StateContext } from '../../state.js';
import { NumericField } from './NumericField';

export const FULL_CIRCLE = 2 * Math.PI;
export const FULL_OPACITY = 1.0;
export const MASK_OPACITY = 0.75;
export const PIXEL_SIZE = 4;
export const PIXEL_WEIGHT = 3;
Expand Down Expand Up @@ -90,9 +91,9 @@ export function MaskCanvas(props: MaskCanvasProps) {
function drawSource(file: Blob): void {
const image = new Image();
image.onload = () => {
const { ctx } = getClearContext(bufferRef);
ctx.globalAlpha = 1.0;
ctx.drawImage(image, 0, 0);
const { canvas, ctx } = getClearContext(bufferRef);
ctx.globalAlpha = FULL_OPACITY;
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
URL.revokeObjectURL(src);

drawBuffer();
Expand Down Expand Up @@ -172,6 +173,8 @@ export function MaskCanvas(props: MaskCanvasProps) {
drawClicks();

const styles: React.CSSProperties = {
backgroundPosition: 'top left',
backgroundRepeat: 'no-repeat',
border: '1px solid black',
maxHeight: params.height.default,
maxWidth: params.width.default,
Expand Down

0 comments on commit f1484dc

Please sign in to comment.