-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor colors #4
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
…sts for conversions that should fail.
[x] | ||
(math-round (* x 255))) | ||
|
||
(defn partition-string |
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.
this might be easier to write by turning the string to a seq of characters, using the actual partition method and then mapping str over the output of it.
"Normalizes a float 0 <= x <= 255 to 0 <= x <= 1." | ||
[x] | ||
(let [v (double (/ x 255))] | ||
(if (= (double (int v)) v) |
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 just cast it to int directly, checking won't really save you anything
|
||
(defn ratio?->double [x] | ||
(cond (nil? x) 1 | ||
(ratio? x) (double x) |
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.
probably here too, you can just cast it to double if it's not nil. also mapping nil to 1 is a bit odd. did you mean 0?
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.
It's used where you convert a ratio between 0 and 1 to a float between 0 and 1, if alpha is nil
, the default value is 1. Honestly, it was also confused with it, I should change it.
No description provided.