// Port the key art to a 1989 handheld: four greens, nothing else. // Then make PRESS START blink, the way every title screen did. let shades = ["#0F380F", "#306230", "#8BAC0F", "#9BBC0F"]; let bayer = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5]; let w = ps.doc_width(); let h = ps.doc_height(); // Pass 1: read every pixel's brightness into a histogram, and note // where the gold PRESS START letters and their shadow sit. let lum = []; let hist = []; hist.pad(256, 0); let label = []; for y in 0..h { for x in 0..w { let hex = ps.pixel_get(x, y); let c = color_components(hex); let l = (c[0] * 299 + c[1] * 587 + c[2] * 114) / 1000; lum.push(l); hist[l] += 1; if y > h * 3 / 4 && (hex == "#FFD23C" || hex == "#3A0E2B") { label.push(y * w + x); } } } // Night art is mostly dark. Half rank (histogram equalization), half // raw brightness: shadows open up and highlights still read. let rank = []; let total = 0; for n in hist { total += n; rank.push(total); } print(`equalized ${w * h} px over 256 levels`); // Pass 2: map to 4 shades. A 4x4 ordered dither keeps the // gradients from collapsing into flat blocks. for y in 0..h { for x in 0..w { let l = lum[y * w + x]; let v = (rank[l] * 47 / total + l * 47 / 255) / 2; let level = v / 16; if v % 16 > bayer[(y % 4) * 4 + x % 4] { level += 1; } ps.pixel_set(x, y, shades[level.min(3)]); } } print(`${w * h} px in 4 shades`); // Frame 2 is a copy with the label painted out: each letter pixel // takes the shade just above the label, in its own column. let top = h; for i in label { top = top.min(i / w); } ps_timeline_duplicate_frame(0); for i in label { let x = i % w; ps.pixel_set(x, i / w, ps.pixel_get(x, (top - 1).max(0))); } ps_timeline_set_fps(2); ps_timeline_set_loop_mode("loop"); print(`PRESS START: ${label.len()} px, ${ps_timeline_frame_count()} frames at 2 fps`);