Compare commits
	
		
			2 Commits
		
	
	
		
			583feac704
			...
			c9c970036f
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					c9c970036f | ||
| 
						 | 
					90c6a575b2 | 
@ -1,5 +1,10 @@
 | 
			
		||||
# CHANGELOG.md
 | 
			
		||||
 | 
			
		||||
## v1.0.2
 | 
			
		||||
 | 
			
		||||
* Fixed bug which was stopping slanted grids
 | 
			
		||||
* Added noise
 | 
			
		||||
 | 
			
		||||
## v1.0.1
 | 
			
		||||
 | 
			
		||||
Added palettes
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,6 @@
 | 
			
		||||
// calculate tiles
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const RADIUS_OPTS = [ 
 | 
			
		||||
	"const",
 | 
			
		||||
	"right",
 | 
			
		||||
@ -12,12 +13,21 @@ const RADIUS_OPTS = [
 | 
			
		||||
	"left-down",
 | 
			
		||||
	"in",
 | 
			
		||||
	"out",
 | 
			
		||||
	"noise",
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
function distance(dx, dy) {
 | 
			
		||||
	return Math.sqrt(dx ** 2 + dy ** 2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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]);
 | 
			
		||||
	return [...Array(high - low + 1).keys()].map((i) => i + low);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class DotMaker {
 | 
			
		||||
	constructor(width) {
 | 
			
		||||
		this.width = width;
 | 
			
		||||
@ -30,19 +40,17 @@ class DotMaker {
 | 
			
		||||
			return [];
 | 
			
		||||
		}
 | 
			
		||||
		const ps = [];
 | 
			
		||||
		const imin = -this.width;
 | 
			
		||||
		const imax = this.width / m;
 | 
			
		||||
		for( let i = imin; i <= imax; i++ ) {
 | 
			
		||||
			const jmin = m * i + (m - n) * this.width;
 | 
			
		||||
			const jmax = m * i;
 | 
			
		||||
			for( let j = jmin; j <= jmax; j++ ) {
 | 
			
		||||
		const is = int_range(-this.width, this.width / m)
 | 
			
		||||
		is.map((i) => {
 | 
			
		||||
			const js = int_range(m * i + (m - n) * this.width, m * i)
 | 
			
		||||
			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 ) {
 | 
			
		||||
					ps.push({i:i, j:j, x:x, y:y});
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
			});
 | 
			
		||||
		});
 | 
			
		||||
		return ps;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -70,6 +78,14 @@ class DotMaker {
 | 
			
		||||
	      		return 2 * maxr * distance((d.x - this.cx), (d.y - this.cy)) / this.width;
 | 
			
		||||
	      	case "in":
 | 
			
		||||
	      		return 2 * maxr * (0.5 * this.width - distance((d.x - this.cx), (d.y - this.cy))) / this.width;
 | 
			
		||||
 | 
			
		||||
	      	// case "hyper-out":
 | 
			
		||||
	      	// 	return 2 * maxr * Math.abs(d.x - this.cx) (d.y - this.cy)) / this.width;
 | 
			
		||||
	      	// case "hyoer-in":
 | 
			
		||||
	      	// 	return 2 * maxr * (0.5 * this.width - distance((d.x - this.cx), (d.y - this.cy))) / this.width;
 | 
			
		||||
 | 
			
		||||
	      	case "noise":
 | 
			
		||||
	      		return maxr * Math.random();
 | 
			
		||||
	    	default:
 | 
			
		||||
	      		return maxr;
 | 
			
		||||
	  }
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@ toc: false
 | 
			
		||||
 | 
			
		||||
<h1>poptimal</h1>
 | 
			
		||||
 | 
			
		||||
<p>v1.0.1 | by <a href="https://mikelynch.org">mike lynch</a> | <a href="https://aus.social/@mikelynch">@mikelynch@aus.social</a> | <a href="https://git.tilde.town/bombinans/poptimal">source</a></p>
 | 
			
		||||
<p>v1.0.2 | by <a href="https://mikelynch.org">mike lynch</a> | <a href="https://aus.social/@mikelynch">@mikelynch@aus.social</a> | <a href="https://git.tilde.town/bombinans/poptimal">source</a></p>
 | 
			
		||||
 | 
			
		||||
<div class="grid grid-cols-2">
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user