Dear
I added png file to my project to do some interactive project however do to PImage koofi I faced an error on this line which is duplicate field sketch .May I ask you helping me?
PImage koofi;
import java.util.Calendar;
boolean koofi = false;
int formResolution = 15;
int stepSize = 2;
float distortionFactor = 1;
float initRadius = 150;
float centerX, centerY;
float[] x = new float[formResolution];
float[] y = new float[formResolution];
boolean filled = false;
boolean freeze = false;
void setup(){
size(displayWidth, displayHeight);
koofi = loadImage(“koofi.png”);
imageMode(CENTER);
smooth();
// init form
centerX = width/2;
centerY = height/2;
float angle = radians(360/float(formResolution));
for (int i=0; i<formResolution; i++){
x[i] = cos(anglei) * initRadius;
y[i] = sin(anglei) * initRadius;
}
stroke(0, 50);
background(255);
}
void draw(){
// floating towards mouse position
if (mouseX != 0 || mouseY != 0) {
centerX += (mouseX-centerX) * 0.01;
centerY += (mouseY-centerY) * 0.01;
}
// calculate new points
for (int i=0; i<formResolution; i++){
x[i] += random(-stepSize,stepSize);
y[i] += random(-stepSize,stepSize);
//ellipse(x[i], y[i], 5, 5);
tint(255,random(50,120));
image(koofi, x[i], y[i]);
}
strokeWeight(0.75);
if (filled) fill(random(255));
else noFill();
beginShape();
// start controlpoint
curveVertex(x[formResolution-1]+centerX, y[formResolution-1]+centerY);
// only these points are drawn
for (int i=0; i<formResolution; i++){
curveVertex(x[i]+centerX, y[i]+centerY);
}
curveVertex(x[0]+centerX, y[0]+centerY);
// end controlpoint
curveVertex(x[1]+centerX, y[1]+centerY);
endShape();
}
// events
void mousePressed() {
//init form on mouse position
centerX = mouseX;
centerY = mouseY;
float angle = radians(360/float(formResolution));
float radius = initRadius * random(0.5,1.0);
for (int i=0; i<formResolution; i++){
x[i] = cos(anglei) * radius;
y[i] = sin(anglei) * radius;
}
}
void keyReleased() {
if (key == ‘s’ || key == ‘S’) saveFrame(timestamp()+“koofi.png”);
if (key == DELETE || key == BACKSPACE) background(255);
if (key == ‘1’) filled = false;
if (key == ‘2’) filled = true;
// ------ pdf export ------
// press ‘r’ to start pdf recording and ‘e’ to stop it
// ONLY by pressing ‘e’ the pdf is saved to disk!
if (key ==‘r’ || key ==‘R’) {
if (koofi == false) {
beginRecord(koofi, timestamp()+“koofi.png”);
println(“recording started”);
koofi = true;
stroke(0, 50);
}
}
else if (key == ‘e’ || key ==‘E’) {
if (koofi) {
println(“recording stopped”);
endRecord();
koofi = false;
background(255);
}
}
// switch draw loop on/off
if (key == ‘f’ || key == ‘F’) freeze = !freeze;
if (freeze == true) noLoop();
else loop();
}
//timestamp
String timestamp()
{
Calendar now = Calendar.getInstance();
return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
}