Created
February 12, 2026 17:14
-
-
Save patakk/a35eefc54248bc58d8a974e9d633c722 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const DPI = 600; | |
| const MM_PER_IN = 25.4; | |
| // === RETRANSFER CANVAS (source of truth) === | |
| const TOTAL_W = 2100; | |
| const TOTAL_H = 1344; | |
| // === PHYSICAL CARD SIZE (ISO ID-1) === | |
| const CARD_W_MM = 85.6; | |
| const CARD_H_MM = 54; | |
| // convert card size to pixels at 600 dpi | |
| const CARD_W = Math.round(CARD_W_MM * DPI / MM_PER_IN); | |
| const CARD_H = Math.round(CARD_H_MM * DPI / MM_PER_IN); | |
| // centered trim area (actual card) | |
| const CARD_X = Math.round((TOTAL_W - CARD_W) / 2); | |
| const CARD_Y = Math.round((TOTAL_H - CARD_H) / 2); | |
| function setup() { | |
| createCanvas(TOTAL_W, TOTAL_H); | |
| pixelDensity(1); | |
| noLoop(); | |
| } | |
| function draw() { | |
| background(255); | |
| // outer canvas (retransfer film) | |
| noFill(); | |
| stroke(0); | |
| rect(0, 0, TOTAL_W, TOTAL_H); | |
| // actual card trim area | |
| strokeWeight(5); | |
| rect(CARD_X, CARD_Y, CARD_W, CARD_H); | |
| const cols = 10; | |
| const rows = 6; | |
| const cell_w = CARD_W / cols; | |
| const cell_h = CARD_H / rows; | |
| // grid inside card area | |
| for (let i = 0; i < cols; i++) { | |
| const x = CARD_X + i * cell_w; | |
| line(x, CARD_Y, x, CARD_Y + CARD_H); | |
| } | |
| for (let j = 0; j < rows; j++) { | |
| const y = CARD_Y + j * cell_h; | |
| line(CARD_X, y, CARD_X + CARD_W, y); | |
| } | |
| // example center mark | |
| strokeWeight(8); | |
| stroke(255, 0, 0); | |
| strokeCap(ROUND); | |
| const line_len = CARD_H / 3; | |
| const cx = TOTAL_W / 2; | |
| const cy = TOTAL_H / 2; | |
| // example cross (optional) | |
| // line(cx, cy, cx + line_len, cy); | |
| // line(cx, cy, cx, cy - line_len); | |
| saveCanvas('id_test', 'tiff'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment