mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 11:16:42 +01:00
add rectangle_outline function
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -115,6 +115,26 @@ export fn rectangle(x: f32, y: f32, w: f32, h: f32, col: i32) {
|
||||
}
|
||||
}
|
||||
|
||||
export fn rectangle_outline(x: f32, y: f32, w: f32, h: f32, col: i32) {
|
||||
let xl = nearest(x) as i32;
|
||||
let xr = nearest(x + w) as i32;
|
||||
let yt = nearest(y) as i32;
|
||||
let yb = nearest(y + h) as i32;
|
||||
|
||||
hline(xl, xr, yt, col);
|
||||
if yt < yb {
|
||||
hline(xl, xr, yb - 1, col);
|
||||
|
||||
loop y {
|
||||
setPixel(xl, yt, col);
|
||||
if xl < xr {
|
||||
setPixel(xr - 1, yt, col);
|
||||
}
|
||||
branch_if (yt := yt + 1) < yb: y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export fn circle(cx: f32, cy: f32, radius: f32, col: i32) {
|
||||
let y = clamp(nearest(cy - radius) as i32, 0, 240);
|
||||
let maxY = clamp(nearest(cy + radius) as i32, 0, 240);
|
||||
|
||||
@@ -89,6 +89,9 @@ impl BaseModule {
|
||||
add_function(&mut functions, &type_map, "setBackgroundColor", &[I32], None);
|
||||
add_function(&mut functions, &type_map, "setCursorPosition", &[I32, I32], None);
|
||||
|
||||
add_function(&mut functions, &type_map, "rectangle_outline", &[F32, F32, F32, F32, I32], None);
|
||||
add_function(&mut functions, &type_map, "circle_outline", &[F32, F32, F32, I32], None);
|
||||
|
||||
for i in functions.len()..64 {
|
||||
add_function(
|
||||
&mut functions,
|
||||
|
||||
Reference in New Issue
Block a user