if mousePressed .........(create a triangle of random radius around the mouse)
in
Programming Questions
•
5 months ago
Hi!
The following is my code:
- Tri pTri;
- void setup()
- {
- size (500, 500);
- pTri = new Tri();
- }
- void draw()
- {
- background (255);
- pTri.display();
- }
- class Tri
- {
- color c;
- float x1, y1;
- float x2, y2;
- float x3, y3;
- Tri()
- {
- c = color (255, 0, 0);
- x1 = random(0, 150);
- y1 = random(0, 150);
- x2 = random(0, 150);
- y2 = random(0, 150);
- x3 = random(0, 150);
- y3 = random(0, 150);
- }
- void display()
- {
- if (mousePressed=true)
- {
- stroke (c);
- triangle (mouseX, y1, x2, mouseY, x3, y3);
- }
- }
- }
1