2021-08-20 01:14:25 +03:00
|
|
|
module main
|
|
|
|
|
|
|
|
import gg
|
|
|
|
import gx
|
|
|
|
|
|
|
|
struct App {
|
|
|
|
mut:
|
2022-09-15 07:59:31 +03:00
|
|
|
gg &gg.Context = unsafe { nil }
|
2021-10-07 10:46:57 +03:00
|
|
|
pixels []f32
|
2021-08-20 01:14:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2021-10-07 10:46:57 +03:00
|
|
|
mut pixels := []f32{}
|
|
|
|
density := 4
|
|
|
|
for x in 30 .. 60 {
|
|
|
|
if x % density == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
for y in 30 .. 60 {
|
|
|
|
if y % density == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
pixels << f32(x + density)
|
|
|
|
pixels << f32(y + density)
|
|
|
|
}
|
|
|
|
}
|
2021-08-20 01:14:25 +03:00
|
|
|
mut app := &App{
|
|
|
|
gg: 0
|
2021-10-07 10:46:57 +03:00
|
|
|
pixels: pixels
|
2021-08-20 01:14:25 +03:00
|
|
|
}
|
|
|
|
app.gg = gg.new_context(
|
|
|
|
bg_color: gx.rgb(174, 198, 255)
|
|
|
|
width: 100
|
|
|
|
height: 100
|
|
|
|
window_title: 'Set Pixels'
|
|
|
|
frame_fn: frame
|
|
|
|
user_data: app
|
|
|
|
)
|
|
|
|
app.gg.run()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn frame(mut app App) {
|
|
|
|
app.gg.begin()
|
2021-12-23 14:31:25 +03:00
|
|
|
|
|
|
|
// Draw a blue pixel near each corner. (Find your magnifying glass)
|
|
|
|
app.gg.draw_pixel(2, 2, gx.blue)
|
|
|
|
app.gg.draw_pixel(app.gg.width - 2, 2, gx.blue)
|
|
|
|
app.gg.draw_pixel(app.gg.width - 2, app.gg.height - 2, gx.blue)
|
|
|
|
app.gg.draw_pixel(2, app.gg.height - 2, gx.blue)
|
|
|
|
|
|
|
|
// Draw pixels in a grid-like pattern.
|
|
|
|
app.gg.draw_pixels(app.pixels, gx.red)
|
2021-08-20 01:14:25 +03:00
|
|
|
app.gg.end()
|
|
|
|
}
|