返回资讯中心
外部精选
软件工程
#开发者实时流

DatumHue – A Lua workstation for data visualization, games and creative coding

Write Lua in the editor you already use. DatumHue draws it, and redraws every time you save. Buy the Personal edition once, and it runs offline with no account.

Hacker News 最新tripokey2026/10/15 · 2026/10/1530 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Write Lua in the editor you already use. DatumHue draws it, and redraws every time you save. Buy the Personal edition once, and it runs offline with no account.

No card · One trial per person · Windows, macOS (Apple Silicon), Linux

Or run free creations in your browser at datumhue.app. No license needed.

Each picture is one file of Lua. Open any of them to read it.

Noise shapes the land, a palette paints sand, grass and rock, and lanterns glow in the hills.

local color = datumhue.color local vec3 = datumhue.math.vec3 local W, H, size = 1280, 720, 64 local WATER, SAND, GRASS, ROCK, LANTERN = 1, 2, 3, 4, 5

local scene = datumhue.scene.new({ width = W, height = H, hdr = true }) scene:mount({ width = W, height = H })

local shape = { width = size, height = 24, depth = size, sunlight = true } local land = datumhue.voxel.new(scene, shape) land:palette(WATER, { color = color("#3a515d"), transparent = true }) land:palette(SAND, { color = color("#dbbc7f") }) land:palette(GRASS, { color = color("#83c092") }) land:palette(ROCK, { color = color("#859289") }) land:palette(LANTERN, { emissive = color(16, 6, 1.5), light = 15 })

local rough = { seed = 11, frequency = 0.05, octaves = 5 } local hills = datumhue.noise.fbm(rough) local heights = datumhue.grid.new(size, size) for x = 0, size - 1 do for z = 0, size - 1 do local d = math.sqrt((x - 32) ^ 2 + (z - 32) ^ 2) / 30 local h = math.floor((hills:at(x, z) + 0.6) * 14 * (1 - d * d)) heights:set(x, z, h) if d < 1 then land:fill(x, 0, z, x, 2, z, WATER) end if h > 0 then local top = h > 11 and ROCK or h > 4 and GRASS or SAND land:fill(x, 0, z, x, h, z, top) end end end

local dice = datumhue.random.new(5) for _ = 1, 12 do local x, z = dice:int(12, 52), dice:int(12, 52) local h = heights:get(x, z) if h > 4 then land:set(x, h + 1, z, LANTERN) end end

scene.background = color("#2d353b") scene.tonemapping = "khronos_pbr_neutral" scene.bloom = { intensity = 0.4 } scene:directional_light({ direction = vec3(-0.6, -1, -0.3), intensity = 3000, shadows = true }) scene.camera.pos = vec3(90, 60, 90) scene.camera:look_at(vec3(32, 4, 32)) scene.camera:set_orthographic(44)

Count bike rides with SQL

Generate 20,000 bike trips, count them by day and hour in SQL, and draw when the city rides as a heatmap.

local color = datumhue.color local W, H = 1280, 720 local margin = { top = 112, right = 240, bottom = 80, left = 112 }

local dice = datumhue.random.new(7) local days = { "Sun", "Sat", "Fri", "Thu", "Wed", "Tue", "Mon" } local hours = {} for h = 0, 23 do hours[h + 1] = h == 12 and "noon" or ((h + 11) % 12 + 1) .. (h < 12 and "am" or "pm") end local rows = { "day,hour,minutes" } for _ = 1, 20000 do local day = dice:int(1, 7) local peaks = day <= 2 and { 11, 15 } or { 8, 17 } local hour = math.floor(dice:pick(peaks) + (dice:next() + dice:next() - 1) * 5 + 0.5) % 24 rows[#rows + 1] = string.format("%s,%s,%d", days[day], hours[hour + 1], dice:int(4, 50)) end local trips = datumhue.bytes(table.concat(rows, "\n")):csv() local busy = trips:query([[ SELECT day, hour, count(*) AS trips FROM data WHERE minutes > 10 GROUP BY day, hour ]])

local canvas = datumhue.draw.new({ width = W, height = H }) canvas:mount({ width = W, height = H }) local x = datumhue.chart.scale.band({ domain = hours, padding = 0 }) local y = datumhue.chart.scale.band({ domain = days, padding = 0 }) local chart = canvas:chart({ pos = datumhue.math.vec3(-W / 2, -H / 2, 0), width = W, height = H, margin = margin, x_scale = x, y_scale = y, }) local heat = datumhue.chart.scale.color({ colors = { color("#83c09240"), color("#83c092"), color("#dbbc7f"), color("#e69875") }, domain = "auto", }) chart:heatmap({ data = busy, x_column = "hour", y_column = "day", value_column = "trips", aggregate = "sum", color_scale = heat, gap = 3, }) chart:axis({ scale = y, side = "left", font_size = 32 }) chart:axis({ scale = x, side = "bottom", tick_values = { 6, 12, 18 }, font_size = 32 }) chart:legend({ kind = "gradient", color_scale = heat, pos = datumhue.math.vec2(W / 2 - margin.right + 24, H / 2 - margin.top), font_size = 32, }) chart:title({ text = "Trips over 10 minutes, by day and hour", font_size = 40, inset = 52 })

Paint with a shader

A dozen lines of shader code in three palette colors. With --watch, every save reloads it.

local color = datumhue.color

local source = [[ fn dh_fragment(uv: vec2<f32>) -> vec4<f32> { let aspect = dh.resolution.x / dh.resolution.y; var p = (uv - vec2<f32>(0.5, 0.5)) * vec2<f32>(aspect, 1.0) * 3.0; var t = 0.0; for (var i = 0; i < 5; i = i + 1) { p = p + vec2<f32>(sin(p.y * 1.7 + t), cos(p.x * 1.3 - t)) * 0.45; t = t + 0.8 + dh.time * 0.1; } let bands = 0.5 + 0.5 * sin(length(p) * 4.0 + p.x); let ink = mix(u.low, u.mid, smoothstep(0.0, 0.6, bands)); return mix(ink, u.high, smoothstep(0.7, 1.0, bands)); } ]]

local flow = datumhue.bytes(source):shader({ uniforms = { low = color("#2d353b"), mid = color("#83c092"), high = color("#e69875"), }, })

datumhue.ui.root:panel({ width = 1280, height = 720, padding = 0, border_radius = 0, material = flow, })

Own every pixel

A 256×144 framebuffer with dithering and a bitmap font, scaled up five times with every pixel kept sharp.

local color = datumhue.color local W, H = 256, 144 local sky = { "#232a2e", "#3a515d", "#7fbbb3", "#dbbc7f", "#e69875" }

local screen = datumhue.image.new({ width = W, height = H }) screen.filter = "nearest" screen:mount({ width = W * 5, height = H * 5 }) local pic = datumhue.image.picture()

for i = 1, #sky - 1 do local y = (i - 1) * 20 pic:rectfill(0, y, W, y + 20, color(sky[i])) pic:fillp(0x5A5A):rectfill(0, y + 15, W, y + 20, color(sky[i + 1])):fillp() end pic:rectfill(0, 80, W, 116, color(sky[5])) pic:circfill(176, 86, 22, color("#fdf6e3"))

local dice = datumhue.random.new(3) for _ = 1, 50 do pic:set(dice:int(0, W), dice:int(0, 36), color("#d3c6aa")) end

local ridge = { 0, H } for x = 0, W, 8 do ridge[#ridge + 1] = x ridge[#ridge + 1] = 94 + dice:int(0, 10) - math.max(0, 44 - math.abs(x - 88)) end ridge[#ridge + 1] = W ridge[#ridge + 1] = H pic:polygonfill(ridge, color("#425047"))

pic:rectfill(0, 116, W, H, color("#232a2e")) for y = 118, H, 3 do local w = 30 - (y - 118) pic:line(176 - w, y, 176 + w, y, color("#e69875")) end pic:print("DUSK", 10, 124, color("#a7c080"))

screen:apply(pic)

Roll a dungeon, carry a torch

Pathfinding, field of view and warm torchlight from the built-in grid tools.

local color = datumhue.color local cols, rows, T = 32, 18, 8

local map = datumhue.grid.new(cols, rows) map:fill(1) local dice = datumhue.random.new(2026) local rooms = {} for i = 0, 7 do local col = i < 4 and i or 7 - i local w, h = dice:int(4, 6), dice:int(3, 5) local x = col * 8 + dice:int(1, 7 - w) local y = (i < 4 and 0 or 9) + dice:int(1, 8 - h) map:fill_rect(x, y, w, h, 0) rooms[#rooms + 1] = { x = x + math.floor(w / 2), y = y + math.floor(h / 2) } end for i = 2, #rooms do local a, b = rooms[i - 1], rooms[i] map:fill_rect(math.min(a.x, b.x), a.y, math.abs(a.x - b.x) + 1, 1, 0) map:fill_rect(b.x, math.min(a.y, b.y), 1, math.abs(a.y - b.y) + 1, 0) end

local hero, hoard = rooms[2], rooms[#rooms] local seen = {} for _, c in ipairs(map:field_of_view(hero.x, hero.y, { range = 8, opaque = { 1 } })) do seen[c.y * cols + c.x] = true end local torch = datumhue.grid.light_field(cols, rows) torch:pour(hero.x, hero.y, 1, 6)

local dark, wall, stone = color("#1e2326"), color("#2d353b"), color("#414b50") local flame, gold = color("#e69875"), color("#dbbc7f") local pic = datumhue.image.picture():fill(dark) for y = 0, rows - 1 do for x = 0, cols - 1 do local lit, px, py = seen[y * cols + x] and torch:get(x, y) or 0, x * T, y * T if map:get(x, y) == 0 then local glow = stone:lerp(flame, lit):lerp(gold, lit * lit) pic:rectfill(px, py, px + T - 1, py + T - 1, glow) pic:set(px + 2, py + 5, dark) elseif map:count_neighbors(x, y, { match = { 0 } }) > 0 then pic:rectfill(px, py, px + T - 1, py + T - 1, wall:lerp(flame, lit * 0.6)) pic:line(px, py + 3, px + T - 1, py + 3, dark) end end end for _, c in ipairs(map:find_path(hero.x, hero.y, hoard.x, hoard.y, { blocked = { 1 } })) do pic:rectfill(c.x * T + 3, c.y * T + 3, c.x * T + 4, c.y * T + 4, gold) end for i = 3, 7 do pic:print("k", rooms[i].x * T - 8, rooms[i].y * T - 11, color("#e67e80")) end pic:print("$", hoard.x * T, hoard.y * T - 3, gold) pic:print("@", hero.x * T, hero.y * T - 3, color("#fdf6e3"))

local screen = datumhue.image.new({ width = cols * T, height = rows * T }) screen.filter = "nearest" screen:mount({ width = cols * T * 5, height = rows * T * 5 }) screen:apply(pic)

Teach with pages that compute

A lesson page with prose, a slider and a chart. Move the slider and the page's code redraws the wave.

local color = datumhue.color

local lesson = [[

How a square wave hides in sines

Add the odd harmonics of a sine wave, each one faster and fainter than the last, and the sum squares off.

row gap=16 {
 label "Harmonics" id="count" font_size=16
 slider id="waves" on_change="{{ redraw }}" min=1 max=25 value=5 step=1 width=240
}
chart id="plot" height=200

]] local page = datumhue.bytes(lesson):book()

local plot, count -- The slider's on_change calls this global function with its value. function redraw(waves) local pts = {} for i = 0, 400 do local x, y = i / 400 * 4 * math.pi, 0 for k = 1, waves * 2, 2 do y = y + math.sin(k * x) / k end pts[#pts + 1] = datumhue.math.vec2(x, y) end count.text = string.format("Harmonics: %d", waves) plot:clear() plot:line({ points = pts, color = color("#7fbbb3"), width = 3 }) end

datumhue.screen.request_zoom(2) page:mount({ width = 640, height = 360, padding = 16 }) plot, count = page:element("plot"), page:element("count") plot.y_scale.domain = { min = -1.2, max = 1.2 } redraw(page:element("waves").value)

Make your own

Every example on this page runs in the free trial, on your own computer.

Write in your own editor and run it in the workstation app. The browser at datumhue.app runs what people publish.

local canvas = datumhue.draw.new({ width = 1280, height = 720 }) canvas:mount({ width = 1280, height = 720 }) canvas:circle({ radius = 240, color = datumhue.color("#e69875") })

Write. Save these lines as hello.lua in any editor.

Run. In a terminal, datumhue run --watch hello.lua opens the picture and redraws it on every save. Get started has the exact command for your system.

Fix. If a save doesn't compile, the last working version keeps running while you fix it.

Yours, offline

The Personal and Indie workstations never connect to the network: no account, no online license check, no telemetry. Every release published in the five years after you buy is yours to keep.

Charts, pixels, 3D, voxels, shaders, physics, sound and interface share one Lua API. Your update function runs every frame and can read keys, mouse, touch and gamepads. A chart can sit inside a game, and a game inside a lesson.

In a project made with one command, any editor with the Lua language server completes and type-checks every call. Breakpoints, tests with branch coverage, a profiler and a live console come in the workstation app.

Tilemaps, sprites, 2D and 3D physics, pathfinding, dialogue, gamepads and save files are built in. With Indie, ship to Windows, macOS (Apple Silicon) and Linux; your players need no license and no account.

A pixel framebuffer with dithering and a bitmap font, shaders you write yourself, particles, voxels and synthesized sound. What you make is yours, paid work included, with no royalties.

Open CSV and Parquet files on your computer, query them with SQL, and pan, zoom and brush the charts, all offline. Heatmaps, histograms, box plots and faceted grids are built in.

Pages that mix prose, charts, sliders and running code. Write and present them with Personal. To publish them to readers' browsers at datumhue.app, use the Platform workstation app and a publishing subscription, served from a package server yo

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →