|
|
@@ -10,7 +10,7 @@ public class SecondApplet extends PApplet { |
|
|
|
ArrayList<Slider> slider = new ArrayList<Slider>(); //brick |
|
|
|
|
|
|
|
public void settings() { |
|
|
|
size(275, 500); |
|
|
|
size(275, 120); |
|
|
|
} |
|
|
|
|
|
|
|
public void setup() { |
|
|
@@ -27,31 +27,41 @@ public class SecondApplet extends PApplet { |
|
|
|
.setType(ControlP5.LIST); |
|
|
|
cp5.addToggle("rec") |
|
|
|
.setPosition(100, height-50) |
|
|
|
.setSize(20,20) |
|
|
|
.setSize(20, 20) |
|
|
|
.plugTo(this, "CP5_recordAction"); |
|
|
|
} |
|
|
|
|
|
|
|
void CP5_recordAction(){ |
|
|
|
|
|
|
|
void CP5_recordAction() { |
|
|
|
recording = !recording; |
|
|
|
} |
|
|
|
|
|
|
|
int totalBrickHeight; |
|
|
|
public void draw() { |
|
|
|
background(68, 68, 68); |
|
|
|
image(bin, width-55, height-85, 40, 40); |
|
|
|
stroke(255); |
|
|
|
strokeWeight(1); |
|
|
|
line(0, height-120, width, height-120); |
|
|
|
totalBrickHeight = 0; |
|
|
|
for (int i = 0; i < shaderList.size(); i++) { |
|
|
|
bricks.get(i).update(); |
|
|
|
bricks.get(i).display(); |
|
|
|
totalBrickHeight+= bricks.get(i).h; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void refreshSurface() { |
|
|
|
surface.setSize(width, height+bricks.get(shaderList.size()-1).h); |
|
|
|
cp5.setPosition(0, height-120); |
|
|
|
} |
|
|
|
|
|
|
|
class shaderManager { |
|
|
|
void addShader(Shader shader) { |
|
|
|
shaderList.add(shader); |
|
|
|
shader.pos = shaderList.size()-1; |
|
|
|
bricks.add(new Brick(shaderList.size()-1, shaderList.get(shaderList.size()-1).params)); |
|
|
|
bricks.add(new Brick(shaderList.size()-1, shaderList.get(shaderList.size()-1).params, shader.name)); |
|
|
|
refreshSurface(); |
|
|
|
println("Added " + shader + " to fxList at spot. List length: " + shaderList.size()); |
|
|
|
} |
|
|
|
void swapShader(int pos1, int pos2) { |
|
|
@@ -72,6 +82,7 @@ public class SecondApplet extends PApplet { |
|
|
|
bricks.get(i).pos = i; |
|
|
|
shaderList.get(i).pos = i; |
|
|
|
} |
|
|
|
refreshSurface(); |
|
|
|
} |
|
|
|
} |
|
|
|
void applyShader() { |
|
|
@@ -86,14 +97,22 @@ public class SecondApplet extends PApplet { |
|
|
|
class Brick { |
|
|
|
ArrayList<Slider> slider = new ArrayList<Slider>(); |
|
|
|
ArrayList<Param> params = new ArrayList<Param>(); |
|
|
|
boolean dragHovered; |
|
|
|
color brickBGcol; |
|
|
|
int pos; |
|
|
|
int h; |
|
|
|
String name; |
|
|
|
|
|
|
|
Brick(int pos_, ArrayList params_) { |
|
|
|
Brick(int pos_, ArrayList params_, String name_) { |
|
|
|
name = name_; |
|
|
|
pos = pos_; |
|
|
|
params = params_; |
|
|
|
|
|
|
|
h = 20 + params.size() * 20; |
|
|
|
for (int i = 0; i < params.size(); i++) { |
|
|
|
slider.add(new Slider(10, 10+20*i+pos*75, 230, 12, params.get(i).minValue, params.get(i).maxValue, params.get(i).name, params.get(i).type, params.get(i).osciModes)); //add possible waves to slider |
|
|
|
slider.add(new Slider(10, 20+(20*i)+totalBrickHeight, 230, 12, params.get(i).minValue, params.get(i).maxValue, params.get(i).name, params.get(i).type, params.get(i).osciModes)); //add possible waves to slider |
|
|
|
} |
|
|
|
println(totalBrickHeight + " " + h); |
|
|
|
} |
|
|
|
|
|
|
|
void exchangeSlider(int sliderNo, Param param) { |
|
|
@@ -108,22 +127,35 @@ public class SecondApplet extends PApplet { |
|
|
|
slider.get(i).update(); |
|
|
|
params.get(i).value = slider.get(i).value; |
|
|
|
} |
|
|
|
brickBGcol = color(85, 85, 85); |
|
|
|
} |
|
|
|
|
|
|
|
void display() { |
|
|
|
noStroke(); |
|
|
|
fill(brickBGcol); |
|
|
|
rect(0, totalBrickHeight, width, h); |
|
|
|
|
|
|
|
fill(255); |
|
|
|
text(name, 10, 10+totalBrickHeight, 10); |
|
|
|
|
|
|
|
for (int i = 0; i < slider.size(); i++) { |
|
|
|
slider.get(i).display(); |
|
|
|
} |
|
|
|
|
|
|
|
stroke(150); |
|
|
|
strokeWeight(1+int(dragHovered)*2); |
|
|
|
line(0, totalBrickHeight+h-1, width, totalBrickHeight+h-1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int pressedSlider = -1; |
|
|
|
|
|
|
|
//class Slider extends Brick{ |
|
|
|
class Slider { |
|
|
|
int x, y, w, h, mode; |
|
|
|
int[] osciModes; |
|
|
|
float minVal, maxVal, value; //should be private but doesnt work lol |
|
|
|
boolean hovering, hovering_anim_btn, animated, randomized; |
|
|
|
boolean hovering, hovering_anim_btn, animated; |
|
|
|
String label; |
|
|
|
Oscillator osci; |
|
|
|
|
|
|
@@ -137,12 +169,11 @@ public class SecondApplet extends PApplet { |
|
|
|
mode = mode_; |
|
|
|
label = label_ + (mode == INTVAL ? " (INT)" : " (FLOAT)"); |
|
|
|
osciModes = osciModes_; |
|
|
|
|
|
|
|
osci = new Oscillator(int(random(2, 20)), osciModes); |
|
|
|
|
|
|
|
osci = new Oscillator(int(random(5, 15)), osciModes); |
|
|
|
osci.amplitude(minVal, maxVal); |
|
|
|
|
|
|
|
animated = true; |
|
|
|
randomized = true; |
|
|
|
|
|
|
|
slider.add(this); |
|
|
|
} |
|
|
@@ -182,6 +213,9 @@ public class SecondApplet extends PApplet { |
|
|
|
} |
|
|
|
|
|
|
|
void update() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
osci.update(); |
|
|
|
|
|
|
|
if (animated) { |
|
|
@@ -203,19 +237,21 @@ public class SecondApplet extends PApplet { |
|
|
|
} |
|
|
|
|
|
|
|
void display() { |
|
|
|
|
|
|
|
stroke(255); |
|
|
|
fill(100+(40*int(hovering))); |
|
|
|
rect(x, y, w, h); |
|
|
|
fill(185+(40*int(hovering))); |
|
|
|
rect(x, y, map(value, minVal, maxVal, 0, w), h); |
|
|
|
fill(255); |
|
|
|
text(label, x+5, y+10, 10); |
|
|
|
text(label, x+5, y+7); |
|
|
|
|
|
|
|
if (animated) { |
|
|
|
fill(185+(40*int(hovering_anim_btn))); |
|
|
|
} else { |
|
|
|
fill(100+(40*int(hovering_anim_btn))); |
|
|
|
} |
|
|
|
rect(x+w+5, y, 15, 15); |
|
|
|
rect(x+w+5, y, h, h); |
|
|
|
} |
|
|
|
} |
|
|
|
|