Draw pixel 2: Difference between revisions

m
mNo edit summary
Line 726:
y = rand.int_in_range(1, win_height) or {exit(-1)}
)
 
struct App {
mut:
gg &gg.Context = unsafe {nil}
}
 
fn main() {
mut app := &App{gg.new_context(
width: win_width
gg: 0
height: win_height
}
frame_fn: frame
app.gg = gg.new_context(
bg_color: gx.black
width: win_width
height: win_height
create_window: true
window_title: 'Pixel 2'
)
frame_fn: frame
app.gg.run()
user_data: app
)
app.gg.run()
}
 
fn frame(app &App) {
app.gg.begin()
app.draw()
app.gg.end()
}
 
fn frame(appmut &App)ctx draw(gg.Context) {
app.gg ctx.begin()
app.gg ctx.draw_pixel(x, y, gx.yellow)
app.gg ctx.end()
}
</syntaxhighlight>
291

edits