Creating fractals with the chaos game
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

#### 224 lines 5.9 KiB Raw Permalink Blame History

 `` ``` ``` `` ``` ``` `
` ` ` ``` ``` `
` ` ` ``` ``` ` {#if controls}` ` ` ` {#each \$points as point}` ` ` ` {/each}` ` ` ``` ``` ` {#each \$points as point, index}` ` points.set([` ` ...\$points.slice(0, index),` ` Matrix.columnVector([evt.detail.x, evt.detail.y, 1]),` ` ...\$points.slice(index + 1)` ` ])}` ` />` ` {/each}` ``` ``` ` {#each \$ifs as current, index}` ` {` ` const point = Matrix.columnVector([evt.detail.x, evt.detail.y, 1]);` ``` ``` ` const vec1 = Matrix.sub(\$points[index], \$center);` ` const vec2 = Matrix.sub(point, \$center);` ``` ``` ` const nextRatio = 1 - vec1.dot(vec2) / vec1.dot(vec1);` ``` ``` ` if (evt.detail.shift)` ` {` ` ratios.set(` ` Array.from({length: \$ratios.length}).fill(nextRatio)` ` );` ` }` ` else` ` {` ` ratios.set([` ` ...\$ratios.slice(0, index),` ` nextRatio,` ` ...\$ratios.slice(index + 1)` ` ]);` ` }` ` }}` ` />` ` {/each}` ` {/if}` `
` ```
``` ``` ```