Skip to content

Conversation

JanSuran03
Copy link
Owner

No description provided.

[x]
(math-round (* x 255)))

(defn partition-string
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Owner Author

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.

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