ticket roll

한 장씩 뜯어 가세요.
Pull. Tear. Keep.

A roll of generated graphic tickets. Drag the paper down to unroll it, flick to tear at the perforation, and the ticket drops into your pile. Every ticket is drawn from a seed, nothing is an image file.

Kept click to save PNG

Use it

import { createRoll, ticket } from './roll.js';

const roll = createRoll(canvas, { seed: 7 });
roll.resize(800, 600);            // CSS px, handles devicePixelRatio
roll.layout({ cx: 400, cy: 90, k: .8, R: 60, tray: { x: 40, y: 380, w: 300, h: 200 } });
roll.interact();                  // drag to pull, flick or double-click to tear
roll.on('tear', ({ index }) => ...).start();

ticket({ seed: 7, index: 3, title: '오늘의 행운' });  // just the art, any canvas
createRoll(canvas, opts)seed, yank (tear speed px/s, 1500), pileMax (6), breeze (1), capacity
.tear()tears at the perforation nearest the roll; returns the piece or null if less than one ticket hangs
.set({ title, seed })the next unprinted tickets carry your text; a new seed is a new roll
.on('tear' | 'land' | 'grab', fn)events with the ticket index
.step(dt) / .draw()drive it yourself (video, tests) instead of .start()
ticket(opts)one 300×460 ticket: seed, index, title, kind (emblem · title · orb · pixel · bars), scale

How it works