Skip to content

Full Eyedropper Tool implementation based on pixel sampling #154

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

Closed
Keavon opened this issue May 23, 2021 · 3 comments
Closed

Full Eyedropper Tool implementation based on pixel sampling #154

Keavon opened this issue May 23, 2021 · 3 comments
Labels
Web Involves web programming (TypeScript, Svelte, CSS)

Comments

@Keavon
Copy link
Member

Keavon commented May 23, 2021

Clicking somewhere samples the color of the pixel under the cursor and sets the primary working color to that. Left click to sample for the primary color, right click to sample for the secondary color.

Since it isn't possible to sample colors from a web page using JavaScript, the simplest approach for this is to probably use the browser's collision detection for the SVG shapes to determine which SVG element is being clicked on, then take either its fill or stroke color. However this approach breaks down for shapes with both a fill and a stroke, and shapes with a gradient or non-solid color. Further investigation is required for solutions that support those edge cases, but one possibility would be switching from rendering via the SVG element to rendering with a 2D canvas using the Path2D API for drawing SVG syntax to the canvas. Canvases can have their color sampled from.

A simpler MVP solution is to just check the color or stroke property of the shape clicked in the viewport, similar to #178. That MVP is filed under #303 and was merged in #300.

@Keavon Keavon added Feature Good First Issue Good for newcomers labels May 23, 2021
@Keavon Keavon added Blocked and removed Available labels May 26, 2021
@Keavon Keavon added Rust Web Involves web programming (TypeScript, Svelte, CSS) labels Jun 10, 2021
@Keavon Keavon changed the title New Tool: Eyedropper Tool Implement the Eyedropper Tool to sample working colors Jun 13, 2021
@Keavon Keavon added Available and removed Blocked labels Jun 17, 2021
@Keavon Keavon changed the title Implement the Eyedropper Tool to sample working colors Eyedropper Tool to sample working colors Jul 2, 2021
@Keavon Keavon added P-Medium and removed Good First Issue Good for newcomers P-High labels Jul 3, 2021
@azeemba
Copy link
Contributor

azeemba commented Jul 19, 2021

What do we think about using something like Canvg to parse the SVG and generate the Canvas rendering? Without this, we are still going to have to parse the svg manually since we need to identify svg elements that are not "Paths" and use the appropriate rendering element for them.

@Keavon
Copy link
Member Author

Keavon commented Jul 20, 2021

That's a possibility, although it must be something with zero transient dependencies. Canvg looks to be quite the offender in terms of its transient dependencies. We can very possibly just roll our own with the Path2D API.

@Keavon Keavon changed the title Eyedropper Tool to sample working colors Full Eyedropper Tool implementation based on pixel sampling Jul 24, 2021
@Keavon Keavon removed the Available label Jan 30, 2022
@Keavon Keavon removed this from the Sprint 13 (upcoming) milestone Jan 30, 2022
@Keavon
Copy link
Member Author

Keavon commented Apr 21, 2022

A reasonable medium-term replacement is #545.

@Keavon Keavon closed this as completed Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Web Involves web programming (TypeScript, Svelte, CSS)
Projects
None yet
Development

No branches or pull requests

3 participants