1
0
mirror of https://github.com/osmarks/random-stuff synced 2025-09-06 04:17:57 +00:00

fractalart things

This commit is contained in:
2021-04-10 19:31:25 +01:00
parent c65a55be67
commit d8ddcc6c3e
4 changed files with 173 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ edition = "2018"
[dependencies]
image = { version = "0.23", features = ["png"], default-features = false }
nanorand = { version = "0.5", features = ["std", "rdseed", "wyrand", "tls"], default-features = false }
nanorand = { version = "0.5", features = ["std", "rdseed", "wyrand"], default-features = false }
hsl = "0.1.1"
gumdrop = "0.8"
smallvec = "1.4.1"

View File

@@ -45,7 +45,7 @@ fn mod_channel(rng: &mut WyRand, range: u16, n: u16) -> u16 {
let rand: u16 = rng.generate::<u16>() % (range * 2 + 2);
let o = ((n as u32) + (rand as u32)).saturating_sub(range as u32);
// avoid weird artifacts - just directly using `as` truncates it, i.e. drops the high bytes, which leads to integer-overflow-like issues
min(o, 65535) as u16
max(min(o, 65535), 1) as u16
}
// randomly adjust all the channels in a color by `range`