Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ufechner7 committed Mar 28, 2024
1 parent 691d8db commit e689bb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 6 additions & 4 deletions examples/stats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ struct Stats
end

function show_stats(stats::Stats)
fig = GLMakie.Figure(size = (400, 400))
lscene = GLMakie.LScene(fig[1, 1], show_axis=false)
HEIGHT=300
UPPER_BORDER=20
fig = GLMakie.Figure(size = (400, HEIGHT))
if Sys.islinux()
# sudo apt install ttf-bitstream-vera
lin_font="/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMono.ttf"
if isfile(lin_font)
font=lin_font
Expand All @@ -20,8 +22,8 @@ function show_stats(stats::Stats)
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)
GLMakie.text!(fig.scene, 20, HEIGHT-UPPER_BORDER-line*32; text=lbl, fontsize = 24, space=:pixel)
GLMakie.text!(fig.scene, 250, HEIGHT-UPPER_BORDER-line*32; text=value, fontsize = 24, font, space=:pixel)
line +=1
end
line = print("energy: ", @sprintf("%5.0f Wh", stats.e_mech); line = 1)
Expand Down
7 changes: 3 additions & 4 deletions mwes/mwe_04.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ end
stats = Stats(333, 3900, 25)

function show_stats(stats::Stats)
# fig = GLMakie.Figure(size = (400, 400))
scene = GLMakie.Scene()
GLMakie.text!(scene, 20, 0, text="hello", fontsize = 30, space=:pixel)
display(GLMakie.Screen(), scene)
fig = GLMakie.Figure(size = (400, 400))
GLMakie.text!(fig.scene, 20, 0, text="hello", fontsize = 30, space=:pixel)
display(GLMakie.Screen(), fig)
nothing
end

0 comments on commit e689bb4

Please sign in to comment.