stn := @use("../../../libraries/stn/src/lib.hb"); .{string, memory, buffer, random, log} := stn; .{Vec2} := stn.math horizon_api := @use("../../../libraries/horizon_api/src/lib.hb") render := @use("../../../libraries/render/src/lib.hb") Window := struct { // TODO: Replace this with widgets implicit_framebuffer: render.Surface, width: int, height: int, x: int, y: int, } main := fn(): int { win_buff := buffer.create("XHorizon\0") // BUG: Backbuffering is disabled screen := render.init(true) // Clear the screen to black. render.clear(screen, render.black) window := render.new_surface(screen.width / 3, screen.height / 3) x := 10 mem_buf := memory.request_page(1) color := random.range(render.Color, render.black, render.white) side := window.width / 8 vel_inner := Vec2(int).(1, 1) pos_inner := Vec2(int).((window.width - side) / 2, (window.height - side) / 2) loop { // Clear the screen render.clear(screen, render.black) // TODO: Read the window buffer here { ret := buffer.recv(win_buff, mem_buf, 4096) if ret == 0 { log.info("No messages\0") } } if pos_inner.x == 0 | pos_inner.x == window.width - side { vel_inner.x = -vel_inner.x color = random.range(render.Color, render.black, render.white) } if pos_inner.y == 0 | pos_inner.y == window.height - side { vel_inner.y = -vel_inner.y color = random.range(render.Color, render.black, render.white) } // TODO: Get windows out of a collection and iter through window_count := 0 loop { render.clear(window, render.black) // Draw the decorators { render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.white) // render.put_rect(window, .(0, 0), .(window.width - 1, 20), render.white) } render.put_filled_rect(window, pos_inner, .(side, side), color) // Apply the image to the screen pos := Vec2(int).(x, 100) render.put_surface(screen, window, pos) if window_count >= 1 { x = 10 break } window_count += 1 x += 400 } pos_inner += vel_inner // Sync the screen render.sync(screen) } return 0 }