/** * 按《国旗制法说明》的比例计算五角星布局。 * * 制式(旗面 30 × 20 单位): * 大星:中心 (5,5),外接圆半径 3 * 小星:中心 (10,2) (12,4) (12,7) (10,9),外接圆半径 1 * 四颗小星各有一角尖正对大星中心 * * 输出:可直接粘进 SVG 的 列表 */ const BIG = { x: 5, y: 5, r: 3 } const SMALL = [ { x: 10, y: 2 }, { x: 12, y: 4 }, { x: 12, y: 7 }, { x: 10, y: 9 } ] function layout({ k, ox, oy, sizes }) { const B = { x: ox + BIG.x * k, y: oy + BIG.y * k } const lines = [] lines.push(``) for (const s of SMALL) { const S = { x: ox + s.x * k, y: oy + s.y * k } const deg = (Math.atan2(B.y - S.y, B.x - S.x) * 180) / Math.PI + 90 lines.push(``) } return { markup: lines.join('\n '), B, smallR: k, bigR: BIG.r * k } } const k = Number(process.argv[2] ?? 7.2) const ox = Number(process.argv[3] ?? -8) const oy = Number(process.argv[4] ?? -14) const out = layout({ k, ox, oy }) console.log(`k=${k} origin=(${ox},${oy}) bigR=${out.bigR.toFixed(1)} smallR=${out.smallR.toFixed(1)} ratio=1:3`) console.log(' ' + out.markup)