Skip to content

Commit 3dc4968

Browse files
committed
Merge pull request #1 from Zebbeni/ux/clickable
Ux/clickable
2 parents 0117852 + e150e2b commit 3dc4968

File tree

9 files changed

+290
-261
lines changed

9 files changed

+290
-261
lines changed

CardCreator.pde

Lines changed: 172 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1,173 +1,173 @@
1-
/**
2-
* CardCreator.pde
3-
*
4-
* This script aids in playing card design by using a customizable card
5-
* template, building each card file with information provided in two
6-
* spreadsheets.
7-
*
8-
* @author Andrew Albers
9-
* @version 1.0
10-
* @since 2014-08-30
11-
*/
12-
13-
PGraphics cardMain;
14-
PGraphics fontPlacer;
15-
PImage cardPic;
16-
PFont font;
17-
Table content;
18-
Table template;
19-
int maxWid = 0;
20-
int maxHei = 0;
21-
ArrayList<String> elements;
22-
23-
/**
24-
* Reads csv files, defines card dimensions to accomodate
25-
* largest x + width and largest y + height of elements
26-
* in template.csv
27-
*
28-
* TODO: Let user choose other card sizes to generate
29-
* TODO: Add bleed area to card sizes for printing.
30-
*/
31-
void setup(){
32-
getCardValues();
33-
cardMain = createGraphics(maxWid,maxHei);
34-
noLoop();
35-
}
36-
37-
/**
38-
* Kicks off card creation safter setup.
39-
*/
40-
void draw(){
41-
createAllCards();
42-
}
43-
44-
/**
45-
* Passes each row in the content.csv file to createCard()
46-
*/
47-
void createAllCards() {
48-
println("Creating All Cards");
49-
for (TableRow conRow : content.rows()) {
50-
createCard(conRow);
51-
}
52-
println("Done. Check the CardCreator directory for updated cards.");
53-
}
54-
55-
/**
56-
* Builds a single card, placing each element in the order it appears in
57-
* template.csv. Saves the finished image with the filename given under
58-
* "Name" in the content.csv file.
59-
*
60-
* @param conRow a row in the user-created content.csv file
61-
*/
62-
void createCard(TableRow conRow) {
63-
cardMain.clear();
64-
println("creating ", conRow.getString("saveFile"));
65-
for(int i = 0; i < elements.size(); i++){
66-
//calls drawImg() if "Img" is in element name
67-
if(elements.get(i).indexOf("Img") != -1){
68-
drawImg(conRow.getString(elements.get(i)), template.getRow(i));
69-
}
70-
//calls drawText() if "Text" is in element name
71-
else if(elements.get(i).indexOf("Text") != -1){
72-
drawText(conRow.getString(elements.get(i)), template.getRow(i));
73-
}
74-
}
75-
saveCard(conRow.getString("saveFile"));
76-
}
77-
78-
/**
79-
* Saves a file to a given filename.
80-
*
81-
* @param filename
82-
*/
83-
void saveCard(String filename){
84-
cardMain.save(filename);
85-
}
86-
87-
/**
88-
* Draws text given a text string, an x and y position,
89-
* a width, height, and font. Optionally it will also squish
90-
* the text given an hSquish (horizontal squish percentage).
91-
* Also added an (optional) colorHex value. Default is white.
92-
*
93-
* @param t text to print
94-
* @param row template.csv attributes for this text element
95-
*/
96-
void drawText(String t, TableRow row) {
97-
int x = int(row.getString("x"));
98-
int y = int(row.getString("y"));
99-
int w = int(row.getString("w"));
100-
int h = int(row.getString("h"));
101-
102-
//get the text color or default to white
103-
String hexStr = "FF" + row.getString("colorHex");
104-
if(hexStr.equals("")){
105-
hexStr = "FFFFFFFF";
106-
}
107-
color col = unhex(hexStr);
108-
109-
//get the horizontal squish value or defualt to 1
110-
float hSquish = float(row.getString("hSquish"));
111-
if(Float.isNaN(hSquish) || hSquish <= 0) {
112-
hSquish = 1; //set hSquish to 1 if undefined or <= 0
113-
}
114-
115-
String text = t;
116-
font = loadFont(row.getString("font"));
117-
fontPlacer = createGraphics(int(w/hSquish),h);
118-
fontPlacer.beginDraw();
119-
fontPlacer.textFont(font);
120-
fontPlacer.textSize(int(row.getString("size")));
121-
fontPlacer.textAlign(LEFT,TOP);
122-
fontPlacer.fill(col);
123-
//provide extra horizontal space for text if 0 < hSquish < 1...
124-
fontPlacer.text(text,0,0,int(w/hSquish),h);
125-
fontPlacer.endDraw();
126-
//... and then compresses to the stated width
127-
cardMain.image(fontPlacer.get(),x,y,w,h);
128-
}
129-
130-
/**
131-
* Draws an image given a filename, an x and y position,
132-
* a width, and height.
133-
*
134-
* @param filename the image file to draw
135-
* @param row template.csv attributes for this image element
136-
*/
137-
void drawImg(String filename, TableRow row) {
138-
if(filename.length() != 0){
139-
cardPic = loadImage(filename);
140-
int x = int(row.getString("x"));
141-
int y = int(row.getString("y"));
142-
int w = int(row.getString("w"));
143-
int h = int(row.getString("h"));
144-
cardMain.image(cardPic,x,y,w,h);
145-
}
146-
}
147-
148-
/**
149-
* Reads template.csv and content.csv, stores their values in
150-
* two tables: template and content.
151-
*
152-
* TODO: Allow multiple template.csv/content.csv files to be
153-
* read. ie generate landscape and portrait-formatted
154-
* cards at the same time
155-
*/
156-
void getCardValues(){
157-
elements = new ArrayList<String>();
158-
template = loadTable("template.csv", "header");
159-
for (TableRow row : template.rows()) {
160-
//add to the list of elements
161-
elements.add(row.getString("element"));
162-
163-
//
164-
if(int(row.getString("x"))+int(row.getString("w")) > maxWid){
165-
maxWid = int(row.getString("x"))+int(row.getString("w"));
166-
}
167-
if(int(row.getString("y"))+int(row.getString("h")) > maxHei) {
168-
maxHei = int(row.getString("y"))+int(row.getString("h"));
169-
}
170-
}
171-
content = loadTable("content.csv", "header");
172-
}
1+
///**
2+
// * CardCreator.pde
3+
// *
4+
// * This script aids in playing card design by using a customizable card
5+
// * template, building each card file with information provided in two
6+
// * spreadsheets.
7+
// *
8+
// * @author Andrew Albers
9+
// * @version 1.0
10+
// * @since 2014-08-30
11+
// */
12+
//
13+
//PGraphics cardMain;
14+
//PGraphics fontPlacer;
15+
//PImage cardPic;
16+
//PFont font;
17+
//Table content;
18+
//Table template;
19+
//int maxWid = 0;
20+
//int maxHei = 0;
21+
//ArrayList<String> elements;
22+
//
23+
///**
24+
// * Reads csv files, defines card dimensions to accomodate
25+
// * largest x + width and largest y + height of elements
26+
// * in template.csv
27+
// *
28+
// * TODO: Let user choose other card sizes to generate
29+
// * TODO: Add bleed area to card sizes for printing.
30+
// */
31+
//void setup(){
32+
// getCardValues();
33+
// cardMain = createGraphics(maxWid,maxHei);
34+
// noLoop();
35+
//}
36+
//
37+
///**
38+
// * Kicks off card creation safter setup.
39+
// */
40+
//void draw(){
41+
// createAllCards();
42+
//}
43+
//
44+
///**
45+
// * Passes each row in the content.csv file to createCard()
46+
// */
47+
//void createAllCards() {
48+
// println("Creating All Cards");
49+
// for (TableRow conRow : content.rows()) {
50+
// createCard(conRow);
51+
// }
52+
// println("Done. Check the CardCreator directory for updated cards.");
53+
//}
54+
//
55+
///**
56+
// * Builds a single card, placing each element in the order it appears in
57+
// * template.csv. Saves the finished image with the filename given under
58+
// * "Name" in the content.csv file.
59+
// *
60+
// * @param conRow a row in the user-created content.csv file
61+
// */
62+
//void createCard(TableRow conRow) {
63+
// cardMain.clear();
64+
// println("creating ", conRow.getString("saveFile"));
65+
// for(int i = 0; i < elements.size(); i++){
66+
// //calls drawImg() if "Img" is in element name
67+
// if(elements.get(i).indexOf("Img") != -1){
68+
// drawImg(conRow.getString(elements.get(i)), template.getRow(i));
69+
// }
70+
// //calls drawText() if "Text" is in element name
71+
// else if(elements.get(i).indexOf("Text") != -1){
72+
// drawText(conRow.getString(elements.get(i)), template.getRow(i));
73+
// }
74+
// }
75+
// saveCard(conRow.getString("saveFile"));
76+
//}
77+
//
78+
///**
79+
// * Saves a file to a given filename.
80+
// *
81+
// * @param filename
82+
// */
83+
//void saveCard(String filename){
84+
// cardMain.save(filename);
85+
//}
86+
//
87+
///**
88+
// * Draws text given a text string, an x and y position,
89+
// * a width, height, and font. Optionally it will also squish
90+
// * the text given an hSquish (horizontal squish percentage).
91+
// * Also added an (optional) colorHex value. Default is white.
92+
// *
93+
// * @param t text to print
94+
// * @param row template.csv attributes for this text element
95+
// */
96+
//void drawText(String t, TableRow row) {
97+
// int x = int(row.getString("x"));
98+
// int y = int(row.getString("y"));
99+
// int w = int(row.getString("w"));
100+
// int h = int(row.getString("h"));
101+
//
102+
// //get the text color or default to white
103+
// String hexStr = "FF" + row.getString("colorHex");
104+
// if(hexStr.equals("")){
105+
// hexStr = "FFFFFFFF";
106+
// }
107+
// color col = unhex(hexStr);
108+
//
109+
// //get the horizontal squish value or defualt to 1
110+
// float hSquish = float(row.getString("hSquish"));
111+
// if(Float.isNaN(hSquish) || hSquish <= 0) {
112+
// hSquish = 1; //set hSquish to 1 if undefined or <= 0
113+
// }
114+
//
115+
// String text = t;
116+
// font = loadFont(row.getString("font"));
117+
// fontPlacer = createGraphics(int(w/hSquish),h);
118+
// fontPlacer.beginDraw();
119+
// fontPlacer.textFont(font);
120+
// fontPlacer.textSize(int(row.getString("size")));
121+
// fontPlacer.textAlign(LEFT,TOP);
122+
// fontPlacer.fill(col);
123+
// //provide extra horizontal space for text if 0 < hSquish < 1...
124+
// fontPlacer.text(text,0,0,int(w/hSquish),h);
125+
// fontPlacer.endDraw();
126+
// //... and then compresses to the stated width
127+
// cardMain.image(fontPlacer.get(),x,y,w,h);
128+
//}
129+
//
130+
///**
131+
// * Draws an image given a filename, an x and y position,
132+
// * a width, and height.
133+
// *
134+
// * @param filename the image file to draw
135+
// * @param row template.csv attributes for this image element
136+
// */
137+
//void drawImg(String filename, TableRow row) {
138+
// if(filename.length() != 0){
139+
// cardPic = loadImage(filename);
140+
// int x = int(row.getString("x"));
141+
// int y = int(row.getString("y"));
142+
// int w = int(row.getString("w"));
143+
// int h = int(row.getString("h"));
144+
// cardMain.image(cardPic,x,y,w,h);
145+
// }
146+
//}
147+
//
148+
///**
149+
// * Reads template.csv and content.csv, stores their values in
150+
// * two tables: template and content.
151+
// *
152+
// * TODO: Allow multiple template.csv/content.csv files to be
153+
// * read. ie generate landscape and portrait-formatted
154+
// * cards at the same time
155+
// */
156+
//void getCardValues(){
157+
// elements = new ArrayList<String>();
158+
// template = loadTable("template.csv", "header");
159+
// for (TableRow row : template.rows()) {
160+
// //add to the list of elements
161+
// elements.add(row.getString("element"));
162+
//
163+
// //
164+
// if(int(row.getString("x"))+int(row.getString("w")) > maxWid){
165+
// maxWid = int(row.getString("x"))+int(row.getString("w"));
166+
// }
167+
// if(int(row.getString("y"))+int(row.getString("h")) > maxHei) {
168+
// maxHei = int(row.getString("y"))+int(row.getString("h"));
169+
// }
170+
// }
171+
// content = loadTable("content.csv", "header");
172+
//}
173173

button.pde

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
public class Button
1+
public class Button extends Panel
22
{
3-
int x;
4-
int y;
5-
int wid;
6-
int hei;
73
PGraphics drawPG;
84

95
Button ( int xx , int yy , int ww , int hh, PGraphics pGraph )
@@ -26,4 +22,8 @@ public class Button
2622
{
2723

2824
}
25+
26+
void updateDraw()
27+
{
28+
}
2929
}

content_handler.pde

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ public class ContentHandler
1717
table = loadTable(filename, "header");
1818
}
1919

20+
2021
}

data/template.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ element,type,x,y,w,h,font,fontsize,hSquish,colorHex
22
Background,image,0,0,675,1050,,0,1.0,FFFFFF
33
Picture,image,55,163,560,505,,0,1.0,FFFFFF
44
Name,text,174,79,434,56,Sansation-Bold-48.vlw,60,0.6,
5-
Main,text,56,705,554,183,Sansation-Regular-48.vlw,45,0.6,
5+
Main,text,60,707,554,183,Sansation-Regular-48.vlw,45,0.6,
66
Icon,image,50,50,100,100,,0,1.0,FFFFFF
77
Italic,text,58,942,550,42,Sansation-Italic-48.vlw,35,0.6,3344FF

0 commit comments

Comments
 (0)