mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 19:26:43 +01:00
fix line drawing
This commit is contained in:
@@ -35,15 +35,15 @@ fn line(x1: f32, y1: f32, x2: f32, y2: f32, col: i32) {
|
||||
}
|
||||
if y1 < 0 as f32 & y2 >= 0 as f32 {
|
||||
x1 = x1 + (x2 - x1) * -y1 / (y2 - y1);
|
||||
y1 = 0.0;
|
||||
y1 = 0 as f32;
|
||||
}
|
||||
if y1 < 240 as f32 & y2 >= 240 as f32 {
|
||||
x2 = x2 + (x2 - x1) * (240 as f32 - y2) / (y2 - y1);
|
||||
y2 = 240 as f32;
|
||||
}
|
||||
|
||||
let dx = x2 - x1;
|
||||
let dy = y2 - y1;
|
||||
let lazy dx = x2 - x1;
|
||||
let lazy dy = y2 - y1;
|
||||
let max_axis: f32;
|
||||
let p: f32;
|
||||
if abs(dx) >= dy {
|
||||
@@ -58,7 +58,7 @@ fn line(x1: f32, y1: f32, x2: f32, y2: f32, col: i32) {
|
||||
p = floor(p) + 0.5 - p;
|
||||
if max_axis < 0 as f32 {
|
||||
steps = -steps;
|
||||
p = 1 as f32 - p;
|
||||
p = -p;
|
||||
max_axis = -max_axis;
|
||||
}
|
||||
dx = dx / max_axis;
|
||||
@@ -91,12 +91,12 @@ fn line(x1: f32, y1: f32, x2: f32, y2: f32, col: i32) {
|
||||
|
||||
export fn upd() {
|
||||
cls(0);
|
||||
//line(0.0, 4.0, 7.0, -2.0, 15);
|
||||
//return;
|
||||
// line(0.0, 4.0, 7.0, -2.0, 15);
|
||||
// return;
|
||||
let i: i32;
|
||||
loop lines {
|
||||
let angle = i as f32 * (3.1415 / 25.0) + time() * 0.01;
|
||||
line(160.0, 120.0, 160.0 + sin(angle) * 200.0, 120.0 + cos(angle) * 200.0, 47);
|
||||
let angle = i as f32 * (3.1415 / 25.0) + time() * 0.1;
|
||||
line(160.0, 120.0, 160.0 + sin(angle) * 100.0, 120.0 + cos(angle) * 100.0, 47);
|
||||
branch_if (i := i + 1) < 50: lines;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user