summaryrefslogtreecommitdiff
path: root/src/screen/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/screen/main.zig')
-rw-r--r--src/screen/main.zig47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/screen/main.zig b/src/screen/main.zig
index 7b73450..2cb8c03 100644
--- a/src/screen/main.zig
+++ b/src/screen/main.zig
@@ -28,39 +28,44 @@ pub fn main() !void {
try crtc.attach(&buffer, &connector, mode);
- const center_x: i64 = @intCast(buffer.current.width / 2 - 100);
- const center_y: i64 = @intCast(buffer.current.height / 2 - 100);
+ const center_x = (buffer.current.width / 2);
+ const center_y = (buffer.current.height / 2);
- var box = graphics.Box {
- .x = @intCast(center_x),
- .y = @intCast(center_y),
- .width = 200,
- .height = 200,
- .color = .{ .red = 0xff, .green = 0x05, .blue = 0x07 },
- .radius = 0,
+ var line = graphics.Line {
+ .start = .{ .x = center_x, .y = center_y },
+ .end = .{ .x = center_x + 110 , .y = center_y + 100 },
+ .color = .{ .red = 0xff, .green = 0, .blue = 0 },
};
var last_duration: f64 = 0;
- var dir: f64 = 1;
var delta: f64 = 0;
- var radius: f64 = 0;
+ var angle: f64 = 0;
while (true) {
const start = try std.time.Instant.now();
const canvas = buffer.canvas();
+
canvas.fill(.{ .red = 0x25, .green = 0x25, .blue = 0x25 });
- box.render(&canvas);
- radius += delta * dir;
- if (radius > 100) {
- std.debug.print("HERE\n", .{});
- radius = 100;
- dir = -1;
- } else if (radius < 0) {
- radius = 0;
- dir = 1;
+ (graphics.Box {
+ .x = center_x - 100,
+ .y = center_y - 100,
+ .width = 200,
+ .height = 200,
+ .radius = 100,
+ .color = .{ .red = 0xff, .green = 0xff, .blue = 0xff },
+ }).render(&canvas);
+
+ line.render(&canvas);
+ const cos = @cos(std.math.degreesToRadians(angle));
+ const sin = @sin(std.math.degreesToRadians(angle));
+ line.end.x = @intCast(@as(i64, @intCast(center_x)) + @as(i64, @intFromFloat(100 * cos)));
+ line.end.y = @intCast(@as(i64, @intCast(center_y)) + @as(i64, @intFromFloat(100 * sin)));
+
+ angle += delta;
+ if (angle > 360) {
+ angle = 0;
}
- box.radius = @intFromFloat(radius);
const end = try std.time.Instant.now();
const duration: f64 = @floatFromInt(end.since(start));