v2 / examples / gg / polygons.v
23 lines · 20 sloc · 534 bytes · bbb61ab3687afe512a1fa12492c876d011626107
Raw
1module main
2
3import gg
4
5fn main() {
6 mut context := gg.new_context(
7 bg_color: gg.rgb(174, 198, 255)
8 width: 600
9 height: 400
10 window_title: 'Polygons'
11 frame_fn: frame
12 )
13 context.run()
14}
15
16fn frame(mut ctx gg.Context) {
17 ctx.begin()
18 ctx.draw_convex_poly([f32(100.0), 100.0, 200.0, 100.0, 300.0, 200.0, 200.0, 300.0, 100.0, 300.0],
19 gg.blue)
20 ctx.draw_poly_empty([f32(50.0), 50.0, 70.0, 60.0, 90.0, 80.0, 70.0, 110.0], gg.black)
21 ctx.draw_triangle_filled(450, 142, 530, 280, 370, 280, gg.red)
22 ctx.end()
23}
24