rc-1.2.1 - new patterns and refactoring #36

Merged
bombinans merged 8 commits from rc-1.2.1 into main 2025-04-20 06:04:44 +00:00
Showing only changes of commit 6a0d2470a1 - Show all commits

View File

@ -11,8 +11,10 @@ const RADIUS_OPTS = [
"right-down", "right-down",
"left-up", "left-up",
"left-down", "left-down",
"in", "circle-in",
"out", "circle-out",
"hyper-in",
"hyper-out",
"noise", "noise",
]; ];
@ -26,8 +28,10 @@ const RADIUS_DESC = {
"right-down": "getting larger towards the lower right", "right-down": "getting larger towards the lower right",
"left-up": "getting larger towards the upper left", "left-up": "getting larger towards the upper left",
"left-down": "getting larger towards the lower left", "left-down": "getting larger towards the lower left",
"in": "getting larger in the centre", "circle-in": "forming a circle at the centre",
"out": "getting larger at the edges", "circle-out": "leaving a circular gap at the centre",
"hyper-in": "forming a starlike pattern at the centre",
"hyper-out": "leaving a starlike pattern gap in the centre",
"noise": "of random sizes", "noise": "of random sizes",
} }
@ -35,6 +39,7 @@ function distance(dx, dy) {
return Math.sqrt(dx ** 2 + dy ** 2); return Math.sqrt(dx ** 2 + dy ** 2);
} }
function int_range(v1, v2) { function int_range(v1, v2) {
const vs = [v1, v2]; const vs = [v1, v2];
vs.sort((a, b) => a - b); vs.sort((a, b) => a - b);
@ -92,16 +97,14 @@ class DotMaker {
return 0.5 * maxr * (d.x + d.y) / this.wh; return 0.5 * maxr * (d.x + d.y) / this.wh;
case "left-down": case "left-down":
return 0.5 * maxr * (this.width - d.x + d.y) / this.wh; return 0.5 * maxr * (this.width - d.x + d.y) / this.wh;
case "out": case "circle-out":
return 2 * maxr * distance((d.x - this.cx), (d.y - this.cy)) / this.wh; return 2 * maxr * distance((d.x - this.cx), (d.y - this.cy)) / this.wh;
case "in": case "circle-in":
return 2 * maxr * (0.5 * this.wh - distance((d.x - this.cx), (d.y - this.cy))) / this.wh; return 2 * maxr * (0.5 * this.wh - distance((d.x - this.cx), (d.y - this.cy))) / this.wh;
case "hyper-in":
// case "hyper-out": return maxr * Math.abs((d.x - this.cx) * (d.y - this.cy)) / this.wh;
// return 2 * maxr * Math.abs(d.x - this.cx) (d.y - this.cy)) / this.width; case "hyper-out":
// case "hyper-in": return maxr * (1 - Math.abs((d.x - this.cx) * (d.y - this.cy)) / this.wh);
// return 2 * maxr * (0.5 * this.width - distance((d.x - this.cx), (d.y - this.cy))) / this.width;
case "noise": case "noise":
return maxr * Math.random(); return maxr * Math.random();
default: default: