DatumHueEnterprise v0.0.24datumhue.com
Contents

handle12 methods, 4 fields

Image

A raster image (pixel data + a renderable texture). Created blank by datumhue.image.new, or produced by bytes:image(), file:read():image(), dir:read(rel):image() and datumhue.screen.screenshot(). Mount via image:mount(opts), read pixels with image:get, persist with image:encode_png. Draw by recording a datumhue.image.picture() and replaying it with image:apply(picture).

Obtained from
datumhue.screen.screenshot, datumhue.image.new, Bytes:image, PackageRef:icon, PackageRef:screenshots, SceneChromaticAberration.color_lut, UiElement.leading_icon
Accepted by
datumhue.material.standard, datumhue.particles.emitter, datumhue.shader.new, Scene:sprite, Material:set_source, Material:update, Voxel:heightmap, Voxel:stamp_image and 11 more

The examples on this page start from:

lua
local color = datumhue.color
local image = datumhue.image.new({ width = 64, height = 64 })
image:mount({ width = 256, height = 256 })

Fields 4

FieldTypeAccessDescription
filterimage.Filterread/writeTexture sampling mode wherever the image is drawn. Set nearest to keep pixel art crisp; the default smooths.
widthintegerread-onlyWidth in pixels. Raises if the image isn't loaded yet — await it with image:ready() or datumhue.ready{...} first.
heightintegerread-onlyHeight in pixels. Raises if the image isn't loaded yet — await it with image:ready() or datumhue.ready{...} first.
stateReadyStateread-onlyCompletion state of this operation. Reading it never raises or suspends; a failed operation's error surfaces at :ready().

Methods 12

Image:get

method
Image:get(x: number, y: number) -> Color?

Read a pixel. Returns a color (.r/.g/.b/.a, 0-1), or nil when out of bounds. Raises if the image isn't loaded yet — await it with image:ready() or datumhue.ready{...} first.

Example
-- Pixels count from 0 at the top-left corner.
local pic = datumhue.image.picture()
pic:set(3, 2, color("#ff8000"))
image:apply(pic)
print(image:get(3, 2)) --> color(1.0, 0.501960813999176, 0.0, 1.0)
print(image:get(0, 0)) --> color(0.0, 0.0, 0.0, 0.0)
print(image:get(64, 0)) --> nil

Image:apply

method
Image:apply(pictures: Picture | Picture[])

Replay one or more pictures onto this image in a single atomic pass, every recorded op in order. Accepts a single picture or an array of them (drawn in order, sharing draw state). The image is never seen partially updated. Raises if this image, or any image a picture blits from, isn't loaded yet — await it with image:ready() or datumhue.ready{...} first; nothing is drawn when it raises.

Example
local sky = datumhue.image.picture()
sky:fill(color("#7fbbb3"))
local sun = datumhue.image.picture()
sun:circfill(48, 16, 8, color("#dbbc7f"))
-- One picture, or several drawn in order.
image:apply(sky)
image:apply({ sky, sun })

Image:cursor

method
Image:cursor() -> Vec2?

Cursor position in this image's own pixel coordinates (Y-down from the top-left), accounting for how the image is displayed — correct even when it is letterboxed or scaled inside a larger element, at every zoom and stretch mode. Nil when the cursor isn't over a mounted, unoccluded instance. The fit-aware companion to elem:mouse_position(); mount the image first.

Image:touch

method
Image:touch(id: integer) -> Vec2?

The position of the touch with this id in this image's own pixel coordinates (y down from the top-left), taking into account how the image is displayed. Nil when the touch isn't down, belongs to a touch control, or isn't over a mounted, unoccluded instance. The touch companion of cursor(); two touches on two images each resolve.

Example
datumhue.on_update(function(dt)
    for _, touch in ipairs(datumhue.input.touches()) do
        -- In the image's own pixels, through how it is displayed; nil
        -- off it.
        local at = image:touch(touch.id)
        if at then
            print(touch.id, at)
        end
    end
end)

Image:remove

method
Image:remove()

Remove the image and any UI element mounting it, freeing its texture. Afterwards state reads failed, calling remove again does nothing, and every other method and property of the handle raises. Copies already made from it (a sprite, a material texture, a shader channel) keep rendering.

Image:mount

method
Image:mount(options?: ui.ImageOptions) -> UiElement?

Mount this render target as a UI image element. Returns the new UiElement, or nil if the app has no UI.

Example
local pic = datumhue.image.picture()
image:apply(pic:circfill(32, 32, 24, color("#a7c080")))
-- A second view of the same image, letterboxed and tinted.
image:mount({
    width = 192,
    height = 96,
    fit = "contain",
    tint = color("#e69875"),
})
-- Pixel art: a whole number of screen pixels per pixel.
image.filter = "nearest"
image:mount({ width = 128, height = 128, fit = "integer" })

options ui.ImageOptions options 41 keys, 34 inherited

KeyTypeDefaultDescription
parentUiElementthe app's content areaParent element.
materialShaderthe texture shows unprocessedShader material for post-processing.
fit"fill" | "contain" | "cover" | "scale_down" | "integer" | "sharp""fill"How the texture maps into the element box; aspect-preserving modes center in the box. "sharp" draws with its own shader, so it takes no material; neither "integer" nor "sharp" takes auto_size. "integer" scales a draw canvas's or scene's size in UI px, so on one whose texels are finer than that (a canvas without pixel_perfect on a HiDPI display, a scene) a texel covers a fraction of the multiple. Pair it with the source's filter set to "nearest".
auto_sizebooleanfalseFor a draw canvas or scene: resize it to the element's size in UI px whenever the element resizes, so what it draws keeps its size in UI px instead of scaling with the element. A scene renders at its own size, so this also keeps one sharp. Raises on a plain image, whose resolution is fixed (use fit).
accessible_labelstringthe image has no accessible nameAccessible name for assistive technology. Images carry no text, so unlike text-bearing widgets they derive no name of their own. Set it on images that convey meaning, and decorative on the rest.
decorativebooleanfalseKeeps the image out of what assistive technology reads, as alt="" does on the web: a screen reader passes over it. Set it on an image that only decorates, such as art beside text that says who or what it shows. Setting both this and accessible_label raises, and so does naming the image later.
tintColor | ThemedColorthe image shows its own colorsA color each texel is multiplied by, alpha included, so white leaves the image as it is and a lower alpha fades it. A theme token follows the theme.

Also takes every key of ui.NodeStyle (34 keys).

Image:atlas

method
Image:atlas(opts: image.AtlasOptions) -> Atlas

Build a uniform grid Atlas over this image. Index cells from 0, row-major, with atlas:sprite(index).

Example
-- 16 cells of 16x16 pixels, indexed row by row from the top-left.
local atlas = image:atlas({
    tile_size = datumhue.math.vec2(16, 16),
    columns = 4,
    rows = 4,
})
local bottom_right = atlas:sprite(15)

opts image.AtlasOptions options 5 keys

KeyTypeDefaultDescription
tile_size requiredVec2no defaultCell size in pixels (width, height).
columns requirednumberno defaultNumber of columns in the grid.
rows requirednumberno defaultNumber of rows in the grid.
paddingVec2datumhue.math.vec2(0, 0)Gap in pixels between cells.
offsetVec2datumhue.math.vec2(0, 0)Pixel offset of the grid's top-left from the image origin.

Image:sprite

method
Image:sprite(opts?: image.SpriteOptions) -> Sprite

Build a reusable Sprite appearance from this whole image. Draw it with canvas:sprite(sprite, {pos = ...}).

Example
local sprite = image:sprite({
    size = datumhue.math.vec2(32, 32),
    flip_x = true,
})

opts image.SpriteOptions options 4 keys

KeyTypeDefaultDescription
colorColordatumhue.color(1, 1, 1)Tint multiplied with the texture; white leaves it unchanged.
flip_xbooleanfalseMirror horizontally.
flip_ybooleanfalseMirror vertically.
sizeVec2the cell or image pixel sizeRendered size in draw units (width, height).

Image:ready

methodsuspends
Image:ready() -> Image

Wait until this asset is fully loaded, then return it for chaining. An in-memory asset returns at once; one still loading (a file read or remote fetch) yields the coroutine until it lands. A load failure raises; format errors on playable assets still surface at use time.

Example
local art = datumhue.args.dirs.art
art:write("blank.png", image:encode_png()):ready()
-- An image read from a file loads in the background.
local copy = art:read("blank.png"):image():ready()
print(copy.width, copy.height) --> 64 64

Image:encode_png

method
Image:encode_png() -> Bytes

Re-encode the pixel buffer as PNG bytes ready for file:write or a save_button's on_save_source.

Image:update

method
Image:update(bytes: Bytes) -> Image

Decode bytes (PNG, JPEG, WebP, etc.) into the existing pixel buffer in place; the texture refreshes on the next frame. The decoded image must match the image's existing dimensions and pixel format — mismatches raise. Returns the same handle for chaining.

Image:to_cubemap

method
Image:to_cubemap() -> CubemapAsset

Build a cubemap for a skybox or environment map from this image, which must be six square faces stacked vertically (height == 6 * width, in +X, -X, +Y, -Y, +Z, -Z order). The original image is unchanged. For prefiltered image-based-lighting maps, load a KTX2 cubemap via bytes:cubemap() instead.

Types 1

ReadyState

enum
ValueDescription
"pending"
"ready"
"failed"

Used by: Shader.state, Bytes.state, DataHandle.state, Image.state, AudioAsset.state, SceneAsset.state, CubemapAsset.state, Font.state and 8 more

datumhue.com

(c) 2026 Shuusei AB. Quote excerpts of this manual, with attribution to DatumHue, in your own documentation, tutorials, course materials, reviews, and other writing or video. Republishing it in whole or in substantial part needs written permission: support@datumhue.com.

Victor Mono is licensed under the SIL Open Font License 1.1
Copyright (c) 2024, Rune Bjørnerås (https://github.com/rubjo)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Try

    ↑↓ selectEnter openTab filter

    Settings

    Theme
    Text
    Print

    Keyboard shortcuts

    / or Ctrl KSearch
    ↑ ↓ EnterPick a result
    TabNext result filter
    j kNext or previous entry
    [ ]Previous or next page
    yCopy a link to the current entry
    ?These shortcuts
    EscClose

    On this page