summaryrefslogtreecommitdiff
path: root/drawing
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-04-15 22:12:38 +0100
committerubq323 <ubq323@ubq323.website>2024-04-15 22:12:38 +0100
commit9bb892b35308919ff93d22e12387e6bdc0a64223 (patch)
tree4c3dd5c1fbb81b2e4b25f0202a102fb62b6f9ceb /drawing
parent5333dc18382ecb0a2286712718ac3b4225fedf64 (diff)
get smooth brush strokes working to my present satisfaction
Diffstat (limited to 'drawing')
-rw-r--r--drawing/drawing.ha17
1 files changed, 14 insertions, 3 deletions
diff --git a/drawing/drawing.ha b/drawing/drawing.ha
index a7d9e1f..54116a3 100644
--- a/drawing/drawing.ha
+++ b/drawing/drawing.ha
@@ -103,9 +103,19 @@ export fn circle_hollow(picture: *picture, c: pos, r: i32, color: u32) void = {
export fn stroke(picture: *picture, c0: pos, c1: pos, r: i32, color: u32) void = {
const dx = c1.0 - c0.0;
const dy = c1.1 - c0.1;
- const count = (abs(dx)+abs(dy))/r;
- const sx = dx: f64 / (count-1): f64;
- const sy = dy: f64 / (count-1): f64;
+ const d = math::sqrtf64((dx*dx+dy*dy):f64):i32;
+ const count = d/r + 1;
+ if (count == 0) {
+ circle(picture, c1, r, color);
+ return;
+ } else if (count == 1) {
+ circle(picture, c0, r, color);
+ circle(picture, c1, r, color);
+ return;
+ };
+ fmt::printfln("count: {}",count)!;
+ const sx = dx: f64 / (count): f64;
+ const sy = dy: f64 / (count): f64;
for (let i = 0i32; i < count; i += 1) {
const cx = c0.0 + math::roundf64(i:f64*sx):i32;
@@ -113,6 +123,7 @@ export fn stroke(picture: *picture, c0: pos, c1: pos, r: i32, color: u32) void =
circle(picture, (cx, cy), r, color);
};
+ circle(picture, c1, r, color);
};
// ehh should check bounding box instead of doing all pictures maybe