-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sequencer_Grid.pde
67 lines (64 loc) · 1.45 KB
/
Sequencer_Grid.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
/**
* Array Objects.
*
* Demonstrates the syntax for creating an array of custom objects.
*/
import oscP5.*;
import netP5.*;
int unit = 50;
int count;
int redamount = 0;
int greenamount = 0;
int blueamount = 255;
int index = 0;
Module[] mods;
OscP5 oscP5;
PImage img;
String path = "black.png";
void setup() {
size(500, 500);
noStroke();
int wideCount = width / unit;
int highCount = height / unit;
count = wideCount * highCount;
oscP5 = new OscP5(this,8000);
mods = new Module[count];
int index = 0;
for (int y = 0; y < highCount; y++) {
for (int x = 0; x < wideCount; x++) {
mods[index++] = new Module(x*unit, y*unit, unit/2, unit/2, random(0.05, 0.8), unit);
img = loadImage(path);
}
}
}
void oscEvent(OscMessage theOscMessage){
if(theOscMessage.checkAddrPattern("/path") == true)
{
path = theOscMessage.get(0).stringValue();
img = loadImage(path);
}
if(theOscMessage.checkAddrPattern("/red") == true)
{
redamount = theOscMessage.get(0).intValue();
index = theOscMessage.get(1).intValue();
greenamount = 0;
blueamount = 0;
img = loadImage(path);
}
if(theOscMessage.checkAddrPattern("/reset") == true)
{
redamount = 0;
greenamount = 0;
blueamount = 255;
img = loadImage("black.png");
}
}
void draw() {
background(0);
clear();
image(img, 0, 0);
for (Module mod : mods) {
mod.display();
}
mods[index].colorit(redamount,blueamount,greenamount);
}