Skip to content

Commit 1e0671c

Browse files
authored
Add color modes for HSL, binary, RGB, and livingstone
1 parent 914ff8f commit 1e0671c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

cnn/cnn2.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,27 @@ function drawFractal() {
217217
const g = Math.floor(v * 255);
218218
color = `rgb(${g},${g},${g})`;
219219
}
220+
else if (mode === "hsl") {
221+
color = `hsl(${v * 360},100%,50%)`;
222+
}
223+
else if (mode === "binary") {
224+
const s = Math.round(raw);
225+
color = (s % 2 === 0) ? "#000" : "#fff";
226+
}
227+
else if (mode === "rgb") {
228+
const s = Math.round(raw);
229+
const p = ["#f00", "#0f0", "#00f"];
230+
color = p[((s % 3) + 3) % 3];
231+
}
220232
else if (mode === "mod4") {
221233
const s = Math.round(raw);
222234
color = (s % 4 === 0 || s % 4 === 1) ? "#000" : "#fff";
223235
}
236+
else if (mode === "livingstone") {
237+
const s = Math.round(raw);
238+
const p = ["#000", "#5f5", "#f55", "#ff5"];
239+
color = p[((s % 4) + 4) % 4];
240+
}
224241
else if (mode === "alleycat") {
225242
const s = Math.round(raw);
226243
const p = ["#000", "#5ff", "#f5f", "#fff"];

0 commit comments

Comments
 (0)