commit bdbb9f81e0eae2d903f8a5ca33f3634c8b9e316f Author: Christian Lawson-Perfect Date: Sun Feb 9 20:08:41 2025 +0000 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8bc0f76 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.make.* \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..b802e78 --- /dev/null +++ b/index.html @@ -0,0 +1,18 @@ + + + + + + A thing made by CLP + + + + +
+ + + + +
+ + \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..dd008a9 --- /dev/null +++ b/script.js @@ -0,0 +1,95 @@ +const svg = document.querySelector('svg'); + +const d = ([x,y]) => { + const u = -0.3; + const s = -0.2; + const t = 0.1; + return [0.1-y*u+x*s, x*u+y*s + Math.sin(x*5)*t]; +} + +let all_points = []; + +let num_path = 1; + +function sqdist([x1,y1], [x2,y2]) { + return (x2-x1)**2 + (y2-y1)**2; +} + +function element(name,attr,content) { + const e = document.createElementNS('http://www.w3.org/2000/svg',name); + if(attr) { + Object.entries(attr).forEach(([k,v])=>e.setAttribute(k,v)); + } + if(content!==undefined) { + e.textContent = content; + } + return e; +} + +function trace_path(pos, fn, h, steps) { + num_path += 1; + h = h || 0.01; + steps = steps || 1000; + const points = []; + for(let i=0;i `L ${x} ${y}`).join(' ')}); + svg.append(path); + all_points = all_points.concat(points); + return points; +} + +const occupied = []; + +const bucket_size = 200; +function bucket_position([x,y]) { + const ix = Math.floor((x+2)/4*bucket_size); + const iy = Math.floor((y+2)/4*bucket_size); + return iy*bucket_size + ix; +} + +function is_occupied(pos, n) { + const r = occupied[bucket_position(pos)]; + return r && r!=n; +} + +function occupy(pos, n) { + const i = bucket_position(pos); + occupied[i] = n; + const x = (i % bucket_size)/bucket_size; + const y = ((i - x) / bucket_size)/bucket_size; + console.log(pos, x,y); + const dot = element('circle', {r:1.5/bucket_size, fill: `hsl(${n*20}, 70%, 50%)`, cx: (x*4-2), cy: y*4-2, 'fill-opacity': 0.1}); + svg.append(dot); +} + +function randrange(a,b) { + return (b-a)*Math.random() + a; +} + +for(let i=0;i<400; i++) { + const r = Math.sqrt(Math.random())*1.5; + const an = randrange(0, 2*Math.PI); + const pos = [r*Math.cos(an), r*Math.sin(an)]; + plot_path(pos, d) +} + +window.bucket_position = bucket_position; +console.log(occupied); \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..c95d3fa --- /dev/null +++ b/style.css @@ -0,0 +1,11 @@ +path { + fill: none; + stroke: black; + stroke-width: 0.01; + stroke-opacity: 0.5; +} + +line.axis { + fill: none; + stroke-width: 0.01; +} \ No newline at end of file