| 14 | } |
| 15 | |
| 16 | void Canvas::DragBrush(vector2i_t a, vector2i_t b){ |
| 17 | double xDist = b.x - a.x; |
| 18 | double yDist = b.y - a.y; |
| 19 | |
| 20 | double _x = a.x; |
| 21 | double _y = a.y; |
| 22 | |
| 23 | int xsign = (_x > 0) - (_x < 0); |
| 24 | |
| 25 | if(abs(xDist) >= abs(yDist)){ |
| 26 | double gradient = xDist ? (yDist ? (yDist / xDist) : 0) : yDist; |
| 27 | for(int i = 0; i < abs(xDist); i++, _x += xsign, _y += gradient){ |
| 28 | currentBrush->Paint(_x, _y, colour.r, colour.g, colour.b, brushScale, this); |
| 29 | } |
| 30 | } else { |
| 31 | double gradient = yDist ? (xDist ? (xDist / yDist) : 0) : xDist; |
| 32 | for(int i = 0; i < abs(yDist); i++, _y += xsign, _x += gradient){ |
| 33 | currentBrush->Paint(_x, _y, colour.r, colour.g, colour.b, brushScale, this); |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | void Canvas::OnMouseDown(vector2i_t mousePos){ |
| 39 | mousePos.x -= bounds.pos.x; |