Advertisement
bethdps

Quadrado arredondado

Oct 5th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. int rectX = 100;
  2. int rectY = 300;
  3. int rectSize = 200;
  4.  
  5. void setup(){
  6.   size(800,800);
  7.  
  8. }
  9.  
  10. void draw() {
  11.   if (collisionRect()){
  12.     fill(255);
  13.     println("Estou no quadrado");
  14.   }else{
  15.     fill(0);
  16.    
  17.   }
  18.   smooth();
  19.   strokeWeight(12);
  20.   strokeJoin(ROUND);
  21.   rect(rectX,rectY,rectSize,rectSize);
  22.  
  23.  
  24.    
  25. }
  26.  
  27. boolean collisionRect(){
  28.   if(((mouseX >= rectX) && (mouseX <= rectX + rectSize) && ((mouseY >= rectY) && (mouseY <= rectY + rectSize)))){
  29.     return true;
  30.   }
  31.   return false;
  32. }
  33.  
  34.  
  35.  
  36.  
  37.  
  38. int dist2D(int p1X,int p1Y,int p2X,int p2Y){
  39.   return round(sqrt( pow( abs(p1X - p2X) , 2 ) + pow( abs(p1Y - p2Y) , 2 ) ) );
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement