-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_york_creater.pde
101 lines (90 loc) · 2.52 KB
/
new_york_creater.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var complexity = $(document).data("complexity");
var thickness = $(document).data("thickness");
void illus()
{
ArrayList colors = new ArrayList();
// add reds
for (int i = 0; i < int(random(0, 4)); i++) {
colors.add(color(175,25,25));
}
// add blues
for (int i = 0; i < int(random(0, 4)); i++) {
colors.add(color(28,24,160));
}
// add yellows
for (int i = 0; i < int(random(0, 4)); i++) {
colors.add(color(240,204,22));
}
var screen_width = $(document).data("width");
var screen_height = $(document).data("height");
int stroke_weight = 0;
if(thickness == 1){
stroke_weight = int(random(1, 8));
}
else if(thickness == 2) {
stroke_weight = int(random(8, 16));
}
else {
stroke_weight = int(random(17, 28));
}
ArrayList line_locations = new ArrayList();
int horizontal_lines = 20;
int vertical_lines = 20;
if(complexity == 1) {
horizontal_lines = 4;
vertical_lines = 4;
}
int background_shade = color(237, 235, 210);
int min_spacing = int(6/complexity);
int max_spacing = int(150/complexity);
// initiate the canvas
size(screen_width, screen_height);
background(background_shade);
fill(255);
noLoop();
PFont fontA = loadFont("courier");
textFont(fontA, 14);
strokeWeight(stroke_weight);
// initiate a pair of variables to help us keep track of
// where we have already placed lines
int location = 0;
int lines = 0;
// find a place to put each line
// this will place lines until we run out of room
// NOT until we've placed the right number of lines
// We may want to change this
while (lines < horizontal_lines) {
location = location + stroke_weight + int(random(min_spacing, max_spacing));
if (location < (height - stroke_weight - min_spacing)) {
int[] coords = {0, location, width, location};
line_locations.add(coords);
lines++;
}
else {
break;
}
}
location = 0;
lines = 0;
while (lines < vertical_lines) {
location = location + stroke_weight + int(random(min_spacing, max_spacing));
if (location < (width - stroke_weight - min_spacing)) {
int[] coords = {location, 0, location, height};
line_locations.add(coords);
lines++;
}
else {
break;
}
}
while (line_locations.size() > 0) {
int choice = int(random(0, line_locations.size()));
int[] coords = line_locations.get(choice);
stroke(colors.get(int(random(colors.size()))));
line(coords[0], coords[1], coords[2], coords[3]);
line_locations.remove(choice);
}
}
void draw(){
illus()
}