Last active
May 2, 2017 16:30
-
-
Save nryota/6b88bd83062d8a64346c1a17c2b78419 to your computer and use it in GitHub Desktop.
This file contains 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
// イベント整理券PDF出力プログラム Ver.0.2 | |
// Written by n_ryota, http://dev.eyln.com | |
import processing.pdf.*; | |
String titleName = "■ Title"; // 展示名 | |
String areaName = "Area X"; // 展示場所名 | |
String logoFile = "logo.png"; // ロゴ画像ファイル名(dataフォルダ下) | |
int ticketStartMinute = 60 * 12; // 開始時刻(分) | |
int ticketAddMinute = 5; // 体験時間(分) | |
int bookingNum = 2; // 同一時間帯でダブらせる人数 | |
int ticketNum = (2 * 7) * 2; // 合計チケット枚数 | |
boolean isDrawCheckList = true; // チェックリストもつけるか? | |
int ticketNo = 0; | |
int ticketMinute = ticketStartMinute; | |
float ticketW, ticketH; | |
PImage logoImg; | |
void setup() | |
{ | |
size(2480, 3508, PDF, "ticket.pdf"); | |
background(255); | |
smooth(); | |
textFont(createFont("", 120)); | |
logoImg = loadImage(logoFile); | |
while(ticketNo < ticketNum) | |
{ | |
if(ticketNo > 0) nextPage(); | |
drawPage(); | |
} | |
if(isDrawCheckList) drawCheckList(); | |
} | |
void drawPage() | |
{ | |
float margin = width / 10; | |
ticketW = (width - margin * 2) / 2; | |
ticketH = (height - margin * 2) / 7; | |
translate(margin, margin); | |
for(int y=0; y<7; y++) | |
{ | |
for(int x=0; x<2; x++) | |
{ | |
drawTicket(x, y, ++ticketNo, ticketMinute); | |
if(ticketNo % bookingNum == 0) | |
{ | |
ticketMinute += ticketAddMinute * bookingNum; | |
} | |
if(ticketNo >= ticketNum) return; | |
} | |
} | |
} | |
void nextPage() | |
{ | |
PGraphicsPDF pdf = (PGraphicsPDF)g; | |
pdf.nextPage(); | |
} | |
void drawTicket(float x, float y, int no, int minute) | |
{ | |
x *= ticketW; | |
y *= ticketH; | |
pushMatrix(); | |
translate(x, y); | |
stroke(64); | |
strokeWeight(1.0f); | |
noFill(); | |
rect(0, 0, ticketW, ticketH); | |
fill(0); | |
scale(ticketW * 0.01f); | |
textSize(7); | |
translate(8, 12); | |
text(titleName, 0, 0); | |
textSize(3); | |
text("Numbered Ticket - 整理券", 0, 6); | |
textSize(4); | |
text("No." + nf(no, 3), 0, 15); | |
textSize(3); | |
text("体験時間 " + (ticketAddMinute - 1) + "〜" + ticketAddMinute + "分", 18, 15); | |
noFill(); | |
strokeWeight(0.1f); | |
rect(0, 17.5f, 37, 7); | |
fill(128); | |
rect(37, 17.5f, 15, 7); | |
fill(255); | |
textSize(4); | |
text(areaName, 38, 23); | |
fill(0); | |
textSize(5); | |
text(nf(minute/60, 2) + ":" + nf(minute % 60, 2), 1, 23); | |
int endMinute = minute + ticketAddMinute * bookingNum; | |
textSize(4); | |
text(" 〜 " + nf(endMinute/60, 2) + ":" + nf(endMinute % 60, 2), 16, 23); | |
if(logoImg!=null) image(logoImg, 59, 0, 26, 25); | |
else { noFill(); rect(59, 0, 26, 25); } | |
popMatrix(); | |
} | |
void drawCheckList() | |
{ | |
ticketMinute = ticketStartMinute; | |
ticketNo = 0; | |
float margin = width / 10; | |
float pageW = width - margin * 2; | |
float pageH = height - margin * 2; | |
float h = pageH / 20.0f; | |
float w = pageW / 2; | |
float y = pageH; | |
for(;;) | |
{ | |
y += h; | |
translate(0, h); | |
if(y >= pageH) | |
{ | |
y = 0; | |
nextPage(); | |
translate(margin, margin); | |
} | |
for(int x=0; x<2; x++) | |
{ | |
if(ticketNo++ >= ticketNum) return; | |
pushMatrix(); | |
translate(x * w, 0); | |
noFill(); | |
rect(0, 0, w, h); | |
rect(h * 0.25f, h * 0.25f, h * 0.5f, h * 0.5f); | |
translate(h, 0); | |
scale(h * 0.06f); | |
fill(0); | |
textSize(4); | |
text("No." + nf(ticketNo, 3) + " /", 5, 10); | |
textSize(5); | |
text(nf(ticketMinute/60, 2) + ":" + nf(ticketMinute % 60, 2), 30, 10); | |
int endMinute = ticketMinute + ticketAddMinute * bookingNum; | |
textSize(4); | |
text(" 〜 " + nf(endMinute/60, 2) + ":" + nf(endMinute % 60, 2), 46, 10); | |
popMatrix(); | |
if(ticketNo % bookingNum == 0) | |
{ | |
ticketMinute += ticketAddMinute * bookingNum; | |
} | |
} | |
} | |
} |
Ver.0.2 でチェックリスト出力機能を追加しました。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Processingで上記ソースを読み込んで、dataフォルダに正方形のlogo.pngを入れて実行すると整理券印刷用のpdfを出力します。
イベント展示用に突貫で作ったものなので、用途にあわせて改造してご自由にお使いください。
冒頭の変数の中身を変えれば、展示名や開始時間、体験時間などを調整できます。
(途中の休憩やバッファをいれたいときは印刷後に間引くのが柔軟で楽かと)
Processingのダウンロードはこちら
https://processing.org/