v2 / examples / pendulum-simulation / modules / sim / anim / worker.v
18 lines · 16 sloc · 373 bytes · 9704a014064de4130a8aa0d1506d6a66b95d1427
Raw
1module anim
2
3import benchmark
4import sim.img
5
6fn pixels_worker(mut app App) {
7 mut bmark := benchmark.new_benchmark()
8 for {
9 result := <-app.result_chan or { break }
10 bmark.step()
11 // find the closest magnet
12 pixel_color := img.compute_pixel(result)
13 app.pixels[result.id] = u32(pixel_color.abgr8())
14 bmark.ok()
15 }
16 bmark.stop()
17 println(bmark.total_message(@FN))
18}
19