-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControlP5.pde
150 lines (138 loc) · 3.88 KB
/
ControlP5.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
144
145
146
147
148
149
150
import controlP5.*;
ControlP5 cp5;
RadioButton r1, r2;
Knob KnobA, KnobB, KnobC, KnobD, KnobE;
int StateRadioButtonA, StateRadioButtonB = 0;
int StateKnobA, StateKnobB, StateKnobC, StateKnobD, StateKnobE = 0;
int radiusA, Nsides = 0;
void Controlp5() {
cp5 = new ControlP5(this);
//Configurações Knobs
KnobA = cp5.addKnob("posX")
.setRange(-60, w-60)
.setValue((w-60)/2)
.setPosition(810, 90)
.setRadius(25)
.setDragDirection(Knob.VERTICAL)
;
KnobB = cp5.addKnob("posY")
.setRange(-360, h -360)
.setValue((h-360)/2)
.setPosition(880, 90)
.setRadius(25)
.setDragDirection(Knob.VERTICAL)
;
KnobC = cp5.addKnob("sizeX")
.setRange(0, 255)
.setValue(50)
.setPosition(810, 160)
.setRadius(25)
.setDragDirection(Knob.VERTICAL)
;
KnobD = cp5.addKnob("sizeY")
.setRange(0, 255)
.setValue(50)
.setPosition(880, 160)
.setRadius(25)
.setDragDirection(Knob.VERTICAL)
;
KnobE = cp5.addKnob("rotation")
.setRange(0, 260)
.setValue(0)
.setPosition(880, 350)
.setRadius(25)
.setDragDirection(Knob.VERTICAL)
;
//Configurações Botões
r1 = cp5.addRadioButton("radioButtonA")
.setPosition(810, 20)
.setSize(20, 20)
.setColorForeground(color(120))
.setColorActive(color(255))
.setColorLabel(color(255))
.setItemsPerRow(4)
.setSpacingColumn(15)
.addItem("0", 1)
.addItem("1", 2)
.addItem("2", 3)
.addItem("3", 4)
;
//Style Lista
for (Toggle t : r1.getItems()) {
//t.getCaptionLabel().setColorBackground(color(255, 80));
t.getCaptionLabel().getStyle().moveMargin(-7, 0, 0, -3);
t.getCaptionLabel().getStyle().movePadding(7, 0, 0, 3);
t.getCaptionLabel().getStyle().backgroundWidth = 45;
t.getCaptionLabel().getStyle().backgroundHeight = 13;
}
r2 = cp5.addRadioButton("radioButtonB")
.setPosition(810, 55)
.setSize(20, 20)
.setColorForeground(color(120))
.setColorActive(color(255))
.setColorLabel(color(255))
.setItemsPerRow(3)
.setSpacingColumn(15)
.addItem("Q", 1)
.addItem("T", 2)
.addItem("X", 3)
;
//Style Lista
for (Toggle t : r2.getItems()) {
//t.getCaptionLabel().setColorBackground(color(255, 80));
t.getCaptionLabel().getStyle().moveMargin(-7, 0, 0, -3);
t.getCaptionLabel().getStyle().movePadding(7, 0, 0, 3);
t.getCaptionLabel().getStyle().backgroundWidth = 45;
t.getCaptionLabel().getStyle().backgroundHeight = 13;
}
///Configurações Slider
cp5.addSlider("radiusA")
.setPosition(810, 250)
.setRange(0, 80)
;
cp5.addSlider("Nsides")
.setPosition(810, 300)
.setWidth(100)
.setRange(8, 1) // values can range from big to small as well
.setValue(3)
.setNumberOfTickMarks(8)
.setSliderMode(Slider.FLEXIBLE)
;
}
//Eventos
void posX(int theValue) {
StateKnobA = theValue;
println("Evento posX "+theValue);
}
void posY(int theValue) {
StateKnobB = theValue;
println("Evento posY "+theValue);
}
void sizeX(int theValue) {
StateKnobC = int(map(theValue, 0, 255, 0, w));
println("Evento SizeX "+theValue);
}
void sizeY(int theValue) {
StateKnobD = int(map(theValue, 0, 255, 0, h));
println("Evento sizeY "+theValue);
}
void rotation(int theValue) {
StateKnobE = int(map(theValue, 0, 255, 0, h));
println("Evento rotation "+theValue);
}
void controlEvent(ControlEvent theEvent) {
if (theEvent.isFrom(r1)) {
print("Evento RadioButtonA "+theEvent.getName()+"\t");
println("\t "+theEvent.getGroup().getValue());
StateRadioButtonA = int(theEvent.getGroup().getValue());
KnobA.setValue((w-60)/2);
KnobB.setValue((h-300)/2);
KnobC.setValue(50);
KnobD.setValue(50);
}
if (theEvent.isFrom(r2)) {
print("Evento RadioButtonB "+theEvent.getName()+"\t");
println("\t "+theEvent.getGroup().getValue());
StateRadioButtonB = int(theEvent.getGroup().getValue());
}
}