hello, i’m a noob in processing, and i have a problem when i run the sketch, memory usage goes up indefinitely
this is my code
import peasy.*;
import controlP5.*;
import processing.opengl.*;
import java.util.*;
Textarea myTextarea;
PeasyCam cam;
ControlP5 cp5;
PImage Tabla;
PImage mouse;
String selected = null;
String X;
String Y;
String T60;
String Z;
String A;
String B;
String C;
String Front;
String Back;
String Left;
String Right;
String Top;
String Bottom;
boolean showimage = false;
void setup() {
size(1000, 600, OPENGL);
cam = new PeasyCam(this, 100);
cam.setMinimumDistance(100);
cam.setMaximumDistance(200);
Tabla = loadImage("tabla.jpg");
mouse = loadImage("mouse.png");
cp5 = new ControlP5(this);
PFont font = createFont("arial",20);
cp5.addTextfield("Ancho")
.setPosition(70, 80)
.setSize(200,40)
.setFont(font)
.setFocus(true)
.setColor(color(255,255,255));
cp5.addTextfield("Largo")
.setPosition(70, 160)
.setSize(200,40)
.setFont(font)
.setFocus(true)
.setColor(color(255,255,255));
cp5.addTextfield("Alto")
.setPosition(70, 240)
.setSize(200,40)
.setFont(font)
.setFocus(true)
.setColor(color(255,255,255));
cp5.addTextfield("Front")
.setPosition(70, 400)
.setSize(60,40)
.setFont(font)
.setFocus(true)
.setColor(color(255,255,255));
cp5.addTextfield("Back")
.setPosition(150, 400)
.setSize(60,40)
.setFont(font)
.setFocus(true)
.setColor(color(255,255,255));
cp5.addTextfield("Left")
.setPosition(230, 400)
.setSize(60,40)
.setFont(font)
.setFocus(true)
.setColor(color(255,255,255));
cp5.addTextfield("Right")
.setPosition(70, 480)
.setSize(60,40)
.setFont(font)
.setFocus(true)
.setColor(color(255,255,255));
cp5.addTextfield("Top")
.setPosition(150, 480)
.setSize(60,40)
.setFont(font)
.setFocus(true)
.setColor(color(255,255,255));
cp5.addTextfield("Bottom")
.setPosition(230, 480)
.setSize(60,40)
.setFont(font)
.setFocus(true)
.setColor(color(255,255,255));
List l = Arrays.asList("Sabbine", "Eyring-Norris", "Millington-Sette");
cp5.addScrollableList("NONE")
.setPosition(70, 320)
.setSize(200, 100)
.setBarHeight(40)
.setBackgroundColor(100)
.setItemHeight(20)
.addItems(l);
myTextarea = cp5.addTextarea("txt")
.setPosition(710,75)
.setSize(200,200)
.setFont(createFont("arial",14))
.setLineHeight(20)
.setColor(color(0))
.setColorBackground(color(0, 45, 90))
.setColorForeground(color(255));
;
textFont(font);
cp5.setAutoDraw(false);
}
void draw() {
stroke(255);
strokeWeight(0.1);
strokeJoin(MITER);
strokeCap(SQUARE);
background(25, 25, 25);
X = cp5.get(Textfield.class,"Ancho").getText();
float boxSizeX = float(X);
Y = cp5.get(Textfield.class,"Largo").getText();
float boxSizeY = float(Y);
Z = cp5.get(Textfield.class,"Alto").getText();
float boxSizeZ = float(Z);
fill(255,255,255,25);
box(boxSizeX, boxSizeY, boxSizeZ);
gui();
}
void gui() {
hint(DISABLE_DEPTH_TEST);
cam.beginHUD();
image(mouse, 650, 515);
PFont font2 = createFont("arial",20);
textFont(font2);
fill(255);
text("T60 ELEGIDO", 70, 385);
cp5.draw();
fill(255);
PFont font = createFont("arial",14);
textFont(font);
A = cp5.get(Textfield.class,"Ancho").getText();
float l = float(A);
B = cp5.get(Textfield.class,"Largo").getText();
float m = float(B);
C = cp5.get(Textfield.class,"Alto").getText();
float n = float(C);
Front = cp5.get(Textfield.class,"Front").getText();
float ñ = float(Front);
Back = cp5.get(Textfield.class,"Back").getText();
float o = float(Back);
Left = cp5.get(Textfield.class,"Left").getText();
float p = float(Left);
Right = cp5.get(Textfield.class,"Right").getText();
float q = float(Right);
Top = cp5.get(Textfield.class,"Top").getText();
float r = float(Top);
Bottom = cp5.get(Textfield.class,"Bottom").getText();
float s = float(Bottom);
text("Volúmen: " + l*m*n, 730, 105);
fill(255);
text("COEF: " + (((l*m*ñ)+(l*m*o)+(m*n*p)+(m*n*q)+(l*n*r)+(l*n*s))/(2*((l*m)+(l*n)+(m*n)))), 730, 130);
fill(255);
if(selected == "Sabbine") {
text("T60: "+0.161*((l*m*n)/((l*m*ñ)+(l*m*o)+(m*n*p)+(m*n*q)+(l*n*r)+(l*n*s))), 730, 155);
}
float logA = log((1-((l*m*ñ)+(l*m*o)+(m*n*p)+(m*n*q)+(l*n*r)+(l*n*s))/(2*((l*m)+(l*n)+(m*n)))));
if(selected == "Eyring-Norris") {
text("T60: "+0.161*((l*m*n)/(((-1*((l*m)+(l*n)+(m*n))))*(logA))), 730, 155);
}
float logB = (-1*(((l*m)*log(1-ñ))+((l*m)*log(1-o))+((m*n)*log(1-p))+((m*n)*log(1-q))+((l*n)*log(1-r))+((l*n)*log(1-s))));
if(selected == "Millington-Sette") {
text("T60: "+0.161*((l*m*n)/(logB)), 730, 155);
}
if(showimage){
showimage1();
}
PFont font3 = createFont("arial",12);
String text1 = "Para valores de α menores a 0,3 tiende a la fórmula de Sabine.";
String text2 = "Para valores de α mayores a 0,3 tiende a la fórmula de Eyring-Norris.";
String text3 = "Cuando los coeficientes de absorción varían con una diferencia significativa entre cada material de la sala se utiliza la fórmula de Millington-Sette";
textFont(font3);
fill(255);
text(text1, 710, 300, 250, 250); // Text wraps within text box
text(text2, 710, 340, 250, 250);
text(text3, 710, 380, 250, 250);
cam.endHUD();
hint(ENABLE_DEPTH_TEST);
}
void showimage1(){
image(Tabla,300,10,400,580);
}
void keyPressed(){
if(key == 'i'){
showimage = true;
}
}
void keyReleased(){
if(key == 'i'){
showimage = false;
}
}
void NONE(int n) {
selected = cp5.get(ScrollableList.class, "NONE").getItem(n).get("name").toString();
}