Now patterns in the bot version go all the way to the edges

This commit is contained in:
Mike Lynch 2025-03-26 18:32:54 +11:00
parent 547baa9586
commit b789f4fd99
2 changed files with 6 additions and 6 deletions

View File

@ -38,8 +38,8 @@ function distance(dx, dy) {
function int_range(v1, v2) {
const vs = [v1, v2];
vs.sort((a, b) => a - b);
const low = Math.floor(vs[0]);
const high = Math.ceil(vs[1]);
const low = Math.floor(vs[0] - 1);
const high = Math.ceil(vs[1] + 1);
return [...Array(high - low + 1).keys()].map((i) => i + low);
}
@ -50,7 +50,7 @@ class DotMaker {
this.cy = 0.5 * width;
}
dots(m, n) {
dots(m, n, clip) {
if( m - n === 0 ) {
return [];
}
@ -61,7 +61,7 @@ class DotMaker {
js.map((j) => {
const x = (j - m * i) / (m - n);
const y = m * (x + i);
if( x > 0 && y > 0 && x < this.width && y < this.width ) {
if( !clip || (x > 0 && y > 0 && x < this.width && y < this.width) ) {
ps.push({i:i, j:j, x:x, y:y});
}
});

View File

@ -118,8 +118,8 @@ if( palette_fn ) {
```js
const dots1 = dm.dots(1 / m1, n1);
const dots2 = dm.dots(1 / m2, n2);
const dots1 = dm.dots(1 / m1, n1, true);
const dots2 = dm.dots(1 / m2, n2, true);
```