forked from AbleOS/ableos
35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
.{Vec2, sin, cos, PI} := @use("../../../../libraries/stn/src/lib.hb").math
|
|
render := @use("../../../../libraries/render/src/lib.hb")
|
|
|
|
able_bmp := @embed("../../../../assets/able.bmp")
|
|
mini_bmp := @embed("../../../../assets/mini.bmp")
|
|
|
|
/* expected result:
|
|
two textured circles rotating
|
|
around one yellow filled circle
|
|
with a blue line showing their
|
|
'orbit' */
|
|
|
|
example := fn(): void {
|
|
able := render.image.from(@bitcast(&able_bmp))
|
|
mini := render.image.from(@bitcast(&mini_bmp))
|
|
if able == null | mini == null {
|
|
return
|
|
}
|
|
|
|
angle := 0.0
|
|
|
|
screen := render.init(true)
|
|
|
|
loop {
|
|
render.clear(screen, render.black)
|
|
render.put_filled_circle(screen, .(screen.width / 2, screen.height / 2), 128, render.light_yellow)
|
|
render.put_circle(screen, .(screen.width / 2, screen.height / 2), 256, render.light_blue)
|
|
render.put_textured_circle(screen, able, .(able.width / 2, able.height / 2), .(screen.width / 2 + @intcast(@fti(sin(angle) * 256)), screen.height / 2 + @intcast(@fti(cos(angle) * 256))), able.width / 2 - 1)
|
|
render.put_textured_circle(screen, mini, .(mini.width / 2, mini.height / 2), .(screen.width / 2 + @intcast(@fti(sin(angle + PI) * 256)), screen.height / 2 + @intcast(@fti(cos(angle + PI) * 256))), mini.width / 2 - 1)
|
|
render.sync(screen)
|
|
|
|
angle += 0.01
|
|
}
|
|
return
|
|
} |