Advertisement
Guest User

Untitled

a guest
Jan 15th, 2014
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1. import toxi.processing.*;
  2.  
  3. PImage Stadt;
  4.  
  5. void setup()
  6. {
  7.   frameRate(200);
  8.   size(1000, 541);
  9.   //noCursor();
  10.  
  11.   Stadt = loadImage("img.jpg");
  12. }
  13.  
  14. void draw()
  15. {
  16.   if (frameCount==1) image(Stadt, 0, 0);
  17.  
  18.  
  19.   if (mouseX > 360.5 && mouseX < 366.5 && mouseY > 228 && mouseY < 234) {
  20.     fill(255,0,0);
  21.     ellipse(363.5,231,6,6);
  22.   }
  23.   else if (mouseX > 360.5 && mouseX < 366.5 && mouseY > 236.5 && mouseY < 242.5) {
  24.     fill(255,240,0);
  25.     ellipse(363.5,239.5,6,6);
  26.   }
  27.   else if (mouseX > 360.5 && mouseX < 366.5 && mouseY > 245 && mouseY < 251) {
  28.     fill(0,255,0);
  29.     ellipse(363.5,248,6,6);
  30.   }
  31.   else if (mouseX > 366.5 && mouseX < 360.5 && mouseY > 251 && mouseY < 228) {
  32.     fill(255,255,255);
  33.     ellipse(363.5,239.5,60,6);
  34.   }
  35.  
  36.  
  37.  
  38.  
  39.    PVector[] verts=new PVector[4];
  40.   // add corner points of quad
  41.   verts[0]=new PVector(30,541);
  42.   verts[1]=new PVector(318,394.5);
  43.   verts[2]=new PVector(410,395);
  44.   verts[3]=new PVector(1000,541);
  45.   // check if mouse pos is inside
  46.   if(containsPoint(verts,mouseX,mouseY) && mousePressed == true) {
  47.     grass();
  48.   }
  49.  
  50.   beginShape();
  51.   for(PVector v : verts) {
  52.     vertex(v.x,v.y);
  53.   }
  54.   endShape(CLOSE);
  55. }
  56.  
  57.  
  58.  
  59. void grass() {
  60.   float step =random(13)-5; //Kopfdicke/Rotation
  61.   float stepx=random(mouseY)/20; //Abstand
  62.   float blade=random(1.5)+1; //Dicke
  63.   float r=random(100)+90; //Farbton
  64.   float x=mouseX;
  65.   float y=mouseY;
  66.   float tipx=x + random(25) - 10; //Rotation
  67.   float tipy=y -random(10)-5-mouseY*0.2; //Länge
  68.   stroke(r, 183, 0, 150);
  69.   strokeWeight(blade);
  70.   curve(x+step, y-step, tipx+step, tipy-step, tipx+2*step, tipy-step-10, tipx+3*step, tipy-step-15);
  71.   line(x+step, y+step, tipx-stepx, tipy-step);
  72.   line(x+step, y-step, tipx+stepx, tipy-step);
  73.   fill(167, 122, 85);
  74.   noStroke();
  75.   ellipse(x+step, y+step, 3, 1);
  76.   ellipse(x+step, y-step, 3, 1);
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement