aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarvin Borner2024-04-07 21:06:36 +0200
committerMarvin Borner2024-04-07 21:08:09 +0200
commit83fe617a787a31abb19d0e58f4b39b41cb9ff1ad (patch)
treeeb5ab330963ac2f620a226443c0153879e58653d
parent49d538dd417ce322a918b089b4b67c56a7240634 (diff)
Cantor and more
hihi
-rw-r--r--bruijn/Experiments.bruijn7
-rw-r--r--bruijn/Screen.bruijn1
-rw-r--r--canvasWorker.js2
-rw-r--r--index.html37
-rw-r--r--main.js26
-rw-r--r--style.css20
6 files changed, 48 insertions, 45 deletions
diff --git a/bruijn/Experiments.bruijn b/bruijn/Experiments.bruijn
index d1bc116..6b837c6 100644
--- a/bruijn/Experiments.bruijn
+++ b/bruijn/Experiments.bruijn
@@ -9,6 +9,7 @@ t-square-1 [[build tl tr bl br] mut]
bl ^(~(~0))
br ^(~(~(~0)))
+# TODO: 1/2
t-square-2 [[build tl tr bl br] mut]
mut y* ([[[[build 3 2 1 (build b w w b)]]]] : ([[[[build 3 2 (build w b b w) 0]]]] : ([[[[build 3 (build w b b w) 1 0]]]] : {}[[[[build (build b w w b) 2 1 0]]]])))
tl ^0
@@ -24,3 +25,9 @@ sierpinski-carpet [[build tl tr bl br] mut]
br ^(~(~(~0)))
sierpinski-triangle [y [build 0 b 0 0]]
+
+cantor-dust [y [build tl tr bl br]]
+ tl [[0 1 1 1 1]] (build 0 b b b)
+ tr [[0 1 1 1 1]] (build b 0 b b)
+ bl [[0 1 1 1 1]] (build b b 0 b)
+ br [[0 1 1 1 1]] (build b b b 0)
diff --git a/bruijn/Screen.bruijn b/bruijn/Screen.bruijn
index 465df25..5100aa9 100644
--- a/bruijn/Screen.bruijn
+++ b/bruijn/Screen.bruijn
@@ -75,6 +75,7 @@ map [&[[[[[0 (5 4) (5 3) (5 2) (5 1)]]]]]]
:test (map invert empty) (build w w w w)
+# splits single pixel to quadrant of same color
qsplit map [w? 0 (build w w w w) (build b b b b)]
:test (qsplit (build b w b w)) (build (build b b b b) (build w w w w) (build b b b b) (build w w w w))
diff --git a/canvasWorker.js b/canvasWorker.js
index a869810..0f17547 100644
--- a/canvasWorker.js
+++ b/canvasWorker.js
@@ -28,7 +28,7 @@ const initGL = () => {
attribute vec2 a_position;
uniform vec2 u_resolution;
void main() {
- vec2 inverted = vec2(a_position.x, u_resolution.y - a_position.y - 1.0); // !! :)
+ vec2 inverted = vec2(a_position.x, u_resolution.y - a_position.y); // !! :)
vec2 zeroToOne = inverted / u_resolution;
vec2 zeroToTwo = zeroToOne * 2.0;
vec2 clipSpace = zeroToTwo - 1.0;
diff --git a/index.html b/index.html
index 78684b5..40f7a26 100644
--- a/index.html
+++ b/index.html
@@ -9,17 +9,6 @@
<body>
<main>
<canvas height="800" width="800" id="canvas"></canvas>
- <!-- <div> -->
- <!-- <div class="inputWrap"> -->
- <!-- Reduction mode: -->
- <!-- <select id="reductionMode"> -->
- <!-- <option value="auto" selected>Reduce to normal form</option> -->
- <!-- <option value="slider">Reduce by sliding</option> -->
- <!-- <option value="click">Reduce by clicking</option> -->
- <!-- </select> -->
- <!-- </div> -->
- <!-- <input type="range" min="0" max="20" value="0" id="slider" /> -->
- <!-- </div> -->
<div>
<div class="inputWrap">
Load preset:
@@ -51,28 +40,36 @@ invert = \\\((2 0) 1)
Invert
</option>
<option
- value="00010001010101000000000001010101101111101111011101100101000001101100000110100101000001101100000110010100000110110000010100101000001101100000110010100000110110000010010100000110110000010100101000001101100000110010100000110110000010010100000110110000010010100000110110000010100100010001010100010001110000101110110100001110000101110110100000000101100000000101000000010110111011001111110111001011111110111110110000010000110110100101010001000111000010111011010000111000010111011010000000010110000000010100000001011011101100111111011100101111111011111011000001000000101010001000111000010111011010000111000010111011010000000010110000000010111111100111111011101101101100101010001000111000010111011010000111000010111011010000000010110000000010100000001011011101100111111011100101111111011111011000001000000101110111010101001010000000101101110110000000000101010100000000000101010110111110111101110110111101110110000010010100000001011011101100000000001010101000000000001010101101111101111011101101111011100000101001010000000101101110110000000000101010100000000000101010110111110111101110110111100000101101001000101000000010110111011010000010000000000101010100000000000101010110111110111101110110000010111011010"
+ value="y = \(\(1 (0 0)) \(1 (0 0)))
+\(y \\((((0 1) \\1) \\0) 1))"
+ >
+ Diagonal
+ </option>
+ <option
+ value="-- note how no white gets drawn since the highlighted parts would be infinitely detailed
+y = \(\(1 (0 0)) \(1 (0 0)))
+\(y \\((((0 1) \\0) 1) 1))"
>
- T-square v1
+ Sierpiński triangle
</option>
<option
- value="00010001010101000000000001010101101111101111011101100101000001101100000110100101000001101100000110010100000110110000010100101000001101100000110010100000110110000010010100000110110000010100101000001101100000110010100000110110000010010100000110110000010010100000110110000010100100010001010100010001110000101110110100001110000101110110100000000101100000000101000000010110111011001111110111001011111110111110110000010000110110100101010001000111000010111011010000111000010111011010000000010110000000010100000001011011101100111111011100101111111011111011000001000000101010001000111000010111011010000111000010111011010000000010110000000010111111100111111011101101101100101010001000111000010111011010000111000010111011010000000010110000000010100000001011011101100111111011100101111111011111011000001000000101110111010101001010000000101101110110000000000101010100000000000101010110111110111101110110111101110110010101010000000000010101011011111011110111011000001000001100000110000010010100000001011011101100000000001010101000000000001010101101111101111011101101111011100101010100000000000101010110111110111101110110000011000001000001000001101001010000000101101110110000000000101010100000000000101010110111110111101110110111100101010100000000000101010110111110111101110110000011000001000001000001101101001000101000000010110111011010000010000000000101010100000000000101010110111110111101110110010101010000000000010101011011111011110111011000001000001100000110000010111011010"
+ value="00010001010101000000000001010101101111101111011101100101000001101100000110100101000001101100000110010100000110110000010100101000001101100000110010100000110110000010010100000110110000010100101000001101100000110010100000110110000010010100000110110000010010100000110110000010100100010001010100010001110000101110110100001110000101110110100000000101100000000101000000010110111011001111110111001011111110111110110000010000110110100101010001000111000010111011010000111000010111011010000000010110000000010100000001011011101100111111011100101111111011111011000001000000101010001000111000010111011010000111000010111011010000000010110000000010111111100111111011101101101100101010001000111000010111011010000111000010111011010000000010110000000010100000001011011101100111111011100101111111011111011000001000000101110111010101001010000000101101110110000000000101010100000000000101010110111110111101110110111101110110000010010100000001011011101100000000001010101000000000001010101101111101111011101101111011100000101001010000000101101110110000000000101010100000000000101010110111110111101110110111100000101101001000101000000010110111011010000010000000000101010100000000000101010110111110111101110110000010111011010"
>
- T-square v2 (1/2) TODO
+ T-square
</option>
<option
value="000100010101010000000000010101011011111011110111011001010000011011000001101001010000011011000001100101000001101100000101001010000011011000001100101000001101100000100101000001101100000101001010000011011000001100101000001101100000100101000001101100000100101000001101100000101001000100010101000100011100001011101101000011100001011101101000000001011000000001010000000101101110110011111101110010111111101111101100000100001101101001010100010001110000101110110100001110000101110110100000000101100000000101000000010110111011001111110111001011111110111110110000010000001010100010001110000101110110100001110000101110110100000000101100000000101111111001111110111011011011001010100010001110000101110110100001110000101110110100000000101100000000101000000010110111011001111110111001011111110111110110000010000001011101110101010010100000001011011101100000000001010101000000000001010101101111101111011101101111011101100101010100000000000101010110111110111101110110010101010000000000010101011011111011110111011000001000001100000110000011000001100000110000010010100000001011011101100000000001010101000000000001010101101111101111011101101111011100101010100000000000101010110111110111101110110000011001010101000000000001010101101111101111011101100000110000010000011000001100000100000110100101000000010110111011000000000010101010000000000010101011011111011110111011011110010101010000000000010101011011111011110111011000001100000100101010100000000000101010110111110111101110110000011000001100000100000110000011011010010001010000000101101110110100000100000000001010101000000000001010101101111101111011101100101010100000000000101010110111110111101110110000010000011000001100101010100000000000101010110111110111101110110000011000001100000110000010111011010"
>
- Sierpinski carpet
+ Sierpiński carpet (variant)
</option>
<option
- value="-- note how no white gets drawn since the highlighted parts would be infinitely detailed
+ value="s=\\0
+quad = \\((((0 1) 1) 1) 1)
y = \(\(1 (0 0)) \(1 (0 0)))
-\(y \\((((0 1) \\0) 1) 1))"
+\(y \\((((0 (quad \((((0 2) s) s) s))) (quad \((((0 s) 2) s) s))) (quad \((((0 s) s) 2) s))) (quad \((((0 s) s) s) 2))))"
>
- Sierpinski "triangle"
+ Cantor dust
</option>
- <option value="">Cantor dust</option>
<option value="">Vicsek saltire</option>
</select>
</div>
diff --git a/main.js b/main.js
index 119a523..6b005f3 100644
--- a/main.js
+++ b/main.js
@@ -1,3 +1,5 @@
+let MAXRES = 2;
+
let errors = [];
const error = (s) => {
errors.push(s);
@@ -461,7 +463,7 @@ const snf = (_t) => {
const reduceLoop = (worker, root, _t) => {
const stack = [{ ctx: root, t: _t }];
- for (let i = 0; stack.length > 0 && i < 4 ** 10; i++) {
+ for (let i = 0; stack.length > 0; i++) {
// console.log(i, stack.length);
let [{ ctx, t }] = stack.splice(
Math.floor(Math.random() * stack.length),
@@ -480,6 +482,10 @@ const reduceLoop = (worker, root, _t) => {
try {
t = snf(t);
} catch (e) {
+ if (e.message == "too much recursion")
+ error(
+ "your term most probably has some logical error (e.g. by not converging to a screen); if not, lmk",
+ );
error(e);
return null;
}
@@ -502,23 +508,7 @@ const reduceLoop = (worker, root, _t) => {
stack.push({ ctx: drawBottomRight(worker, ctx, toColor(br)), t: br });
} else {
// TODO: could we risk gnfing here?
- drawAt(ctx.x, ctx.y, toColor(t));
+ drawAt(worker, ctx.x, ctx.y, toColor(t));
}
}
};
-
-/* interface */
-
-// window.reductionMode.addEventListener("change", () => {
-// const state = window.reductionMode.value;
-// if (state === "auto") {
-// window.slider.disabled = true;
-// window.slider.style.opacity = 0;
-// } else if (state === "slider") {
-// window.slider.disabled = false;
-// window.slider.style.opacity = 100;
-// } else if (state === "click") {
-// window.slider.disabled = true;
-// window.slider.style.opacity = 0;
-// }
-// });
diff --git a/style.css b/style.css
index 5c6db87..752487e 100644
--- a/style.css
+++ b/style.css
@@ -2,7 +2,7 @@ html, body {
padding: 0;
margin: 0;
width: 100%;
- background-color: #fafafa;
+ background-color: white;
}
main {
@@ -25,22 +25,30 @@ canvas {
width: auto;
flex-basis: auto;
border: 1px solid black;
-}
-
-input#slider {
- width: 100%;
- opacity: 0;
+ background-color: white;
}
textarea#term {
width: 100%;
font-size: 1.3em;
+ border: 1px solid black;
+ box-sizing: border-box;
}
button#render {
+ cursor: pointer;
width: 100%;
height: 3em;
font-size: 2em;
+ border: 1px solid black;
+ border-radius: 0;
+ background-color: white;
+}
+
+select {
+ border: 1px solid black;
+ background-color: white;
+ margin: 8px;
}
span#error {