MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / DragBrush

Method DragBrush

Applications/LemonPaint/canvas.cpp:16–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16void 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
38void Canvas::OnMouseDown(vector2i_t mousePos){
39 mousePos.x -= bounds.pos.x;

Callers

nothing calls this directly

Calls 2

absFunction · 0.85
PaintMethod · 0.45

Tested by

no test coverage detected