git-hash-art 0.10.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/deploy-www.yml +13 -3
- package/ALGORITHM.md +76 -24
- package/CHANGELOG.md +18 -0
- package/dist/browser.js +938 -251
- package/dist/browser.js.map +1 -1
- package/dist/main.js +940 -251
- package/dist/main.js.map +1 -1
- package/dist/module.js +940 -251
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/performance.test.ts +243 -0
- package/src/__tests__/phase-timing.test.ts +260 -0
- package/src/__tests__/profile-pipeline.test.ts +160 -0
- package/src/lib/archetypes.ts +29 -0
- package/src/lib/canvas/colors.ts +30 -11
- package/src/lib/canvas/draw.ts +147 -50
- package/src/lib/canvas/shapes/complex.ts +19 -10
- package/src/lib/canvas/shapes/sacred.ts +16 -17
- package/src/lib/render.ts +663 -204
|
@@ -149,28 +149,27 @@ export const drawVesicaPiscis: DrawFunction = (ctx, size) => {
|
|
|
149
149
|
export const drawTorus: DrawFunction = (ctx, size) => {
|
|
150
150
|
const outerRadius = size / 2;
|
|
151
151
|
const innerRadius = size / 4;
|
|
152
|
-
|
|
152
|
+
// Adaptive step count: fewer segments for small shapes where detail isn't visible.
|
|
153
|
+
// 36×36 = 1296 segments at full size; at size < 60 we drop to 16×16 = 256.
|
|
154
|
+
const steps = size < 60 ? 16 : size < 150 ? 24 : 36;
|
|
155
|
+
const TWO_PI = Math.PI * 2;
|
|
156
|
+
const angleStep = TWO_PI / steps;
|
|
153
157
|
|
|
154
158
|
ctx.beginPath();
|
|
155
159
|
for (let i = 0; i < steps; i++) {
|
|
156
|
-
const angle1 =
|
|
157
|
-
|
|
160
|
+
const angle1 = i * angleStep;
|
|
161
|
+
const cosA = Math.cos(angle1);
|
|
162
|
+
const sinA = Math.sin(angle1);
|
|
158
163
|
|
|
159
164
|
for (let j = 0; j < steps; j++) {
|
|
160
|
-
const phi1 =
|
|
161
|
-
const phi2 =
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
(outerRadius + innerRadius * Math.cos(phi2)) * Math.cos(angle1);
|
|
169
|
-
const y2 =
|
|
170
|
-
(outerRadius + innerRadius * Math.cos(phi2)) * Math.sin(angle1);
|
|
171
|
-
|
|
172
|
-
ctx.moveTo(x1, y1);
|
|
173
|
-
ctx.lineTo(x2, y2);
|
|
165
|
+
const phi1 = j * angleStep;
|
|
166
|
+
const phi2 = phi1 + angleStep;
|
|
167
|
+
|
|
168
|
+
const r1 = outerRadius + innerRadius * Math.cos(phi1);
|
|
169
|
+
const r2 = outerRadius + innerRadius * Math.cos(phi2);
|
|
170
|
+
|
|
171
|
+
ctx.moveTo(r1 * cosA, r1 * sinA);
|
|
172
|
+
ctx.lineTo(r2 * cosA, r2 * sinA);
|
|
174
173
|
}
|
|
175
174
|
}
|
|
176
175
|
};
|