Fork me on GitHub
#clojurescript
<
2024-01-19
>
Nundrum00:01:16

Am I overlooking some simple way to turn a "hue" into an RGB value? It seems odd that you can use various colorspaces in CSS, but the same doesn't seem to be exposed through JS.

valtteri05:01:02

Check goog.color in closure library

Nundrum13:01:51

I realized something last night right after getting in bed - I can just use "hsl(h,s,l)" in the setProperty call :man-facepalming:

👀 1
💡 1
vraid19:01:53

Could anyone recommend a (edit: seedable) pseudrandom number generator library/code for clojurescript? Alternatively an algorithm that's easy to implement. It doesn't have to be cryptographically secure.

haris19:01:48

ClojureScript can also consume from any npm lib, so randomatic, faker, etc. are all viable.

👍 1
vraid19:01:29

I should have clarified a seedable pseudorandom number generator, which Math.random() is not

haris19:01:55

Ah, that's makes more sense. You could use Math.sin instead if cryptographic security isn't a concern.

vraid19:01:14

How would Math.sin be used in this context?

haris19:01:16

This is JS, but should be easy to convert to CLJS:

function seededRandom(seed: number) {
  let x = Math.sin(seed++) * 10000;
  return x - Math.floor(x);
}
Worked well for projects I used

vraid19:01:19

It's still important that they're evenly distributed, so i think i'll go for the npm route 🙂

👍 1
Chris McCormick20:01:29

@U0552GV2X32 I'm a fan of seedrandom: https://github.com/davidbau/seedrandom - it has a cool mode where you can install it as the global Math.random() to get seeding for anything that calls that (including rand-nth etc.).

vraid20:01:46

@UUSQUGUF3 Looks promising, i'll check it out

vraid03:01:01

Works like a charm, thanks!

❤️ 1