Skip to content

Commit

Permalink
Update mwe_04
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Fechner committed Mar 28, 2024
1 parent 13d7057 commit 7b2497e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions mwes/mwe_04.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,24 @@ stats = Stats(333, 3900, 25)
function show_stats(stats::Stats)
fig = GLMakie.Figure(size = (400, 400))
lscene = GLMakie.LScene(fig[1, 1], show_axis=false)
lbl = "energy:"
value = @sprintf("%5.0f Wh", stats.e_mech)
GLMakie.text!(lscene, position = GLMakie.Point2f( 10, 340), lbl, fontsize = 24, space=:pixel)
GLMakie.text!(lscene, position = GLMakie.Point2f(250, 340), value, fontsize = 24, space=:pixel)
if Sys.islinux()
lin_font="/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMono.ttf"
if isfile(lin_font)
font=lin_font
else
font="/usr/share/fonts/truetype/freefont/FreeMono.ttf"
end
else
font="Courier New"
end
function print(lbl::String, value::String; line, font=font)
GLMakie.text!(lscene, position = GLMakie.Point2f( 10, 360-line*32), lbl; fontsize = 24, space=:pixel)
GLMakie.text!(lscene, position = GLMakie.Point2f(250, 360-line*32), value; fontsize = 24, font, space=:pixel)
line +=1
end
line = print("energy: ", @sprintf("%5.0f Wh", stats.e_mech); line = 1)
line = print("max force: ", @sprintf("%5.0f N", stats.max_force); line)
line = print("min height:", @sprintf("%5.0f m", stats.min_height); line)
# @sprintf("%5.0f N", stats.max_force)
# @sprintf("%5.0f m", stats.min_height)

Expand Down

0 comments on commit 7b2497e

Please sign in to comment.