-
Notifications
You must be signed in to change notification settings - Fork 18
/
TouchColours.pde
113 lines (102 loc) · 3.18 KB
/
TouchColours.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
//standard library imports
//SMT library imports
import vialab.SMT.*;
//constants
int display_width = 1200;
int display_height = 800;
int display_halfWidth;
int display_halfHeight;
int fps_limit = 60;
//other
//main functions
void setup(){
display_halfWidth = display_width / 2;
display_halfHeight = display_height / 2;
//processing window setup
frameRate( fps_limit);
size( display_width, display_height, P3D);
SMT.init( this, TouchSource.AUTOMATIC);
//create zones
ColourSetter touch_blue = new TouchColourSetter( 50, 100, 100, 100,
100, 100, 150, 200);
ColourSetter touch_pink = new TouchColourSetter( 200, 100, 100, 100,
230, 200, 200, 200);
ColourSetter touch_aqua = new TouchColourSetter( 350, 100, 100, 100,
100, 150, 150, 200);
ColourSetter touch_black = new TouchColourSetter( 500, 100, 100, 100,
10, 10, 10, 200);
ColourSetter touch_ghost = new TouchColourSetter( 650, 100, 100, 100,
250, 250, 250, 50);
ColourSetter trail_blue = new TrailColourSetter( 50, 300, 100, 100,
100, 100, 150, 200);
ColourSetter trail_pink = new TrailColourSetter( 200, 300, 100, 100,
230, 200, 200, 200);
ColourSetter trail_aqua = new TrailColourSetter( 350, 300, 100, 100,
100, 150, 150, 200);
ColourSetter trail_black = new TrailColourSetter( 500, 300, 100, 100,
10, 10, 10, 200);
ColourSetter trail_ghost = new TrailColourSetter( 650, 300, 100, 100,
250, 250, 250, 50);
//add zones
SMT.add( touch_blue);
SMT.add( touch_pink);
SMT.add( touch_aqua);
SMT.add( touch_black);
SMT.add( touch_ghost);
SMT.add( trail_blue);
SMT.add( trail_pink);
SMT.add( trail_aqua);
SMT.add( trail_black);
SMT.add( trail_ghost);
}
void draw(){
//draw background
background( 50, 50, 50);
}
private class ColourSetter extends Zone {
protected int colour_red;
protected int colour_green;
protected int colour_blue;
protected int colour_alpha;
public ColourSetter( int x, int y, int width, int height,
int colour_red, int colour_green, int colour_blue, int colour_alpha){
super( x, y, width, height);
this.colour_red = colour_red;
this.colour_green = colour_green;
this.colour_blue = colour_blue;
this.colour_alpha = colour_alpha;
}
//draw method
public void drawImpl(){
pushStyle();
noStroke();
fill( colour_red, colour_green, colour_blue, colour_alpha);
rect( 0, 0, this.getWidth(), this.getHeight(), 5);
popStyle();
}
public void touchImpl(){}
}
private class TouchColourSetter extends ColourSetter {
public TouchColourSetter( int x, int y, int width, int height,
int colour_red, int colour_green, int colour_blue, int colour_alpha){
super( x, y, width, height,
colour_red, colour_green, colour_blue, colour_alpha);
}
//touch method
public void touchDownImpl( Touch touch){
SMT.setTouchColour(
colour_red, colour_green, colour_blue, colour_alpha);
}
}
private class TrailColourSetter extends ColourSetter {
public TrailColourSetter( int x, int y, int width, int height,
int colour_red, int colour_green, int colour_blue, int colour_alpha){
super( x, y, width, height,
colour_red, colour_green, colour_blue, colour_alpha);
}
//touch method
public void touchDownImpl( Touch touch){
SMT.setTrailColour(
colour_red, colour_green, colour_blue, colour_alpha);
}
}