A Three.js site presenting 20 world history milestones as double-sided loose-leaf pages, with three views: a leather binder with page-flip animation, a golden timeline, and a dotted globe with great-circle arcs. All textures (paper, leather, registration cards, and 18 hand-drawn sketches) are generated procedurally via Canvas 2D, so no external image assets are needed beyond the Earth map. Includes dev helper scripts for screenshots, ASCII previews, and headless verification.
25 lines
867 B
JavaScript
25 lines
867 B
JavaScript
import fs from 'node:fs';
|
|
import { PNG } from 'pngjs';
|
|
|
|
for (const name of process.argv.slice(2)) {
|
|
const png = PNG.sync.read(fs.readFileSync(name));
|
|
const { width: w, height: h, data } = png;
|
|
let sum = 0, bright = 0, n = 0;
|
|
// 分区域统计
|
|
const zones = { center: 0, left: 0, right: 0 };
|
|
for (let y = 0; y < h; y++) {
|
|
for (let x = 0; x < w; x++) {
|
|
const i = (y * w + x) * 4;
|
|
const lum = 0.299 * data[i] + 0.587 * data[i + 1] + 0.114 * data[i + 2];
|
|
sum += lum; n++;
|
|
if (lum > 40) bright++;
|
|
if (lum > 40) {
|
|
if (x < w / 3) zones.left++;
|
|
else if (x > (2 * w) / 3) zones.right++;
|
|
else zones.center++;
|
|
}
|
|
}
|
|
}
|
|
console.log(`${name}: ${w}x${h} avgLum=${(sum / n).toFixed(1)} brightPct=${((bright / n) * 100).toFixed(1)}% left/center/right=${zones.left}/${zones.center}/${zones.right}`);
|
|
}
|