-
Notifications
You must be signed in to change notification settings - Fork 41
Adding the XKCD colour definition to the library #55
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
base: master
Are you sure you want to change the base?
Conversation
Thanks, that was a good read. I'm totally open to integrate xkcd naming into
I would understand that you don't want to push further this PR yourself, and if you don't mind waiting a little, I'll surely integrate this myself, but with a low priority on my list. After said that, you are welcome to make a better PR if you feel so. I'll send a few remark on your code to give you more clues about what to improve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointer !
colour.py
Outdated
@@ -39,7 +39,7 @@ | |||
import hashlib | |||
import re | |||
import sys | |||
|
|||
from XKCD_colour_definition import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoir uppercases, and import *
, in general, I'm not sure this requires to be in another file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware of this good practice, but i'll keep it in mind !
I put it in another file because i wasn't sure adding a thousand line of hard-coded constant would be good for readability, but it can totally be included in the main file !
colour.py
Outdated
@@ -192,6 +192,8 @@ | |||
(255, 255, 255): ['White'] | |||
} | |||
|
|||
COLOR_NAME_TO_RGB.update(XKCD_RGB_TO_COLOR_NAMES) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I can't really see how this even runs : COLOR_NAME_TO_RGB
is not defined at this point, and is defined the next instruction. Please also notice that the format you use is closer to RGB_TO_COLOR_NAME
but a simple update anyway will not make it : the key is meant to be 3-uple of RGB integers... not floats. And the update will overwrite previous names instead of appending them upon key collision which I expect to happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's totally correct, the line should be :
RGB_TO_COLOR_NAME.update(XKCD_RGB_TO_COLOR_NAMES)
I messed the pull request as i originally wrote the code in another folder and then copied it manually in a newly cloned repository to make the pull request, i though i could manage it as it's only one line but apparently not 😅
I though it was working because it wasn't throwing errors but you're right, it's unclean and probably overwriting keys, i'll look into a better solution !
XKCD_colour_definition.py
Outdated
@@ -0,0 +1,950 @@ | |||
XKCD_RGB_TO_COLOR_NAMES = {(0.6745098039215685, 0.76078431372549, 0.8509803921568628): ['XKCD_cloudy_blue'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could totally use these values, but it seems that original content from xkcd defines also RGB 3-uple integer, or at least standard hexa counterparts (I'm refering to https://xkcd.com/color/rgb.txt ). It seems to be a much more solid definition than a float approximation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add also that we don't want to mix 'web' format with 'xkcd' one, and the current structure of colour
is quite friendly to add new formats. So why not use a similar table without the XKCD_
prefix. We would then wait for an attribute Colour().xkcd
that could be read or written to, and a instanciation time keyword Colour(xkcd='light eggplant')
. You could actually start the xkcd
realm as an exact copy of web
realm, but using simply another correspondance table... This would also give you the defaulting of using hexa decimal forms when no xkcd definition exists.
Whooo, first of all, thanks a lot for taking the time to review my request |
Don't hesitate to push unfinished code in this PR to ask for confirmation on some of your choices, this could help you not loosing to much time on things I might refuse. You may probably also want to start by the documentation so as to make sure that we have the same view on what is the objective for the final user. |
Codecov Report
@@ Coverage Diff @@
## master #55 +/- ##
=========================================
Coverage ? 98.72%
=========================================
Files ? 1
Lines ? 236
Branches ? 0
=========================================
Hits ? 233
Misses ? 3
Partials ? 0
Continue to review full report at Codecov.
|
Hi Valentin, So I tried to take into account your remarks and include the XKCD naming scheme in a similar fashion to the web color. |
Hi Valentin, I just wanted to check with you if you had the time to get a look at the modifications I made to the request? Regards, |
Hi, I've been using your module for some time and I was thinking the XKCD colour definition would be a fine addition to it.
https://blog.xkcd.com/2010/05/03/color-survey-results/
This might seem a little bit odd at first as it's not really an accepted standard anywhere but the methodology behind this way of defining colours name is sound and at least one other python library is implementing them (matplotlib). Also, it's fun !
Let me know what you think of it.
I can complete the documentation if you like this pull request.
Also, it might be cleaner to define standard RGB colours in a separate file too so the the architecture is the same for both dictionaries defining colours name but i didn't want to modify too much the library for this first pull request.