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
|
||||
```hb
|
||||
$W := 200
|
||||
$H := 200
|
||||
$MAX_ITER := 20
|
||||
$ZOOM := 0.5
|
||||
|
||||
$H := 3
|
||||
$W := 3
|
||||
|
||||
main := fn(): int {
|
||||
mv_x := 0.5
|
||||
mv_y := 0.0
|
||||
|
||||
y := 0
|
||||
loop if y < H break else {
|
||||
x := 0
|
||||
loop if x < W break else {
|
||||
i := MAX_ITER - 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 := @as(int, 0)
|
||||
loop if y == H break else {
|
||||
x := @as(int, 0)
|
||||
loop if x == W break else {
|
||||
c_r := @itf(x)
|
||||
c_i := @itf(y)
|
||||
if c_i * c_r >= 10.0 return 0
|
||||
x += 1
|
||||
}
|
||||
y += 1
|
||||
}
|
||||
|
||||
return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
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) {
|
||||
_ = log::set_logger(&crate::fs::Logger);
|
||||
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 (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<()> {
|
||||
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)));
|
||||
}
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue