Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out source of partially filled pixels #3

Open
ianhi opened this issue Jun 16, 2020 · 4 comments
Open

Figure out source of partially filled pixels #3

ianhi opened this issue Jun 16, 2020 · 4 comments

Comments

@ianhi
Copy link
Owner

ianhi commented Jun 16, 2020

If you zoom in on an area that you filled in from a lower zoom level then the edge pixels have clearly been interpolated:
image
This is happening either on the scaling up of the image to match the classCanvas size - or on the downsizing of the class canvas to the zoomed image. I think it may be the latter because if I draw while zoomed in it's crisp:

image
not sure though. Probably ought to look at what the actual arrays look like.

@ianhi
Copy link
Owner Author

ianhi commented Jun 16, 2020

Probably happening due to the scaling here:

ipysegment/src/widget.ts

Lines 145 to 160 in 6d18932

this.displayContext.fill(this.path);
this.previewContext.save();
this.previewContext.fillStyle = 'rgb(255, 10, 100)';
this.previewContext.fill(this.path);
this.model.classContext.drawImage(
this.previewCanvas,
0,
0,
this.previewCanvas.width,
this.previewCanvas.height,
this._Sx,
this._Sy,
this._sWidth,
this._sHeight
);
this.previewContext.restore();

@ianhi
Copy link
Owner Author

ianhi commented Jun 16, 2020

maybe these will be important:
https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering
https://stackoverflow.com/questions/7615009/disable-interpolation-when-scaling-a-canvas
though annoyingly chome and firefox both don't fully implement the spec and instead implement different keywords:
https://caniuse.com/#feat=css-crisp-edges

only pixelated for chrome and only crisp-edges for firefox

@ianhi
Copy link
Owner Author

ianhi commented Jun 24, 2020

there may be a compositing mode that is helpful here https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation

@ianhi
Copy link
Owner Author

ianhi commented Jun 30, 2020

search for "crisp" on this page https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Applying_styles_and_colors

maybe need to check that the points on the path all align with pixels?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant