We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello dudes,
I am a newbie in using the Processing Language. I have developed a small application which displays randomly circles on the phone screen. Their radius is also one of the first 20 fibonacci numbers in magnitude. I have added a mousePressed() event in order to save my creations. However, my app closes instantly when I touch the screen with my finger. Can you help me in order to solve this problem?
My code:
void setup() {
size(displayWidth,displayHeight);
smooth();
background(random(255),random(255),random(255));
}
void draw() {
noFill();
stroke(255);
strokeWeight(4);
for(int i=0; i<20; i++) {
ellipse(random(width),random(height),fibonacci(i)/5,fibonacci(i)/5);
delay(10);
}
}
int fibonacci(int n) {
if (n==0 || n==1) {
return 1;
}
return fibonacci(n-1)+fibonacci(n-2);
}
void mousePressed() {
saveFrame("/sdcard/img-####.png");
}
void delay(int ms)
{
try
{
Thread.sleep(ms);
}
catch(Exception e){}
}
The Android API I am using is the one recommended by the Processing Wiki.
Thanks in advance!
Answers
Have you enabled the permission
WRITE_EXTERNAL_STORAGE
(Android > Sketch Permissions from the PDE)?Also, that may not be the correct path, depending on your phone. If it still doesn't work, then you can try this to save to the pictures directory:
I'll try it later in the evening! Thank you very much!
It saves a frame but not my frame .. It's just random something black screen. .