-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphicDesigner.pde
75 lines (62 loc) · 2.32 KB
/
GraphicDesigner.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class GraphicDesigner {
String graphicType;
Grid myGrid;
StageInfo design(Poster poster) {
addBackgroundColorToPoster(poster);
myGrid = poster.grids.get( poster.partitionArrangement.get("graphics") );
log.print("Init grid background...");
//PGraphics generatedPGraphics = createGraphics(myGrid.w, myGrid.h);
chooseGraphicType();
String detailsFromGraphics = "";
log.print("Creating graphics...<br>");
switch (graphicType) {
case "offset":
OffsetGraphics offsetGraphics = new OffsetGraphics(poster, myGrid);
//generatedPGraphics = offsetGraphics.getGraphics();
detailsFromGraphics = offsetGraphics.details;
break;
case "pattern":
PatternGraphics patternGraphics = new PatternGraphics(poster, myGrid);
//generatedPGraphics = patternGraphics.getGraphics();
detailsFromGraphics = patternGraphics.details;
break;
default:
//generatedPGraphics = empty();
break;
}
//applyGraphicToPoster(generatedPGraphics, poster);
String details = "Graphic Type: " + graphicType + "<br>" + "Graphic Partition Location: " + myGrid.index + "<br>" + detailsFromGraphics;
StageInfo stageInfo = new StageInfo(details);
return stageInfo;
}
private void chooseGraphicType() {
log.print("Choosing graphics type...");
String[] graphicTypes = new String[] {"offset", "pattern", "empty"};
int[] graphicTypeProbabilities = new int[]{7, 2, 0};
if (myGrid.fullHeight) {
graphicTypeProbabilities = new int[]{1, 0, 0};
}
graphicType = pickByProbability(graphicTypes, graphicTypeProbabilities).toString();
log.print("Graphics type is: [" + graphicType+"]<br>");
}
void applyGraphicToPoster(PGraphics pg, Poster poster) {
poster.content.beginDraw();
if (myGrid.index == 0 || myGrid.fullHeight) {
poster.content.image(pg, 0, 0);
} else {
poster.content.image(pg, 0, poster.grids.get(0).h);
}
poster.content.endDraw();
}
void addBackgroundColorToPoster(Poster poster) {
poster.content.beginDraw();
poster.content.background(poster.colorScheme.backgroundColor);
poster.content.endDraw();
}
private PGraphics empty() {
PGraphics emptyGraphics = createGraphics(myGrid.w, myGrid.h);
emptyGraphics.beginDraw();
emptyGraphics.endDraw();
return emptyGraphics;
}
}