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

Prevent stroke of zoom rectangles from being cropped by canvas #1346

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

axelboc
Copy link
Contributor

@axelboc axelboc commented Jan 11, 2023

And.... SvgRect and SvgLine are back!! 😂

This is something I had been meaning to fix for a while. Notice how the stroke of the zoom rectangle gets cropped by the the canvas:

stroke-cropped

What it looks like now:

stroke-not-cropped

This is a good use case for re-introducing SvgRect and SvgLine, as "shifting" the stroke inside of the rectangle requires knowing the strokeWidth (and whether stroke is declared at all). Utilities aren't great to handle this.

Note, however, that I'm now choosing to keep SvgElement out of SvgRect/Line.

@axelboc axelboc requested a review from loichuder January 12, 2023 12:59
Copy link
Member

@loichuder loichuder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great but I don't see the advantage of having SvgElement out of SvgRect/SvgLine ?

@axelboc
Copy link
Contributor Author

axelboc commented Jan 16, 2023

It's better to have as few SvgElement as possible, since each instance renders Html underneath, which appends a wrapper element to the DOM and calls ReactDOM.render(). By moving SvgElement out for SvgRect/Line, we can wrap multiple low-level SVG components/elements (which is likely to be quite common - e.g. ROIs need drag handles) inside a single SvgElement.

SvgElement and SvgRect/Line also serve two distinct purposes: rendering SVG elements inside VisCanvas for the former, and rendering simple SVG shapes from a tuple of vectors for the latter. Since those are low-level components, I think it's good to keep them separate (single responsibility principle and all that.)

@loichuder
Copy link
Member

Ah yes, right. Go ahead then 👍

@axelboc axelboc force-pushed the selection-validity branch from fd67445 to 42843eb Compare January 16, 2023 08:58
Base automatically changed from selection-validity to main January 16, 2023 09:04
@axelboc axelboc merged commit 9411f8f into main Jan 16, 2023
@axelboc axelboc deleted the stroke-offset branch January 16, 2023 10:35
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

Successfully merging this pull request may close these issues.

2 participants