Don`t work void mousePressed

int K = 2;
int L1 = 1;
int P1 = 0;
int L2 = 3;
int P2 = 4;
color k1,k2,l1,l2,p1,p2,l3,l4,p3,p4,len,len2,ban,ban2;
void setup(){
size(500,500);
background(145, 209, 189);
k1=color(255,70,64);
k2=color(194,53,48);
l1=color(255,65,59);
l2=color(255,55,50);
p1=color(200,45,50);
p2=color(200,30,30);
l3=color(245,55,49);
l4=color(245,45,40);
p3=color(190,35,40);
p4=color(190,20,20);
len=color(227,189,52);
len2=color(217,179,62);
ban=color(237,199,62);
noLoop();
}

void draw(){

setGradient(150,190,350,150, k1, k2, K); // ΠΊΡ€ΠΈΡˆΠΊΠ° quad(250,150,350,190,250,230,150,190);
setGradient(150,190,250,230, l1, l2, L1); //Π»Ρ–Π²Π° ΠΊΡ€ΠΈΡˆΠΊΠ°
setGradient(250,230,350,190, p1, p2, P1); //ΠΏΡ€Π°Π²Π° ΠΊΡ€ΠΈΡˆΠΊΠ°
setGradient(160,215,250,272, l3, l4, L2); //Π»Ρ–Π²Π° стінка
setGradient(250,251,340,190, p3, p4, P2); //ΠΏΡ€Π°Π²Π° стінка
//Π»Π΅Π½Ρ‚Π°

noStroke();
fill(len);
quad(190,173,210,165,310,206,290,214); //Π·Π»Ρ–Π²Π°-Π½Π°ΠΏΡ€Π°Π²ΠΎ ΠΊΡ€ΠΈΡˆΠΊΠ°
quad(293,165,313,173,210,214,190,206); //справа-Π½Π°Π»Ρ–Π²ΠΎ ΠΊΡ€ΠΈΡˆΠΊΠ°
quad(190,205,210,213,210,234,190,226); //Π»Ρ–Π²Π° ΠΊΡ€ΠΈΡˆΠΊΠ°
quad(290,212,310,205,310,226,290,234); //ΠΏΡ€Π°Π²Π° ΠΊΡ€ΠΈΡˆΠΊΠ°
fill(len2);
quad(195,227,215,235,215,317,195,310); //Π»Ρ–Π²Π° стінка
quad(285,235,305,227,305,310,285,318); //ΠΏΡ€Π°Π²Π° стінка
//Π±Π°Π½Ρ‚ΠΈΠΊ
fill(ban);
noStroke();
//ΠΏΡ€Π°Π²Π° Π·Π°Π²ΠΈΡ‚ΡƒΡ…Π°
int x=250;
float y=0;
int r=20;
int z=205;
float df= 2PI/18;
for (float f=df; f<2
PI; f += df)
{
x = x+3;
y = z - sin(f) * r;
ellipse( x, y, 20, 20);
z=z+2;
}
//Π»Ρ–Π²Π° Π·Π°Π²ΠΈΡ‚ΡƒΡ…Π°
int x1=250;
int z1=205;
float y1;
float df1= 2PI/18;
for (float f1=df1; f1<2
PI; f1 += df1)
{
x1 = x1-3;
y1 = z1 - sin(f1) * r;
ellipse( x1, y1, 20, 20);
z1=z1+2;
}
stroke(len2);
circle(230,190,40); //Π»Ρ–Π²Π° частина
circle(270,190,40); //ΠΏΡ€Π°Π²Π° частина
circle(250,190,30); //Ρ†Π΅Π½Ρ‚ Π±Π°Π½Ρ‚Π°
//після натискання
}
void mousePressed() {
background(145, 209, 189);
fill(22, 135, 31);
triangle(250,10,300,60,200,60);
triangle(250,30,320,100,180,100);
triangle(250,50,340,140,160,140);
}

//ΠΊΡ€ΠΈΡˆΠΊΠ°
void setGradient(int x, int y,float w, float h, color z1, color z2, int ax ) {

noFill();

if (ax == K) {
float k3=map(x, y, h, 0, 0.4);
float k31=k3;
for (int i = x; i <= w; i++) {
float inter = map(i, x, w, 0, 1);
color k = lerpColor(z1, z2, inter);
stroke(k);
line(i, y-k31, i, y+k31);
if (i <= w-100) {
k31=k31+k3;}
else {
k31=k31-k3;}
}
}
else if (ax==L1) {
float k3=map(x, y, h, 0, 0.4);
float k31=k3;
for (int i = x; i <= w; i++) {
float inter = map(i, x, w, 0, 1);
color k = lerpColor(z1, z2, inter);
stroke(k);
line(i, y-k31,i,y-k31+20);
k31=k31+k3;
}
}
else if (ax==P1) {
float k3=map(x, y, h, 0, 0.8);
float k31=k3;
for (int i = x; i <= w; i++) {
float inter = map(i, x, w, 0, 1);
color k = lerpColor(z1, z2, inter);
stroke(k);
line(i, y-k31,i,y-k31+20);
k31=k31-k3;
}
}
else if (ax==L2) {
float k3=map(x, y, h, 0, 0.4);
float k31=k3;
for (int i = x; i <= w; i++) {
float inter = map(i, x, w, 0, 1);
color k = lerpColor(z1, z2, inter);
stroke(k);
line(i, y-k31,i,y-k31+80);
k31=k31+k3;
}
}
else if (ax==P2) {
float k3=map(x, h, y, 0, 0.4);
float k31=k3;
for (int i = x; i <= w; i++) {
float inter = map(i, x, w, 0, 1);
color k = lerpColor(z1, z2, inter);
stroke(k);
line(i, y-k31,i,y-k31+80);
k31=k31+k3;
}
}
}

Hi,

Welcome to the forum! :wink:

First of all, you can format your code by using the </> button in the message editor. (Also remember to press Ctrl+T in the Processing IDE for auto formating :+1: )

When you ask a question on the forum, you should elaborate a little more. Because giving only the question in the title is not a good practice and without saying hi everyone!

Also giving a full code without explanations of what it’s doing is a little bit rude, so be gentle with people trying to help you :heart_eyes:

You can read the guidelines here : https://discourse.processing.org/faq

ΠœΠ΅Π½Ρ– сподобався малюнок. Π©ΠΎΠ± Π½Π°ΠΌΠ°Π»ΡŽΠ²Π°Ρ‚ΠΈ Ρ‚Ρ€ΠΈΠΊΡƒΡ‚Π½ΠΈΠΊΠΈ, Π²ΠΈ ΠΌΠΎΠΆΠ΅Ρ‚Π΅ ΠΏΠΎΠ²Π½Ρ–ΡΡ‚ΡŽ Π²ΠΈΠ΄Π°Π»ΠΈΡ‚ΠΈ Ρ„ΡƒΠ½ΠΊΡ†Ρ–ΡŽ β€œvoid mousePress ()” Ρ– Π·Π°ΠΌΡ–Π½ΠΈΡ‚ΠΈ Ρ—Ρ— Ρ†ΠΈΠΌ ΠΊΠΎΠ΄ΠΎΠΌ, Ρ€ΠΎΠ·ΠΌΡ–ΡΡ‚ΠΈΠ²ΡˆΠΈ Ρ—Ρ— Π²Π½ΠΈΠ·Ρƒ Ρ„ΡƒΠ½ΠΊΡ†Ρ–Ρ— draw ().

if (mousePressed) {
    fill(22, 135, 31);
    triangle(250, 10, 300, 60, 200, 60);
    triangle(250, 30, 320, 100, 180, 100);
    triangle(250, 50, 340, 140, 160, 140);
  }
1 Like