# Duplicate field sketch

**URL:** https://discourse.processing.org/t/duplicate-field-sketch/34865
**Category:** Coding Questions
**Created:** [January 27, 2022, 8:32pm UTC](https://discourse.processing.org/t/duplicate-field-sketch/34865 "2022-01-27T20:32:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![PARINAZ129](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@PARINAZ129](https://discourse.processing.org/u/PARINAZ129)
#### Post date: [January 27, 2022, 8:32pm UTC](https://discourse.processing.org/t/duplicate-field-sketch/34865/1 "2022-01-27T20:32:47Z")

</div>

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(angle_i) \* initRadius;  
y[i] = sin(angle_i) \* 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(angle_i) \* radius;  
y[i] = sin(angle_i) \* 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);  
}

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [January 27, 2022, 10:31pm UTC](https://discourse.processing.org/t/duplicate-field-sketch/34865/2 "2022-01-27T22:31:30Z")

</div>

> [@PARINAZ129](#):
>
> PImage koofi;  
> boolean koofi = false;

Use different variable names.

Please format your code:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

Are you seeing this on the console?

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f7ee9057b54070f7690c0641a264f59b4eb50d42.png)

`:)`

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [January 27, 2022, 10:31pm UTC](https://discourse.processing.org/t/duplicate-field-sketch/34865/3 "2022-01-27T22:31:45Z")

</div>

> [@PARINAZ129](#):
>
> boolean koofi = false;

boolean and image have the same name.

Let’s have boolean boolKoofi = false;
