Circle rendering support (janky) #18

Merged
koniifer merged 8 commits from peony/ableos:master into master 2024-11-10 09:03:15 -06:00
4 changed files with 43 additions and 35 deletions
Showing only changes of commit 8f5833955f - Show all commits

View file

@ -0,0 +1,36 @@
.{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)
// Precision issues?
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
}

View file

@ -1 +1 @@
.{example: main} := @use("./examples/text.hb")
.{example: main} := @use("./examples/orbit.hb")

View file

@ -1,28 +0,0 @@
.{memory, log, string, buffer, math} := @use("../../../libraries/stn/src/lib.hb")
render := @use("../../../libraries/render/src/lib.hb")
Color := render.Color
Vec2 := math.Vec2
main := fn(): void {
input := @as(u8, 0)
output_buffer := memory.request_page(1)
input_buffer := buffer.search("XKeyboard\0")
render.init()
loop {
render.clear(render.black)
render.put_vline(100, 255, 128, Color.(255, 255, 255, 255))
render.put_hline(64, 100 - 64, 164, Color.(255, 255, 255, 255))
render.put_trirect(Vec2(int).(128, 128 + 256), Vec2(int).(256, -256), Color.(147, 147, 147, 255), Color.(107, 107, 107, 255))
render.put_filled_rect(Vec2(int).(128 + 32, 128 + 32), Vec2(int).(256 - 64, 256 - 64), Color.(127, 127, 127, 127))
render.sync()
buffer.recv(input_buffer, &input, 1)
if input != 0 {
log.info(string.display_int(input, output_buffer))
input = 0
}
}
return
}

View file

@ -22,14 +22,14 @@ resolution = "1024x768x24"
[boot.limine.ableos.modules]
# [boot.limine.ableos.modules.render_example]
# path = "boot:///render_example.hbf"
[boot.limine.ableos.modules.render_example]
path = "boot:///render_example.hbf"
[boot.limine.ableos.modules.horizon]
path = "boot:///horizon.hbf"
# [boot.limine.ableos.modules.horizon]
# path = "boot:///horizon.hbf"
[boot.limine.ableos.modules.ps2_mouse_driver]
path = "boot:///ps2_mouse_driver.hbf"
# [boot.limine.ableos.modules.ps2_mouse_driver]
# path = "boot:///ps2_mouse_driver.hbf"
# [boot.limine.ableos.modules.ps2_keyboard_driver]
# path = "boot:///ps2_keyboard_driver.hbf"