brushes not drawing per quadrent.
in
Programming Questions
•
1 years ago
here is my code. For some reason the brushes are not drawing correctly. Help would be appreciated.
- void setup ()
- {
- background (255);
- size (400, 400);
- frameRate(50);
- smooth ();
- }
- //Draws brushes
- void draw()
- {
- float MSize, SMSize;
- //Calculates how fast the mouse is moving
- sizeOfMouse=dist(pmouseX, pmouseY, mouseX, mouseY);
- SMSize=dist(pmouseX, pmouseY, mouseX, mouseY);
- SMSize += 25;
- // placements per quadrant
- if (mousePressed) {
- if (mouseX < width/2 && mouseY < height/2) {
- brush(mouseX, mouseY, MSize+20);
- }
- else if (mouseX > width/2 && mouseY < height/2) {
- brush(mouseX, mouseY, MSize+20);
- }
- else if (mouseX < width/2 && mouseY > height/2) {
- brush(mouseX, mouseY, MSize+20);
- }
- //Brush
- brush(mouseX, mouseY, MSize+20);
- }
- //Spacebar clears page
- if (keyPressed) {
- if (key == ' ') {
- background (255);
- }
- }
- }
- //Brush
- void brush (int xBrushPos, int yBrushPos, float bSize)
- {
- // rectMode (CENTER);
- // ellipseMode (CENTER);
- //Brush changes per quadrant
- if (xBrushPos < width/2 && yBrushPos < height/2)
- {
- fill(0, random(210), 219);
- rect (xBrushPos, xBrushPos, bSize*random(3), bSize*random(3));
- fill(209, 0, 219);
- ellipse (xBrushPos, yBrushPos, bSize, bSize);
- fill(0, 0, 219);
- ellipse (xBrushPos+random(-bSize, bSize), yBrushPos+random(-bSize, bSize), bSize/2, bSize/2);
- }
- else if (xBrushPos < height/2 && yBrushPos > height/2)
- {
- fill(0, random(210), 219);
- rect (xBrushPos, xBrushPos, bSize*random(3), bSize*random(3));
- fill(209, 0, 219);
- ellipse (xBrushPos, yBrushPos, bSize, bSize);
- fill(0, 0, 219);
- ellipse (xBrushPos+random(-bSize, bSize), yBrushPos+random(-bSize, bSize), bSize/2, bSize/2);
- }
- else if (xBrushPos > height/2 && yBrushPos < height/2)
- {
- fill(0, random(210), 219);
- rect (xBrushPos, xBrushPos, bSize*random(3), bSize*random(3));
- fill(209, 0, 219);
- ellipse (xBrushPos, yBrushPos, bSize, bSize);
- fill(0, 0, 219);
- ellipse (xBrushPos+random(-bSize, bSize), yBrushPos+random(-bSize, bSize), bSize/2, bSize/2);
- }
- else
- {
- fill(0, random(210), 219);
- rect (xBrushPos, xBrushPos, bSize*random(3), bSize*random(3));
- fill(209, 0, 219);
- ellipse (xBrushPos, yBrushPos, bSize, bSize);
- fill(0, 0, 219);
- ellipse (xBrushPos+random(-bSize, bSize), yBrushPos+random(-bSize, bSize), bSize/2, bSize/2);
- }
- }
1