Skip to content

Added color picker tool, activated pressing Ctrl #317

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DanX3
Copy link
Contributor

@DanX3 DanX3 commented Nov 28, 2024

I added a color picker function, similar to many other editors
By pressing Ctrl, the picker is activated and a new color is selected based on the cursor position on the canvas

The color picking function (ColorPickerTool.gd) is somewhat complicated but I couldn't find a way to read the screen directly from GDScript. I'm open to suggestions

@DanX3 DanX3 marked this pull request as draft November 28, 2024 09:42
@DanX3 DanX3 marked this pull request as ready for review November 28, 2024 10:45
@tafode
Copy link
Contributor

tafode commented Mar 14, 2025

@DanX3 I think the way you select the nearest color with the hue, is causing some problem if you use similar colors as your background. E.g. if you use a color like #1c0535 with the default settings and you draw a circle somewhere. The color is also picked when you click inside the circle or below the circle. Also if you use similar colors near each other it sometimes doesn't change the color at all and sometimes it selects a different color than the one you try to select.

I will make a video of the two later.

@tafode
Copy link
Contributor

tafode commented Mar 14, 2025

Here is now the Video of the issue:

https://youtu.be/U13blNgS2VI

Probably there is a way to fetch/select the stroke from below the cursor and get the color from that stroke. Just an idea, that came to my mind.

@DanX3
Copy link
Contributor Author

DanX3 commented Mar 15, 2025

Thank you for your feedback @tafode!
I updated the code to ignore the background color and the grid as well, so that issue with darker tones does not happen anymore.
Actually my first version was exactly like you suggested, but it was becoming a complicated geometry mess: I had to check for distance from each segment instead of points, to be able to pick the color also from in between points. Also to be more precise, I had to check for line thickness, and it was not scaling very well with a lot of lines.
The color picking with the color based approach just suffers from hue shifting due to antialiasing but is waaay less code to manage

@tafode
Copy link
Contributor

tafode commented Mar 15, 2025

Sounds good, I will try the new version later.

Ok, I thought you couldprobably re-usr some things from the select tool, but I guess that would only work if you would draw a rectangle.

@tafode
Copy link
Contributor

tafode commented Mar 16, 2025

🤔Somehow sometimes it still gets the color, when you click somewhere where no stroke is. But I guess in generel it works.

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