aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/examples/gg/set_pixels.v
blob: 69dc53dd2a1b24fb5cd5c7385001a4b977f00ec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module main

import gg
import gx

struct App {
mut:
	gg &gg.Context
}

fn main() {
	mut app := &App{
		gg: 0
	}
	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) {
	mut pixels := []f32{}

	for x in 30 .. 60 {
		for y in 30 .. 60 {
			pixels << f32(x)
			pixels << f32(y)
		}
	}

	app.gg.begin()
	app.gg.set_pixels(pixels, gx.red)
	app.gg.end()
}