forked from AbleOS/holey-bytes
saving
This commit is contained in:
parent
2034152c83
commit
a64383e72b
|
@ -707,40 +707,24 @@ main := fn(): void {
|
||||||
|
|
||||||
#### very_nested_loops
|
#### very_nested_loops
|
||||||
```hb
|
```hb
|
||||||
$W := 200
|
|
||||||
$H := 200
|
$H := 3
|
||||||
$MAX_ITER := 20
|
$W := 3
|
||||||
$ZOOM := 0.5
|
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
mv_x := 0.5
|
y := @as(int, 0)
|
||||||
mv_y := 0.0
|
loop if y == H break else {
|
||||||
|
x := @as(int, 0)
|
||||||
y := 0
|
loop if x == W break else {
|
||||||
loop if y < H break else {
|
c_r := @itf(x)
|
||||||
x := 0
|
c_i := @itf(y)
|
||||||
loop if x < W break else {
|
if c_i * c_r >= 10.0 return 0
|
||||||
i := MAX_ITER - 1
|
x += 1
|
||||||
|
|
||||||
c_i := (2.0 * @floatcast(@itf(@as(i32, @intcast(x)))) - @floatcast(@itf(@as(i32, @intcast(W))))) / (W * ZOOM) + mv_x
|
|
||||||
c_r := (2.0 * @floatcast(@itf(@as(i32, @intcast(y)))) - @floatcast(@itf(@as(i32, @intcast(H))))) / (H * ZOOM) + mv_y
|
|
||||||
|
|
||||||
z_i := c_i
|
|
||||||
z_r := c_r
|
|
||||||
|
|
||||||
// iteration
|
|
||||||
loop if (z_r + z_i) * (z_r + z_i) >= 4 | i == 0 break else {
|
|
||||||
// z = z * z + c
|
|
||||||
z_i = z_i * z_i + c_i
|
|
||||||
z_r = z_r * z_r + c_r
|
|
||||||
i -= 1
|
|
||||||
}
|
|
||||||
// b g r
|
|
||||||
put_pixel(.(x, y), .(@intcast(i), @intcast(i), @intcast(i), 255))
|
|
||||||
}
|
}
|
||||||
|
y += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Color := struct {r: u8, g: u8, b: u8, a: u8}
|
Color := struct {r: u8, g: u8, b: u8, a: u8}
|
||||||
|
|
|
@ -4844,7 +4844,7 @@ mod tests {
|
||||||
fn generate(ident: &'static str, input: &'static str, output: &mut String) {
|
fn generate(ident: &'static str, input: &'static str, output: &mut String) {
|
||||||
_ = log::set_logger(&crate::fs::Logger);
|
_ = log::set_logger(&crate::fs::Logger);
|
||||||
log::set_max_level(log::LevelFilter::Info);
|
log::set_max_level(log::LevelFilter::Info);
|
||||||
//log::set_max_level(log::LevelFilter::Trace);
|
log::set_max_level(log::LevelFilter::Trace);
|
||||||
|
|
||||||
let mut ctx = CodegenCtx::default();
|
let mut ctx = CodegenCtx::default();
|
||||||
let (ref files, embeds) = crate::test_parse_files(ident, input, &mut ctx.parser);
|
let (ref files, embeds) = crate::test_parse_files(ident, input, &mut ctx.parser);
|
||||||
|
|
|
@ -25,7 +25,7 @@ fn build_cmd(cmd: impl AsRef<str>) -> std::process::Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exec(mut cmd: std::process::Command) -> io::Result<()> {
|
fn exec(mut cmd: std::process::Command) -> io::Result<()> {
|
||||||
if !cmd.status()?.success() {
|
if !cmd.status().inspect_err(|e| println!("failed to execute '{cmd:?}': {e}"))?.success() {
|
||||||
return Err(io::Error::other(format!("command failed: {:?}", cmd)));
|
return Err(io::Error::other(format!("command failed: {:?}", cmd)));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue