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