- HR도(헤르츠스프룽-러셀 도표) = 별의 '지도'이자 진화 경로도
- 가로축 표면 온도(오른쪽=차가움), 세로축 밝기(광도)(위=밝음)
- 별을 찍으면 진화 단계별로 특정 위치에 모임 — 아래는 대화형 HR도
let stars = [];
function col(tx) {
return p.color(p.map(tx, 0, 1, 130, 255), p.map(tx, 0, 1, 175, 120), p.map(tx, 0, 1, 255, 60));
}
p.setup = function() {
p.createCanvas(el.clientWidth, el.clientHeight);
for (let i = 0; i < 60; i++) { let tx = p.random(0.05, 0.95); stars.push({ x: tx, y: tx + p.random(-0.05, 0.05), g: 'MS' }); }
for (let i = 0; i < 12; i++) stars.push({ x: p.random(0.65, 0.95), y: p.random(0.06, 0.3), g: 'RG' });
for (let i = 0; i < 12; i++) stars.push({ x: p.random(0.1, 0.4), y: p.random(0.7, 0.92), g: 'WD' });
};
p.draw = function() {
p.background(12, 14, 32);
const m = 46, W = p.width - m * 2, H = p.height - m * 2;
p.stroke(120); p.strokeWeight(1);
p.line(m, m, m, m + H); p.line(m, m + H, m + W, m + H);
p.noStroke(); p.fill(185); p.textSize(12); p.textAlign(p.CENTER);
p.text('← 뜨거움 표면 온도 차가움 →', m + W / 2, m + H + 28);
p.push(); p.translate(m - 30, m + H / 2); p.rotate(-p.HALF_PI); p.text('어두움 ← 광도 → 밝음', 0, 0); p.pop();
for (const s of stars) {
const px = m + s.x * W, py = m + s.y * H;
const tw = 1 + 0.4 * Math.sin(p.frameCount * 0.05 + s.x * 20);
p.fill(col(s.x));
const r = (s.g === 'RG' ? 12 : s.g === 'WD' ? 5 : 7) * tw;
p.ellipse(px, py, r, r);
}
p.textSize(13);
p.fill(120, 200, 255); p.text('주계열', m + W * 0.5, m + H * 0.5);
p.fill(255, 120, 90); p.text('적색거성', m + W * 0.8, m + H * 0.16);
p.fill(200, 220, 255); p.text('백색왜성', m + W * 0.25, m + H * 0.86);
};