Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

256
Visualizações
How to delete a 2D Primitive in processing?

I'm having a problem to delete 2D primitives, I have tried to create a rectangle in front of those primitives to hide them. But I have to hide them when I click somewhere, so I guess that my draw() overpass the mouseclicked.

In my code, "maFenetre" is what I would like to hide/delete. So this is my code:

float hauteurR = 700;
float barreFenetre = 50;
float xIcone = 80;


float x = random(0,500);
float y = random(0,800);


color rouge = #FF0000;
color blanc = #FFFFFF;

void setup() {
  //colorMode(HSB,360,100,100);
  size(1500,1500); 
  background(#C1C1C1);

  
}

void rectangle(){
rect((x+largeurR)-xIcone,y,xIcone,barreFenetre);
}

void maFenetre(){
      
  
  //fenetre
  noStroke();
  fill(#89E0FF);
  rectMode(CORNER);
  rect(x,y,largeurR,hauteurR);
  
  //barre croix
  rectMode(CORNER);
  fill(blanc);
  noStroke();
  rect(x,y,largeurR,barreFenetre);
  
  if ((mouseX>= (x+largeurR)-xIcone && mouseX <= x+largeurR) && (mouseY >= y && mouseY <= y+barreFenetre)) {
   fill(rouge);
   rectangle();
   
}

   //barre aggrandir
   
   if ((mouseX>= (x+largeurR)-xIcone*2 && mouseX <= (x+largeurR)-xIcone) && (mouseY >= y && mouseY <= y+barreFenetre)) {
   fill(#CEDDDE);
   noStroke();
   rect((x+largeurR)-xIcone*2,y,xIcone,barreFenetre);
   
  }
 
 
 //barre reduire
 
   if ((mouseX>= (x+largeurR)-xIcone*3 && mouseX <= (x+largeurR)-xIcone*2) && (mouseY >= y && mouseY <= y+barreFenetre)) {
   fill(#CEDDDE);
   noStroke();
   rect((x+largeurR)-xIcone*3,y,xIcone,barreFenetre);
   }
   
   
   //icone réduire
   
   stroke(#000000);
 strokeWeight(2);
 line((x+largeurR)-xIcone*2.65,y+barreFenetre/2,(x+largeurR)-xIcone*2.35,y+barreFenetre/2);
   
   
 //icone aggrandir
 
 stroke(#000000);
 strokeWeight(2);
 noFill();
 rectMode(CENTER);
 rect((x+largeurR)-xIcone*1.5,y+barreFenetre/2,20,20);
 

  //icone croix
  stroke(#030303);
  strokeWeight(2.5);
  line((x+largeurR)-xIcone*0.62,y+barreFenetre*0.35,(x+largeurR)-xIcone*0.38,y+barreFenetre*0.75);
  line((x+largeurR)-xIcone*0.62,y+barreFenetre*0.75,(x+largeurR)-xIcone*0.38,y+barreFenetre*0.35);
    
  }
  
void draw() {

maFenetre();

  


}


void mouseReleased(){
  if (mousePressed == ((mouseX>= (x+largeurR)-xIcone && mouseX <= x+largeurR) && (mouseY >= y && mouseY <= y+barreFenetre))){
  }
    else{
    //background(#C1C1C1);
    noStroke();
    rectMode(CORNER);
    fill(#C1C1C1);
    rect(x-1,y-1,largeurR+2,hauteurR+2);
  //maFenetre();

}
  
  
  
}```
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Deleting an object not drawing it. Add a variable that indicates whether an object needs to be drawn. Change the status of the variable if you want to hide (or show) the object:

boolean drawMyObject = true;

void draw() {
    // [...]


    rectMode(CORNER);
    if (drawMyObject) {
        rect(x, y, w, h);
    }
}

void mouseReleased(){
    if (mouseX >= x-w/2 && mouseX <= x+w/2 && mouseY >= y-h/2 && mouseY <= y+h/2){
        drawMyObject = false;
    }
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda