trunic

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2025 License: MIT Imports: 14 Imported by: 0

README

trunic

trunic is a Go module for producing images of text written in the writing system from the game Tunic.

The rune line data and bitmask system were taken from Arayan Pingle's excellent in-browser translator tool.

Documentation

Overview

Package trunic provides image-related functionality for the Trunic writing system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConsonant

func IsConsonant(ph string) bool

IsConsonant returns true if ph is a consonant.

func IsLetter

func IsLetter(ph string) bool

IsLetter returns true if ph is a consonant or a vowel.

func IsSymbol

func IsSymbol(ph string) bool

IsSymbol returns true if ph is a symbol, such as punctuation or a reversing circle.

func IsVowel

func IsVowel(ph string) bool

IsVowel returns true if ph is a vowel.

func Normalize

func Normalize(text string) string

Normalize returns a copy of text with all unsupported characters removed.

func Runes

func Runes(text string) iter.Seq[[]string]

Runes returns a sequence of rune sections suitable for passing to Renderer.AppendRune.

The yielded slice should not be retained from one iteration to the next.

Types

type Renderer

type Renderer struct {
	Color      color.Color // Default: color.Black
	TextHeight float64     // Default: 72
	Thickness  float64     // Default: 5
	// contains filtered or unexported fields
}

Renderer draws Trunic text to an image.

func (*Renderer) Append

func (r *Renderer) Append(text string)

Append is a high-level function that appends text to the Renderer's internal buffer. The text is expected to be a sequence of words written in IPA characters. Leading and trailing whitespace is trimmed, all unrecognized characters are stripped via Normalize, the characters in words are parsed into pairs via Runes, and these are then appended one-by-one via [AppendRune].

If there is already anything in the buffer when Append is called, a space is inserted first.

If the length of the text to be inserted after normalization is zero, this method is a no-op.

func (*Renderer) AppendRune

func (r *Renderer) AppendRune(ph ...string)

AppendRune is a low-level method that appends pieces of runes to the Renderer's internal buffer. Each call appends a single rune which is drawn by overlapping all of the symbols corresponding to the strings passed. Generally speaking, this is a single vowel and a single consonant, possibly including a reversing circle.

func (*Renderer) Bounds

func (r *Renderer) Bounds() image.Rectangle

Bounds returns the minimum bounding box that will contain the result of rendering the Renderer's current state with the top-left corner at (0, 0). Note that this is a minimum that does not take into account the thickness of the lines. Default thickness usually requires about 10 pixels of padding or so to fit the result without anything getting clipped.

func (*Renderer) DrawTo

func (r *Renderer) DrawTo(dst draw.Image, x, y float64)

DrawTo draws the Renderer's current state to dst with the top-left corner at (x, y). The coordinates are relative to (0, 0), not to the top-left of dst's bounding box.

func (*Renderer) Size

func (r *Renderer) Size() image.Point

Size returns the size of the image. This is equivalent to

r.Bounds().Size()

Directories

Path Synopsis
cmd
trunic command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL