We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › problem, a little urgent :s
Page Index Toggle Pages: 1
problem, a little urgent :s (Read 426 times)
problem, a little urgent :s
Jul 10th, 2009, 3:31pm
 
well i got this code Code:


Vect v1 = new Vect(1,1);

void setup(){
size(1024,768);
background(0);

smooth();
frameRate(100);

}

void draw(){


if(mousePressed){
translate(mouseX,mouseY);
rotate(mouseX);
scale(random(1.5));
v1.desenhar();

}
}


with this class Code:
  class Vect{


float xpos, ypos, r,g,b;
Vect(float x,float y){
xpos = x;
ypos = y;
}

void desenhar(){

r = random(255);
g = random(255);
b = random(255);
xpos = 0;
ypos = 0;
String [] Lista = {"vector-10.svg","vector-11.svg","vector-12.svg","vector-13.svg","vector-14.svg","vector-15.svg"};
PShape [] formas = new PShape [Lista.length];
for (int s = 0; s < formas.length; s++)
formas[s] = loadShape(Lista[s]);


PShape vect = formas [int(random(formas.length))];
vect.disableStyle();
PImage img = loadImage("4.jpg");
int xcol =(int)random(width);
int ycol =(int) random(height);
color col = img.get(xcol,ycol);
fill(col);
noStroke();
shape(vect,xpos,ypos);

}
}



and when i export it doesnt work and i need to deliver this work monday morning :s
Re: problem, a little urgent :s
Reply #1 - Jul 10th, 2009, 4:07pm
 
I just tested it, and i dont have any problems exporting it as an applet.
Whats exactly your problem ?

Maybe upload a archive of your sketch so we can take a closer look at the files etc.

Re: problem, a little urgent :s
Reply #2 - Jul 10th, 2009, 4:11pm
 
well the problem i got is... nothing appens the screen stays black, it runs slowly when i do a Run in processing, but it doesnt run when i export it :s

you can download the sketch folder here http://www.yousendit.com/transfer.php?action=batch_download&send_id=712086424&email=876fc5b4e6aa3b77acc9dacbc8748375

and thanks in advance
Re: problem, a little urgent :s
Reply #3 - Jul 10th, 2009, 4:25pm
 
ok, i got it as i took a closer look...
i already solved this problem today in another sketch but you have to put your loadImage in setup... no need to call it everytime... thats why its getting slow.


update the first part like this :

Code:


Vect v1 = new Vect(1,1);
PImage img ;
void setup(){
 size(800,600);
 background(0);
 img = loadImage("2.jpg");
 smooth();
 frameRate(100);  

}


and remove it from the class!!

there is probably more room for improvement if you but the loadshape somewhere else too... but try it yourself

Re: problem, a little urgent :s
Reply #4 - Jul 10th, 2009, 4:31pm
 
thanks! i just started to work with classes yester day, so im preety new to it! thanks again, you've been a great help!
Re: problem, a little urgent :s
Reply #5 - Jul 10th, 2009, 4:33pm
 
works awesom now Cheesy thanks again
Re: problem, a little urgent :s
Reply #6 - Jul 10th, 2009, 4:47pm
 
np... another thing, maybe not that important but you can really reduce the image size by 786 times by just using one line in height. There is no need to store more in your memory as it is always the same.
Page Index Toggle Pages: 1