summaryrefslogtreecommitdiff
path: root/src/estd/graphics
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2025-02-14 16:51:07 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2025-02-14 16:51:07 +0100
commit40b847344481803e94e78ba2dacde8dc78636948 (patch)
treec14fe2f3ad85a7b18fc3a66a7d60249245ab8d6b /src/estd/graphics
parent7ca9831f85db448641141ac40770af6baa8b512f (diff)
graphics: make curve more smooth
Diffstat (limited to 'src/estd/graphics')
-rw-r--r--src/estd/graphics/curve.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/estd/graphics/curve.zig b/src/estd/graphics/curve.zig
index 70569a3..6c591fa 100644
--- a/src/estd/graphics/curve.zig
+++ b/src/estd/graphics/curve.zig
@@ -29,7 +29,7 @@ pub const Curve = struct {
const middle_y: f64 = @floatFromInt(self.middle.y);
const end_x: f64 = @floatFromInt(self.end.x);
const end_y: f64 = @floatFromInt(self.end.y);
- const resolution = 2 + (
+ const resolution = 1 + (
distance(self.start.x, self.end.x) + distance(self.start.y, self.end.y)
) / 8;
@@ -37,7 +37,7 @@ pub const Curve = struct {
canvas.buffer[last.x + last.y * canvas.width] = .{ .red = 0xff, .green = 0xff, .blue = 0xff };
- for (1..resolution) |index| {
+ for (1..resolution + 1) |index| {
const t: f64 = @as(f64, @floatFromInt(index)) / @as(f64, @floatFromInt(resolution));
const x: u32 = @intFromFloat(@round(
(1 - t) * ((1 - t) * start_x + t * middle_x) + t * ((1 - t) * middle_x + t * end_x)