Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import toxi.processing.*;
- PImage Stadt;
- void setup()
- {
- frameRate(200);
- size(1000, 541);
- //noCursor();
- Stadt = loadImage("img.jpg");
- }
- void draw()
- {
- if (frameCount==1) image(Stadt, 0, 0);
- if (mouseX > 360.5 && mouseX < 366.5 && mouseY > 228 && mouseY < 234) {
- fill(255,0,0);
- ellipse(363.5,231,6,6);
- }
- else if (mouseX > 360.5 && mouseX < 366.5 && mouseY > 236.5 && mouseY < 242.5) {
- fill(255,240,0);
- ellipse(363.5,239.5,6,6);
- }
- else if (mouseX > 360.5 && mouseX < 366.5 && mouseY > 245 && mouseY < 251) {
- fill(0,255,0);
- ellipse(363.5,248,6,6);
- }
- else if (mouseX > 366.5 && mouseX < 360.5 && mouseY > 251 && mouseY < 228) {
- fill(255,255,255);
- ellipse(363.5,239.5,60,6);
- }
- PVector[] verts=new PVector[4];
- // add corner points of quad
- verts[0]=new PVector(30,541);
- verts[1]=new PVector(318,394.5);
- verts[2]=new PVector(410,395);
- verts[3]=new PVector(1000,541);
- // check if mouse pos is inside
- if(containsPoint(verts,mouseX,mouseY) && mousePressed == true) {
- grass();
- }
- beginShape();
- for(PVector v : verts) {
- vertex(v.x,v.y);
- }
- endShape(CLOSE);
- }
- void grass() {
- float step =random(13)-5; //Kopfdicke/Rotation
- float stepx=random(mouseY)/20; //Abstand
- float blade=random(1.5)+1; //Dicke
- float r=random(100)+90; //Farbton
- float x=mouseX;
- float y=mouseY;
- float tipx=x + random(25) - 10; //Rotation
- float tipy=y -random(10)-5-mouseY*0.2; //Länge
- stroke(r, 183, 0, 150);
- strokeWeight(blade);
- curve(x+step, y-step, tipx+step, tipy-step, tipx+2*step, tipy-step-10, tipx+3*step, tipy-step-15);
- line(x+step, y+step, tipx-stepx, tipy-step);
- line(x+step, y-step, tipx+stepx, tipy-step);
- fill(167, 122, 85);
- noStroke();
- ellipse(x+step, y+step, 3, 1);
- ellipse(x+step, y-step, 3, 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement