DatumHuePlatform v0.0.24datumhue.com
Contents

handle32 methodsUI apps only

Picture

A reusable, canvas-agnostic command list created by datumhue.image.picture. Record drawing with the methods below, then replay it onto an Image with canvas:apply(picture) — the whole picture lands in one atomic pass. Record once and apply every frame; rebuild dynamic content with reset.

Obtained from
datumhue.image.picture
Accepted by
Image:apply

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 })
local pic = datumhue.image.picture()

Methods 32

Picture:set

method
Picture:set(x: number, y: number, color: Color) -> Picture

Set a pixel. No-op if out of bounds when applied.

Picture:fill

method
Picture:fill(color: Color) -> Picture

Fill the entire buffer with a color.

Picture:clear

method
Picture:clear() -> Picture

Clear to transparent black (all zeros). Also resets the clip rectangle.

Picture:line

method
Picture:line(x0: number, y0: number, x1: number, y1: number, color: Color) -> Picture

Draw a line.

Picture:circ

method
Picture:circ(x: number, y: number, r: number, color: Color) -> Picture

Draw a circle outline.

Picture:circfill

method
Picture:circfill(x: number, y: number, r: number, color: Color) -> Picture

Draw a filled circle.

Picture:oval

method
Picture:oval(x0: number, y0: number, x1: number, y1: number, color: Color) -> Picture

Draw an oval outline (bounding box).

Picture:ovalfill

method
Picture:ovalfill(x0: number, y0: number, x1: number, y1: number, color: Color) -> Picture

Draw a filled oval (bounding box).

Picture:rect

method
Picture:rect(x0: number, y0: number, x1: number, y1: number, color: Color) -> Picture

Draw a rectangle outline.

Picture:rectfill

method
Picture:rectfill(x0: number, y0: number, x1: number, y1: number, color: Color) -> Picture

Draw a filled rectangle between two corners (inclusive, in either order). Clips to bounds.

Picture:rrect

method
Picture:rrect(x: number, y: number, w: number, h: number, r: number, color: Color) -> Picture

Draw a rounded-rectangle outline.

Picture:rrectfill

method
Picture:rrectfill(x: number, y: number, w: number, h: number, r: number, color: Color) -> Picture

Draw a filled rounded rectangle.

Picture:tri

method
Picture:tri(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, color: Color) -> Picture

Draw a triangle outline.

Picture:trifill

method
Picture:trifill(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, color: Color) -> Picture

Draw a filled triangle.

Picture:polygon

method
Picture:polygon(points: number[], color: Color) -> Picture

Draw a polygon outline from a flat point array {x1,y1, x2,y2, ...}.

Picture:polygonfill

method
Picture:polygonfill(points: number[], color: Color) -> Picture

Draw a filled polygon from a flat point array {x1,y1, x2,y2, ...}.

Example
-- Points are flat x, y pairs.
pic:polygonfill({ 32, 4, 60, 56, 4, 56 }, color("#a7c080"))
image:apply(pic)

Picture:arc

method
Picture:arc(cx: number, cy: number, r: number, start_angle: number, end_angle: number, color: Color) -> Picture

Draw an arc outline. Angles in radians.

Picture:arcfill

method
Picture:arcfill(cx: number, cy: number, r: number, start_angle: number, end_angle: number, color: Color) -> Picture

Draw a filled arc (pie slice). Angles in radians.

Example
-- Y points down, so a growing angle turns clockwise on screen.
pic:arcfill(32, 32, 24, 0, math.pi / 2, color("#dbbc7f"))
image:apply(pic)

Picture:floodfill

method
Picture:floodfill(x: number, y: number, color: Color) -> Picture

Replace all connected same-color pixels from (x,y). Bypasses camera and clip.

Picture:blur

method
Picture:blur(x: number, y: number, w: number, h: number, radius: number) -> Picture

Box blur over a rectangular region.

Picture:print

method
Picture:print(text: string, x: number, y: number, color: Color) -> integer

Draw text. Returns the x position after the last character (sized by the current font). Supports newlines and the active font, clip, and camera.

Example
local x = pic:print("HP", 2, 2, color("#e67e80"))
print(x) --> 18
pic:print("42", x + 4, 2, color("#a7c080"))
image:apply(pic)

Picture:measure_text

method
Picture:measure_text(text: string) -> image.TextSize

Size of the text for the picture's current font. Bitmap fonts have a fixed line height (the cell height), so height depends only on the number of lines.

Example
local size = pic:measure_text("Hello\nworld")
print(size.width, size.height) --> 40 26

returns image.TextSize record 2 keys

KeyTypeDescription
widthintegerThe widest line's advance, in pixels.
heightintegerLine count times the font's cell height, in pixels.

Picture:wrap

method
Picture:wrap(text: string, max_width: number) -> string[]

Word-wrap the text to fit max_width pixels for the picture's current font, breaking at spaces (a word longer than the width hard-splits) and honoring embedded newlines. Print the returned lines one per row; every line's measured width fits within max_width.

Example
local lines = pic:wrap("one two three four", 64)
print(table.concat(lines, "|")) --> one two|three|four
for i, line in ipairs(lines) do
    pic:print(line, 2, 2 + (i - 1) * 13, color("#7fbbb3"))
end
image:apply(pic)

Picture:push

method
Picture:push() -> Picture

Save the current camera offset and clip rectangle.

Picture:pop

method
Picture:pop() -> Picture

Restore the camera offset and clip rectangle. No-op if the stack is empty.

Picture:translate

method
Picture:translate(dx: number, dy: number) -> Picture

Shift the drawing origin by (dx, dy). Additive with the current camera offset.

Picture:camera

method
Picture:camera(x?: number, y?: number) -> Picture

Set the camera offset absolutely. Call with no arguments to reset to (0, 0).

Picture:clip

method
Picture:clip(x?: number, y?: number, w?: number, h?: number) -> Picture

Set the clipping rectangle in screen space. Call with no arguments to reset.

Example
pic:clip(16, 16, 32, 32)
pic:circfill(32, 32, 28, color("#d699b6"))
-- No rectangle: draw anywhere again.
pic:clip()
pic:circ(32, 32, 30, color("#d699b6"))
image:apply(pic)

Picture:fillp

method
Picture:fillp(pattern?: number) -> Picture

Set a 4x4 fill-pattern bitmask (16-bit). Call with no arguments to reset to solid.

Example
-- A set bit leaves its pixel unfilled. Bit 0 is the top-left pixel
-- of each 4x4 tile, and the bits count along its rows.
pic:fillp(0x5a5a)
pic:rectfill(0, 0, 63, 31, color("#83c092"))
-- No pattern: solid again.
pic:fillp()
pic:rectfill(0, 32, 63, 63, color("#83c092"))
image:apply(pic)

Picture:set_font

method
Picture:set_font(atlas?: Atlas, char_w?: number) -> Picture

Set a custom bitmap font from an Atlas (cell index = ASCII code - 32). char_w overrides the per-glyph advance, defaulting to the atlas cell width. Pass nil for the atlas to reset to the built-in font.

Picture:blit

method
Picture:blit(src: Image, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, blend_mode?: image.BlendMode) -> Picture

Copy pixels from another Image (or the target itself) onto the canvas at apply time. blend_mode defaults to copy.

Example
local stamp = datumhue.image.new({ width = 8, height = 8 })
local dot = datumhue.image.picture()
stamp:apply(dot:circfill(4, 4, 3, color("#e69875")))
-- Copy the stamp's 8x8 pixels to (20, 20), blending by alpha.
pic:blit(stamp, 0, 0, 8, 8, 20, 20, "alpha")
image:apply(pic)

Picture:reset

method
Picture:reset() -> Picture

Empty the command list so the picture can be rebuilt. Does not change the current font.

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