Fortran Immediate-mode GUI for User interfaces, Rendering and Exploration
FIGURE gives a Fortran program interactive windows, widgets and plots: Dear ImGui, ImPlot and ImPlot3D on SDL3 and OpenGL 3, on Linux, macOS and Windows. It is immediate mode: no widget objects, no handles, no callbacks. The interface is declared every frame, and its state is your own variables. Plots read your arrays in place, without copies. v0.8.0 is the first release I announce here (written with the help of an AI assistant).
Disclaimer: beta, and still more an experiment than a mature library. FIGURE has had only eight minor releases; the API can and will change before v1.0. Few applications use it so far (my own tools for a CFD solver), so most of it has been exercised by its tests, not by users. The native layer carries a few patches to Dear ImGui and ImPlot that are not upstream yet, and the known issues page is not short. Try it, break it, tell me; do not build anything on it yet that you cannot afford to rewrite.
figure_hello: a button, a frequency slider dragged by the mouse, and a sine wave that follows it.
mpirun) run with their output streamed into a log view. app%init_remote() serves the same interface to a web browser, with an access token: no display or GPU on the program’s side, e.g. a cluster node through an SSH tunnel.app%init_headless() and the figure_testing module drive the interface with synthetic input (clicks, keys, typing) in CI without a display, and a CPU renderer draws every frame, so tests compare pictures with goldens.
figure_mandelbrot: 60 wheel steps, about 175 times into the seahorse valley, then more iterations; every frame recomputed at the plot’s resolution and uploaded as a texture.
A Lorenz trajectory growing in an ImPlot3D plot, its newest point marked; a right drag turns the box.
FIGURE’s 3-D view: a slender body coloured by a field, cut by a plane moved and turned with a gizmo.
The whole of a program with a window, a slider and a plot that follows it:
program readme
use, intrinsic :: iso_fortran_env, only : int32, real64
use figure, only : app_object, ig_begin, ig_end, ig_set_next_window, ig_slider, ip_begin_plot, ip_end_plot, ip_line
implicit none
type(app_object) :: app
real(real64) :: x(200)
real(real64) :: frequency
integer(int32) :: i
x = [(0.05_real64 * i, i = 0, 199)]
frequency = 1.0_real64
call app%init('FIGURE', 800, 500)
do while (app%next_frame()) ! the interface is declared every frame
call ig_set_next_window(20.0_real64, 20.0_real64, 760.0_real64, 460.0_real64)
if (ig_begin('Wave')) then
if (ig_slider('frequency', frequency, 0.1_real64, 5.0_real64)) continue
if (ip_begin_plot('sin(f x)', height=-1.0_real64)) then
call ip_line('y', x, sin(frequency * x))
call ip_end_plot()
endif
endif
call ig_end()
enddo
call app%destroy()
endprogram readme
curl -fsSL https://github.com/szaghi/figure/releases/latest/download/install.sh | bash -s -- --gnu
gfortran readme.F90 $(pkg-config --cflags --libs figure) -o readme
The one-line installer builds the latest release (--nvidia for nvfortran), installs it into ~/.local, compiles and runs a test program against it, and prints the line above.
The same kind of program grows into an application by adding windows: here they dock into one another.
A window dragged by its title bar onto the Log area docks there as a tab; then the frequency slider changes the plot.
Its appearance changes at runtime: app%set_style picks one of seven built-in styles, or combines a look (the geometry) with a palette (the colours); every colour and size of Dear ImGui and ImPlot can be set by name; and the style editor saves a theme file that the program loads back.
gallery: one program through the seven built-in styles (seal, seal-light, paper, high-contrast, and Dear ImGui’s dark, light, and classic), one and a half seconds each.
The showcase is the application that drove the design: a run checker and two input editors for a CFD solver, in one window, with the solvers run from it.
xall_evol, the run checker: the residuals of six variables on a log axis follow a run’s history files as they grow; the summary table updates (synthetic files).
xall_gui: the mesh tool runs on 2 processes from the window; its output scrolls, with a notification when it finishes.
ig_color_picker), pie charts and bubbles ( ip_pie_chart, ip_bubbles), error bars along x; in ImPlot3D, colours and sizes per point, axis formats and ticks, its style by name.
New in v0.8.0: pie charts and bubbles.
The tutorial’s solver studio, chapter 13: F5 runs the solver; when it has converged, the plate’s temperature is shown as a heatmap with labelled contour lines and a colour bar.
FIGURE builds with FoBiS or fpm (a self-contained vX.Y.Z-fpm tag per release), its native layer with CMake; your own project finds an installed FIGURE with pkg-config or CMake’s find_package(figure). Only SDL3 comes from the system. It is released under the MIT licence; the native layer compiles Dear ImGui, ImPlot, cimgui and cimplot (MIT) and SDL3 (zlib).
Coming next: FIGURE’s patches to Dear ImGui and ImPlot reported upstream, and whatever the first users find.
Feedback, issues, and contributions are welcome, and in this phase, bug reports most of all.
Stefano