-
Notifications
You must be signed in to change notification settings - Fork 1
/
mapping_start.pde
144 lines (128 loc) · 2.92 KB
/
mapping_start.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioInput in;
PImage bg;
int w;
int h;
ArrayList<Area> quads = new ArrayList<Area>();
int startMouseX;
int startMouseY;
boolean edit = false;
boolean mmode = false;
boolean buildMode = true;
int selected = 0;
int corner = 0;
boolean makingNew = false;
boolean sketchFullScreen() {
return true;
}
void setup() {
size(800, 600, P3D);
frameRate(12);
minim = new Minim(this);
in = minim.getLineIn();
}
void draw() {
background(0);
/*
fill(255, 0, 0);
rect(0, 0, width/2, height/2);
fill(255, 255, 0);
rect(width/2, 0, width/2, height/2);
fill(0, 255, 0);
rect(0, height/2, width/2, height/2);
fill(0, 0, 255);
rect(width/2, height/2, width/2, height/2);
*/
stroke(255);
for(int i = 0; i<in.bufferSize()-10; i+=10){
float total = 0;
for(int j = 0; j<10; j++){
total+=in.mix.get(i+j)*10;
}
stroke(map(total, 0, 10, 150, 255));
strokeWeight(10);
line(int(map(i, 0, in.bufferSize(), 0, 800)), height, int(map(i, 0, in.bufferSize(), 0, 800)), height/2 + total*35);
}
for (int i = 0; i<quads.size (); i++) {
PImage img = get(int(quads.get(i).x), int(quads.get(i).y), int(quads.get(i).w), int(quads.get(i).h));
quads.get(i).proj = img;
}
if(!buildMode)
background(0);
noStroke();
if(mmode && edit){
quads.get(selected).pr[corner].x = mouseX;
quads.get(selected).pr[corner].y = mouseY;
}
for (int i = 0; i<quads.size (); i++) {
if (edit && i == selected) {
quads.get(i).drawShape();
} else {
quads.get(i).draw();
}
}
}
void keyPressed() {
if (key == 'a') {
edit = !edit;
}
if (key == 'e') {
mmode = !mmode;
}
if (key == 'z' && edit) {
quads.get(selected).pr[corner].y--;
}
if (key == 's' && edit) {
quads.get(selected).pr[corner].y++;
}
if (key == 'q' && edit) {
quads.get(selected).pr[corner].x--;
}
if (key == 'd' && edit) {
quads.get(selected).pr[corner].x++;
}
if (key == 'b') {
buildMode = !buildMode;
}
if (key == 'p' && edit) {
quads.remove(quads.size()-1);
}
if (keyCode == UP) {
selected++;
if (selected > quads.size())
selected = 0;
}
if (keyCode == DOWN) {
selected--;
if (selected < 0)
selected = quads.size();
}
if (keyCode == RIGHT) {
corner++;
if (corner > 3)
corner = 0;
}
if (keyCode == LEFT) {
corner--;
if (corner < 0)
corner = 3;
}
}
void mousePressed(){
if(!mmode){
makingNew = true;
startMouseX = mouseX;
startMouseY = mouseY;
}
mmode = false;
}
void mouseReleased(){
if(makingNew){
Area a = new Area(startMouseX, startMouseY, new PVector(startMouseX, startMouseY), new PVector(mouseX, startMouseY), new PVector(mouseX, mouseY), new PVector(startMouseX, mouseY), abs(mouseX-startMouseX), abs(mouseY-startMouseY));
quads.add(a);
selected = quads.size()-1;
makingNew = false;
}
}