-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXY4View.sc
107 lines (84 loc) · 3.07 KB
/
XY4View.sc
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
/*
SoundXY4 - a musical tabletop interface for ambisonics spatialisation
Author:
Copyright (c) 2013 Anna Xambó <anna.xambo@open.ac.uk>
Computing Department
Faculty of Maths, Computing and Technology
The Open University
Milton Keynes, UK
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
XY4View {
var <>window;
var <view;
var <viewobj;
//var viewtestareatable;
*new {
^super.new.init
}
init {
window = Window("XY4", Window.screenBounds).front;
view = UserView(window, window.view.bounds).background_(Color.blue);
viewobj = UserView(window, window.view.bounds);
//viewtestareatable = UserView(window, Rect(262, 3, 740, 729)).background_(Color.red);
viewobj.drawFunc = {|me|
var strokeColor = Color.gray(0.0);
var fillColor = [Color.red, Color.yellow, Color.new255(255, 165, 0), Color.new255(255, 0, 255), Color.new255(211, 211, 211), Color.green, Color.black];
var extent = 100;
var xCmin = 0.22;
var xCmax = 0.84;
var intxC = xCmax - xCmin;
var yCmin = 0.02;
var yCmax = 0.86;
var intyC = yCmax - yCmin;
var xPoffset = 276;
var yPoffset = 20;
var tablewP = 660;
var tablehP = 685;
var numcat = 6;
XY4.objects.do{|obj|
var x, y, xNor, yNor, numsound;
xNor = (obj.pos[0] - xCmin) / intxC;
x = (xNor * tablewP) + xPoffset;
yNor = (obj.pos[1] - yCmin) / intyC;
y = (yNor * tablehP) + yPoffset;
numsound = (obj.classID % numcat) + 1;
Pen.use{
Pen.strokeColor = strokeColor;
Pen.fillColor = fillColor[obj.classID/numcat];
if(obj.isKindOf(XY4FX), {
Pen.fillColor = fillColor[obj.busNum/numcat]
});
Pen.translate(x + (-0.5 * extent), y + (-0.5 * extent));
Pen.rotate(obj.rotEuler[0], extent * 0.5, extent * 0.5);
Pen.addRect(Rect(0, 0, extent, extent));
Pen.line((0.5 * extent)@(0.5 * extent), (0.5 * extent)@(extent * 1.2));
Pen.moveTo(extent@extent);
numsound.do{|item| Pen.addRect(Rect(extent * 1.1 - (item * 10) - (extent/2), extent *1.1, extent/10, extent/10));};
Pen.fillStroke;
if(obj.isKindOf(XY4Player), {
Pen.color = fillColor[obj.classID/numcat];
Pen.stringAtPoint("%".format(((((obj.rotEuler[0]/2pi)/(-1))+1)*100).asInteger), (extent * 1)@(extent * 1));
});
if(obj.isKindOf(XY4FX), {
Pen.color = fillColor[obj.busNum/numcat];
Pen.stringAtPoint("%".format(((((obj.rotEuler[0]/2pi)/(-1))+1)*100).asInteger), (extent * 1)@(extent * 1));
});
}
}
};
viewobj.animate = true;
}
clear{
window.close;
}
}