1
0
Fork 0
forked from AbleOS/ableos
ableos/sysdata/programs/render_example/src/examples/image.hb
2024-11-10 05:52:51 -06:00

26 lines
964 B
Plaintext

.{log, math, string} := @use("../../../../libraries/stn/src/lib.hb")
render := @use("../../../../libraries/render/src/lib.hb")
/* expected result:
a cute qoi image and a cute bmp image */
example := fn(): void {
screen := render.init(true)
image_qoi := render.image.from(@bitcast(&@embed("../../../../assets/mini.qoi")))
image_bmp := render.image.from(@bitcast(&@embed("../../../../assets/mini.bmp")))
if image_qoi == null | image_bmp == null {
log.error("failed to load images for whatever reason\0")
return
}
t := 0.0
loop {
render.clear(screen, render.black)
render.put_surface(screen, image_bmp, .(@bitcast(@fti(math.cos(t) * 100.0)) + (screen.width - image_bmp.width * 3) / 2, (screen.height - image_bmp.height) / 2), false)
render.put_surface(screen, image_qoi, .((screen.width + image_qoi.width) / 2, @bitcast(@fti(math.sin(t) * 100.0)) + (screen.height - image_qoi.height) / 2), false)
render.sync(screen)
t += 0.02
}
return
}