I dont know why, but my code is running insanely slow. Here it is, dont know how to fix the slow down:
Code:import fullscreen.*;
import japplemenubar.*;
import JMyron.*;
FullScreen fs;
PShape featherSVG;
float thisScale = 10;
float cols, rows;
Feather feather1;
ArrayList featherList;
JMyron m;
float randomSpeed = random(-5,5);
int[][] a;
int arrayCounter;
void setup()
{
int widthVar = 1440;
int heightVar = 900;
size(widthVar,heightVar);
m = new JMyron();
m.start(widthVar,heightVar);
m.findGlobs(1);
println("Myron " + m.version());
fs = new FullScreen(this);
fs.enter();
smooth();
cols = width/thisScale;
rows = height/thisScale;
feather1 = new Feather(0,0);
featherList = new ArrayList();
for(int i=0;i<widthVar;i+=50)
{
for(int j=0;j<heightVar;j+=50){
featherList.add(new Feather(i,j));
}
}
}
void mousePressed(){
m.settings();
}
void draw()
{
m.trackColor(255,255,0,255);
//pushMatrix();
//translate(10,5);
featherSVG = loadShape("feather.svg");
background(255);
//image(m.cameraImage(),0,0);
for(int i=0;i<featherList.size();i++)
{
Feather feathers = (Feather) featherList.get(i);
feathers.moveFeather();
feathers.displayFeather();
}
m.update();
a = m.globCenters();
}
class Feather
{
float xpos;
float ypos;
float xspeed;
float yspeed;
float[] pcompare;
Feather(float tempXPos, float tempYPos/*, float tempXSpeed, float tempYSpeed*/)
{
xpos = tempXPos;
ypos = tempYPos;
/*xspeed = tempXSpeed;
yspeed = tempYSpeed;*/
}
void makeLines(){
stroke(0,0,0);
for(int i=0;i<a.length;i++){
int[] p = a[i];
point(p[0],p[1]);
}
}
void moveFeather()
{/*
if(a!=null) {
for(int i=0;i<a.length;i++)
{
if(a != null){
int[] p = a[i];
if(pcompare[i] != p[0] && pcompare[i] != p[1])
{
if(((p[0]-pcompare[i]) > 0))
{
xspeed = xspeed+(p[0]+pcompare[i]);
yspeed = yspeed+(p[1]+pcompare[i]);
}
}
} }}*/
if(a!=null){
makeLines();
}
if(a!=null){
for(int i=0; i<a.length;i++){
int[] p = a[i];
xpos = xpos+xspeed;
ypos = ypos+yspeed;
if(abs(dist(p[0],p[1],xpos,ypos))<80){
if(xpos<p[0] && xpos>p[0]-80) {
xspeed -= randomSpeed;
}
if(xpos<p[0] && xpos>p[0]-50) {
xspeed -=randomSpeed;
}
if(xpos>p[0] && xpos<p[0]+80) {
xspeed +=randomSpeed;
}
if(xpos>p[0] && xpos<p[0]+50) {
xspeed +=randomSpeed;
}
if(xpos >= width){
xspeed =-abs(randomSpeed);
}
if(xpos <= 0){
xspeed = randomSpeed;
}
if(p[0] == 0)
{
xspeed = randomSpeed;
}
}
if(abs(dist(p[0],p[1],xpos,ypos))<80){
if(ypos<p[1] && ypos>p[1]-80) {
yspeed -= randomSpeed;
}
if(ypos<p[1] && ypos>p[1]-50) {
xspeed -=randomSpeed;
}
if(ypos>p[1] && ypos<p[1]+80) {
yspeed +=randomSpeed;
}
if(ypos>p[1] && ypos<p[1]+50) {
yspeed +=randomSpeed;
}
if(ypos >= height){
yspeed =-abs(randomSpeed);
}
if(ypos <= 0){
yspeed = randomSpeed;
}
if(p[1] == 0)
{
yspeed = randomSpeed;
}
}}}
}
void displayFeather()
{
shape(featherSVG,xpos,ypos,thisScale,thisScale);
//fill(#000000);
//noStroke();
//rect(xpos,ypos,10,10);
}
}
public void stop(){
m.stop();
super.stop();
}