Skip to content

Latest commit

 

History

History

examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Rune examples

Every package under examples/, grouped by what it teaches. All headless commands below run from the repository root.

In debug builds, apps built with rune::run, App::run, or rune::run_windows automatically include Rune's headless CLI (--snap, --tree, --list-scenes, --list-windows, --script, --trace, --strip, --video, --html). Release builds include it only when Rune's tooling feature is enabled.

Basics and state

Example What it teaches Main APIs Platforms Repo-root headless command
hello Minimal single-state app with a spring-animated switch and accessible role/label rune::run, AppSpec, El::motion, El::on_press, tok Desktop, headless cargo run -p hello -- --snap target/hello.png --scene on
todo Keyed list with add/toggle/remove, enter/exit presence animations, and a spring or timed-curve progress bar (--scene timed) El::key, ScrollSpec, Spring, El::transition_motion, El::frame_motion, El::press_motion, tok::Theme Desktop, headless cargo run -p todo -- --snap target/todo.png
settings Full settings window: System/Light/Dark ColorScheme override for native window chrome and macOS app appearance, macOS sRGB vs unmanaged window colour space (SETTINGS_MAC_COLOR_SPACE=unmanaged, works under both Metal and RUNE_GPU_BACKEND=wgpu), accent picker, sliders, toggles, time scale, system font pickers (--scene fonts), reactive window titlebar (Cx::is_maximized, Cx::is_full_screen, Tx::set_full_screen), and macOS native menus (MenuItem::about, custom ⌘Q, nested MenuItem::submenu and closure MenuItem::with_action) ColorScheme, MacColorSpace, MacWindowOptions::color_space, App::color_scheme, Tx::set_color_scheme, AppHandle::set_color_scheme, Cx::is_maximized, Cx::is_full_screen, Tx::set_full_screen, Tx::toggle_maximized, AppSpec::scenes, rune::text::installed_families, Tx::set_font_families, MenuItem::about, MenuItem::submenu, MenuItem::with_action, El::on_drag, Phase, Spring, tok::Theme Desktop, headless (hot, frame-profile optional) cargo run -p settings -- --snap target/settings.png --scene dark
playground Built-in story browser (⌘⇧D) with nested groups, variants, side-column controls, hover/press replacement buttons & popup hover blocking, a Controls/Haptics story (Tx::haptic, Haptic, ImpactStrength, HapticOutcome), a Controls/Popups/Passive press observer story (El::on_any_press, PointerEvent::pressing), a Controls/Pointer/Pointer lock story (El::pointer_lock, Cx::pointer_locked), a Controls/Buttons/Press cursor & bounds story (Cx::press_cursor, Tx::press_point, El::hover_tracks_bounds), a Controls/Motion/Loops & press offset story, a Controls/Motion/Reveal pacing story (--reveal-fps / RUNE_REVEAL_FPS, CLI flag wins), a Controls/Motion/Ambient pacing story (--ambient-fps / RUNE_AMBIENT_FPS, CLI flag wins), an overlay story, a Lists/Scroll anchoring story, a Lists/Virtual items canvas story (El::virtual_items, VirtualItems), an El::on_mount same-frame mount lifecycle story, a Text/Indent & hanging story, a Text/Inline boxes story (El::inline, InlineBox, InlineAlign), a Text/Emoji family story (Tx::set_emoji_family, App::emoji_family), a state-independent on_layout_any / on_visible_any / on_key_any timeline strip story, a Tx::read_elements element inspector, and a Pick::interactive / Pick::drop_targets pointer-pick overlay App::playground, Playground, Story, Story::overlay, Stage, El::hover_fill, El::press_fill, El::hover_border, El::press_border, El::on_any_press, PointerEvent::pressing, El::pointer_lock, Cx::pointer_locked, Cx::press_cursor, Tx::press_point, El::hover_tracks_bounds, El::press_offset, Sequence::repeating, El::loop_times, App::reveal_fps, App::ambient_fps, El::scroll_anchor, El::no_scroll_anchor, El::virtual_items, VirtualItems, El::on_mount, El::text_indent, El::set_text_indent, El::inline, InlineBox, InlineAlign, App::emoji_family, Tx::set_emoji_family, El::on_layout_any, El::on_visible_any, El::on_key_any, Tx::read_elements, ElementInfo, Pick, Picked Desktop, headless cargo run -p playground -- --snap target/playground.png --playground
knobs Live-tuning a UI card with rune-knobs (⌘⇧K panel and playground side column) rune_knobs::{Group, Knob, Knobs, Preset}, App::playground Desktop, headless cargo run -p knobs -- --snap target/knobs.png --scene open

Motion and live updates

Example What it teaches Main APIs Platforms Repo-root headless command
live-values Updating opacity, offset, rotation, and wrapped/truncated live text at 60–120 Hz from background threads without rebuilding the view (--bench compares against --rebuild) Live<f32>, Live<[f32; 2]>, LiveText, El::live_opacity, El::live_offset, El::live_rotation, El::live_text, Live::smooth Desktop, headless cargo run -p live-values -- --snap target/live-values.png --at 2
matched Shared-element geometry flight between a 2×2 grid and a full-stage view (with spring and --scene timed curve modes), --scene in-place (in-place segmented pill flight under labels + Tx::instant() toast entrance), and a --scene mips streaming/mipmapped Pixels comparison El::matched, El::matched_in_place, El::matched_motion, El::enter_in_instant, El::transition_motion, El::frame_motion, El::press_motion, Transition, Pixels::{replace, with_rgba}, ImageCache::rgba_into, SurfaceFit Desktop, headless cargo run -p matched -- --snap target/matched.png --scene one (--scene timed, --scene in-place, --scene mips)
odometer Rolling numeric digits and right-aligned usage headers using rune-kit's RollingText rune_kit::{RollingText, Button, Kit}, El::width_leads, El::ride_trailing Desktop, headless cargo run -p odometer -- --snap target/odometer.png
frosted-bar Long list scrolling behind an in-window blurred bottom bar with a live ScrollSource badge (direct, momentum, edge return, programmatic) El::backdrop_blur, El::scroll, El::on_scroll_offset, ScrollPos, ScrollSource, AppSpec::scenes Desktop, headless cargo run -p frosted-bar -- --snap target/frosted-bar.png --theme dark

Desktop, input, windows, and overlays

Example What it teaches Main APIs Platforms Repo-root headless command
drag-out Dragging a file, app bundle, text, or custom MIME + Copy/Move + hotspot icon (--scene custom-mime) out of a Rune window into external apps (macOS, Windows, Wayland) DragItem, DragItem::data, DragImage::hotspot, DragOutcome, El::drag_out, El::on_drag_start, El::on_drag_end Desktop, headless cargo run -p drag-out -- --scene custom-mime --tree
drop-files Accepting file drops on targeted drop zones, state-aware accepts_drag, dragged-paths preview, passive ancestor strip observers, multi-file Open dialog (Tx::open_files), macOS system-opened files (App::on_open_files, --scene opened-with-app, scripts/open-with-app.json), and Open/Reveal actions for dropped paths El::on_drop_files, El::accepts_drag, El::on_drop_hover, El::on_drop_hover_within, El::on_drop_move_within, Tx::drag_paths, Tx::open_files, App::on_open_files, Tx::open_path, Tx::reveal_path Desktop, headless cargo run -p drop-files -- --script examples/drop-files/scripts/drop.json --frames 120 --every 8 --cols 5 --strip target/drop-files.png
rich-clipboard Reading and writing plain text, sanitised HTML, and RTF on the OS clipboard, with field spellcheck, clipboard revision counter, floating selection bar (Cx::field_selection_rects), byte-offset hit-testing (Tx::text_offset_at), mention pills with leading Pixels logos/rings/radii, pill click inspection (El::on_pill_press), live caret/selection readout (El::on_input_selection), pill copy payloads (El::pill_copy_text, El::on_input_copy, ClipboardContent::has_own_pills), padded SpanBox search-filter chips, El::overline rich-text decorations, and plain-text LineFill code-block / quote decorations, and a macOS OptionAsAlt picker on an El::ime_cursor caret (--scene selected, --scene decorations, --scene pill-copy, --scene ime-option-as-alt) ClipboardContent, OptionAsAlt, El::ime_option_as_alt_mode, ClipboardContent::has_own_pills, TextEdit, TextEdit::selected_with_pills, text_input, El::on_pill_press, El::on_input_selection, El::on_input_copy, El::pill_copy_text, PillStyle, SpanBox, El::span_box, El::overline, El::pill_image, El::pill_with_image, LineFill, El::line_fills, El::spellcheck, Tx::copy, clipboard::revision, Cx::field_selection_rects, Tx::text_offset_at Desktop, headless cargo run -p rich-clipboard -- --scene decorations --snap target/rich-clipboard.png
sketch Freehand drawing canvas with a custom 2× PNG cursor, right-button pan drag (pointer_buttons([PointerButton::Secondary])) keeping right-click for the context menu, extra-button undo/redo/pan reset (El::on_button), and diagonal/bidirectional/one-way resize, alias, and copy cursors (--scene handles, --scene panned) Cursor::Image, CursorImage::png, Cursor::ResizeNwse, Cursor::ResizeNesw, Cursor::ResizeEw, Cursor::ResizeNs, Cursor::ResizeN, Cursor::ResizeE, Cursor::ResizeS, Cursor::ResizeW, Cursor::Alias, Cursor::Copy, Shape, canvas, El::on_drag, El::pointer_buttons, El::on_button, PointerButton Desktop, headless cargo run -p sketch -- --snap target/sketch.png
background Windowless/background app lifetime controlled over stdin, optional system tray (--tray, live icon/title/rect updates and checked menu items), native window/display handle inspection with pre-exit display teardown hook, plus HUD (with reactive on_availability) and clickable corner overlays App::windowless, App::overlay, App::on_window, App::on_display_close, WindowHandle::with_raw_handle, WindowHandle::with_raw_display_handle, AppHandle, OverlayHandle, ConfiguredOverlay::on_availability, Tray, TrayIcon::template, TrayItem::check Desktop, headless (macOS --accessory / --tray options) cargo run -p background -- --snap target/background.png --scene ticked
launcher Multi-window notes app (macOS document window with MacWindowOptions represented file proxy icon, title_from_file, show_title, accepts_first_mouse(false), live Tx::set_represented_file / Tx::set_document_edited toggles under --scene document-edited, and an unsaved-changes confirmation dialog driven by App::on_close_request under --scene unsaved-close and App::on_quit_request under --scene unsaved-quit) plus a borderless ⌘Space launcher panel with 8-way El::window_resize edge/corner grips and Linux freedesktop themed icons (--scene themed-icons), composable under --desktop rune::run_windows, WindowSpec, WindowOptions::launcher_panel, MacWindowOptions, Tx::set_represented_file, Tx::set_document_edited, App::on_close_request, CloseResponse, App::on_quit_request, QuitResponse, El::window_resize, ResizeEdge, App::global_shortcut, ImageCache::themed_icon, Image::is_not_found Desktop, headless cargo run -p launcher -- --window notes --scene unsaved-close --snap target/launcher.png
overlay Control window plus one transparent, click-through overlay per display sharing a Live cursor rune::run_windows, WindowSpec, WindowOptions::overlay, WindowHandle, Live Desktop, headless (macOS window_number) cargo run -p overlay -- --window overlay-0 --snap target/overlay.png --at 2
glass-card Spring-animated card over a live test pattern using system backdrop materials (Glass, Popover, Sidebar), --overlay springing non-activating overlay pill probe (macOS and Windows 11 with --features rune/windows-system-material), and cap-overflow fallback inspection rune::run_windows, El::system_material, SystemMaterial, App::max_native_materials, MacWindowOptions, OverlaySpec Desktop, headless (card window); macOS and opt-in Windows 11 for live system material (fallback tint elsewhere) cargo run -p glass-card -- --window card --scene overflow --tree target/glass-card.json
glass-panel Floating non-activating macOS overlay panels (flight handing off to dock) with continuous corners and system material rune::run_windows_with, RunOptions, App::windowless, App::overlay, SystemMaterial macOS for live system material and panel levels No headless CLI mode — see Notes on glass-card and glass-panel

Graphics, media, and compositing

Example What it teaches Main APIs Platforms Repo-root headless command
shapes Vector strokes, filled polygons, compound paths with transparent holes (FillRule), SVG 2 path data (Path::from_svg, Shape::fill_svg, fill_svg_with, stroke_svg), Bézier paths, waveforms, multi-hole circular element cutouts (El::cutout_circles), nearest-neighbour pixel-art scaling (El::image_filter, ImageFilter::Nearest), runtime alpha-tinted symbolic icons (El::pixels_tint), wrapped and tiled image patterns (El::pixels_wrap, El::pixels_tile, PixelsWrap), and memoized canvases Shape, Path, FillRule, LineCap, ImageFilter, PixelsWrap, canvas, memo, El::cutout_circles, El::image_filter, El::pixels_tint, El::pixels_wrap, El::pixels_tile Desktop, headless cargo run -p shapes -- --snap target/shapes.png --at 1.5
video-player Playing video or audio files and URLs (defaults to an embedded test clip) with keyframe scrub bar (seek_fast / is_seeking), frame stepping (step), frame-rate and shown-timestamp readout (frame_duration / presented_time), mute, loop, and output-device controls Player, PlayerState, SurfaceFit, Waker Desktop, headless cargo run -p video-player -- --snap target/video-player.png --at 0.6
video-tiles Four live video surfaces fed from a background producer, plus a headless --bench-native mode NativeSurface, ByteFrame, SurfaceFit, native_surface::macos::PixelBuffer Desktop, headless (NV12 IOSurface on macOS; byte planes elsewhere) cargo run -p video-tiles -- --snap target/video-tiles.png --scale 2
cursed-settings Settings window where controls trigger custom rune-fx and rune-light effects via a compositor rune::run_with, Compositor, rune-kit, rune-theme-opencode, rune-fx, rune-light Desktop, headless cargo run -p cursed-settings -- --snap target/cursed-settings.png --scene fire
showreel Clock-driven showcase scenes combining Rune UI and rune-fx for frame-exact --video captures App::compositor, AppSpec::scenes, rune-fx Desktop, headless cargo run -p showreel -- --scene deploy --snap target/showreel.png --at 1.0

Components, scripting, and web

Example What it teaches Main APIs Platforms Repo-root headless command
kit-gallery Every rune-kit component story (OpenCode theme, --kit neutral, or --kit palette), plus inline link hover preview cards anchored via Markdown::on_link_hover (--scene rune-markdown--link-hover) and click/keyboard link popovers anchored via Tx::link_rect (--scene rune-markdown--link-popover), tall single-line El::align_y inputs (--scene rune-text--align-y-input), image decode and Display P3 ICC-to-sRGB comparisons (--scene rune-image--decode) rune-kit (markdown, mermaid), rune-theme-opencode, AppSpec::scenes, ImageCache::load_scaled, Image::intrinsic_size Desktop, headless cargo run -p kit-gallery -- --scene ui-button--variants --snap target/kit-gallery.png --theme dark --size 720x300
luau-panel Sandboxed Luau UI script with task.wait, signals, 1,000-row ui.virtualList, a --scene props showcase (maxLines, matched, transforms, outline, cols, % sizes, ARIA roles, onScroll, view.reducedMotion), and live file watch; includes a second luau-bench binary rune_luau::{Script, Sources, ScriptOptions}, Script::watch Desktop, headless, web (scripts/web-build.sh luau-panel with WASI_SDK_PATH); native builds need a host C++ compiler cargo run -p luau-panel --bin luau-panel -- --snap target/luau-panel.png (benchmark binary: cargo run -p luau-panel --bin luau-bench --profile perf)
web-hello Responsive chat layout with safe-area insets, text input, clipboard copy, wasm32 browser entry point, ?rtl-proof RTL/locale scene, and ?pointer-lock-proof browser pointer-lock scene Cx::safe_area, Cx::system_dark, Cx::locale, Cx::system_languages, El::dir, text_input, ScrollSpec, App::on_frame_drawn, rune::web::open_url Desktop, headless, web (scripts/web-build.sh web-hello) cargo run -p web-hello -- --snap target/web-hello.png
web-showcase Interactive switch, spring picker, and throwable puck built to mount on an existing webpage canvas AppSpec, Spring, El::on_drag, wasm_bindgen Desktop, headless, web (scripts/web-build.sh web-showcase) cargo run -p web-showcase -- --snap target/web-showcase.png --size 560x320 --scale 2
fetch Cross-target JSON fetch: spawn_local + web_sys fetch + AppHandle::update_if on web, Latest on native App::handle, App::init, App::on_ready, AppHandle::update_if, Latest Desktop, headless, web (scripts/web-build.sh fetch) cargo run -p fetch -- --snap target/fetch.png

Labs and benchmarks

These packages are diagnostic labs, benchmarks, or site asset renderers rather than minimal app templates.

Example Kind What it exercises Main APIs Platforms Repo-root headless command
lab Lab Interactive lighting, glass, and effects sandbox with live knobs for rune-light and rune-fx App::compositor, rune-light, rune-fx, rune_motion::{Animated, VelocityTracker} Desktop, headless cargo run -p lab -- --scene lamp --snap target/lab.png
hello-floor Benchmark Measures the least memory a Rune window holds (HELLO_FLOOR_STEP=empty, text, effect; HELLO_FLOOR_MEMORY_POLICY; HELLO_FLOOR_WARM; RUNE_CPU_FIRST=only) beside hello-floor-bare, a frameworkless Direct3D 12 / 11 window stopped at each start step; measure.ps1 prints every step's private working set and the README holds the measured ladder App::gpu_memory_policy, GpuMemoryPolicy, App::prewarm_effects, PrewarmEffects, El::backdrop_blur, CpuFirst Desktop (the bare program and measure.ps1 are Windows only) pwsh examples/hello-floor/measure.ps1
launch-floor Benchmark Measures minimum first-frame launch cost (bare, shell, reads, LAUNCH_FLOOR=warm cache prewarm, LAUNCH_FLOOR_MEMORY_POLICY, and LAUNCH_FLOOR_CPU_FIRST) App::on_ready, App::layout_seed, App::gpu_memory_policy, GpuMemoryPolicy, App::cpu_first, CpuFirst, rune::set_gpu_memory_policy, rune::marks, rune::warm_gpu_cache Desktop, headless (debug builds include tooling; LAUNCH_FLOOR=warm opens no window) cargo run -p launch-floor -- --tree
motion-bento Benchmark / lab 12-tile control center and --load/--ramp stress wall driven by a seeded chaos schedule, with opt-in --present-times presentation latency HUD/metrics; shares its Rune-free model and schedule crate motion-bento/chaos (motion-bento-chaos) Live, memo, App::on_frame_encoded, App::on_frame_presented, FramePresented, rune-kit, motion_bento_chaos Desktop, headless (actual present timestamps on macOS Metal, Windows DX12/DXGI, and Linux Wayland wp_presentation) cargo run -p motion-bento -- --snap target/motion-bento.png --at 1.0
overlay-lab Lab Multi-display overlay pill with edge/corner cycling and Display::work_area() readout, full-screen area picker, regional hit testing, ordinary borderless window with WindowsWindowOptions and live capture-exclusion toggle (--scene native-window, OVERLAY_LAB_NATIVE_WINDOW=1), plus extra native probe binaries layer-filter-overlay and occluded-timer App::overlay, Display::work_area, WindowsWindowOptions, WindowSpec::exclude_from_capture, WindowHandle::set_exclude_from_capture, OverlayOptions, OverlayPlacement, OverlayInput, OverlayLevel, KeyPolicy Desktop, headless (capture exclusion on Windows and macOS; native status levels on macOS) cargo run -p overlay-lab -- --scene work-area --snap target/overlay-lab.png
site-scenes Asset renderer Renders the home-page material stills (metal, glass, light) plus an opt-in runtime scene directly through Gpu::headless, Offscreen, and Renderer::render_runtime_to_offscreen Gpu::headless, Offscreen, Renderer::render_runtime_to_offscreen, write_png, rune-fx, rune-light Headless only (custom CLI, no rune::run) cargo run -p site-scenes -- --only runtime --out target/site-scenes

Notes on glass-card and glass-panel

  • glass-card (examples/glass-card/src/main.rs) builds two windows through rune::run_windows: pattern passes App::args(vec![]) while card inherits headless CLI flags (unless GLASS_CARD_TRACE is set), so --window card --scene sidebar --tree target/glass-card.json and --window card --scene overflow --tree target/glass-card.json (with optional GLASS_CARD_MAX_MATERIALS=6) run headlessly. Live SystemMaterial requires a native macOS window; headless renders substitute a flat tint.
  • glass-panel (examples/glass-panel/src/main.rs) runs a 1×1 windowless() host app and drives three non-activating macOS overlay panels (backdrop, flight, dock) from a background thread loop. Headless CLI targets only the 1×1 dummy host window and neither runs the overlay panels nor composites macOS system materials.