mirror of
https://github.com/vlang/v.git
synced 2025-09-15 23:42:28 +03:00
examples: improve the pendulum simulation, with several modes and diagrams (#13446)
This commit is contained in:
parent
a74d28ae5f
commit
4391ae563d
26 changed files with 1501 additions and 366 deletions
19
examples/pendulum-simulation/modules/sim/anim/worker.v
Normal file
19
examples/pendulum-simulation/modules/sim/anim/worker.v
Normal file
|
@ -0,0 +1,19 @@
|
|||
module anim
|
||||
|
||||
import benchmark
|
||||
import sim
|
||||
import sim.img
|
||||
|
||||
fn pixels_worker(mut app App) {
|
||||
mut bmark := benchmark.new_benchmark()
|
||||
for {
|
||||
result := <-app.result_chan or { break }
|
||||
bmark.step()
|
||||
// find the closest magnet
|
||||
pixel_color := img.compute_pixel(result)
|
||||
app.pixels[result.id] = u32(pixel_color.abgr8())
|
||||
bmark.ok()
|
||||
}
|
||||
bmark.stop()
|
||||
println(bmark.total_message(@FN))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue