forked from AbleOS/ableos
25 lines
739 B
Plaintext
25 lines
739 B
Plaintext
.{line} := @use("../draw.hb");
|
|
.{clear, create_buffer, present, FB_WIDTH, FB_HEIGHT, Point} := @use("../lib.hb")
|
|
|
|
/* expected result:
|
|
a 3d-looking blue set of lines
|
|
created on a blue background */
|
|
|
|
example := fn(): void {
|
|
// creates a back buffer, which we write to, to avoid screen flickering
|
|
buffer := create_buffer()
|
|
// fill the screen in blue
|
|
clear(buffer, .(100, 50, 0, 255))
|
|
p0 := Point.(0, 0 - 1)
|
|
p1 := Point.(0, FB_HEIGHT - 1)
|
|
loop if p0.y >= FB_HEIGHT break else {
|
|
// draw a line between p0 and p1
|
|
line(buffer, p0, p1, .(255, 180, 100, 255), 3)
|
|
p0.y += FB_HEIGHT >> 6
|
|
p1.x += FB_WIDTH >> 6
|
|
}
|
|
/* push the back buffer to the front buffer
|
|
this displays our image to the screen */
|
|
present(buffer)
|
|
return
|
|
} |