Sprites.Media.Text
The text screen editor and its model. A text screen is a grid of character cells drawn from one font, each cell coloured by an ink and a paper attribute. Its data is { platform, mode, w, h, first, character, ink, paper, special }, where character, ink, paper and special are four flat lists, one integer to a cell, packed in row order. A character cell holds the glyph index into the font, or undefined for a blank cell. An ink or paper cell holds a colour, or undefined for the default. There are two attribute models: a per cell machine gives each cell its own ink and paper, and an inline machine, wholeCell true, lets an attribute take a whole cell and hold along the row until another overrides it. The editor reuses the shared pixel parts under Sprites.Media.Sprite for the canvas, the pan and zoom, the move, file and history windows and the info window, and the font editor's Characters window for the glyph palette; only the model, the Tools window and the character palette are text specific.
- Sprites.Media.Text.Atlas
- Sprites.Media.Text.Blank
- Sprites.Media.Text.BlankDocument
- Sprites.Media.Text.CellImage
- Sprites.Media.Text.CellImages
- Sprites.Media.Text.CellIndex
- Sprites.Media.Text.CharObjects
- Sprites.Media.Text.Colourise
- Sprites.Media.Text.DecodeGlyph
- Sprites.Media.Text.DefaultInk
- Sprites.Media.Text.DefaultPaper
- Sprites.Media.Text.Editor
- Sprites.Media.Text.EffectiveColour
- Sprites.Media.Text.GridColour
- Sprites.Media.Text.GridLineWidth
- Sprites.Media.Text.NewDocument
- Sprites.Media.Text.OutlineColour
- Sprites.Media.Text.OutlineWidth
- Sprites.Media.Text.PaintChar
- Sprites.Media.Text.PaintInk
- Sprites.Media.Text.PaintPaper
- Sprites.Media.Text.RenderData
- Sprites.Media.Text.ResizeAll
- Sprites.Media.Text.ResizeList
- Sprites.Media.Text.ScreenPixels
- Sprites.Media.Text.SetCell
- Sprites.Media.Text.Space
- Sprites.Media.Text.Summary
- Sprites.Media.Text.View
Sprites.Media.Text.Atlas Array
Sprites.Media.Text.Atlas(font)
The atlas of a font: a list of glyphs, each a flat one bit cell list of the font's cell size, in charset order. Grid.Two.Tile places a glyph by its index, so the atlas is the tile set a character screen draws from. A boot helper over DecodeGlyph, plain data built once as the editor opens.
| Input | Type | Description |
|---|---|---|
font | Object | A charset, { name, w, h, first, glyphs }, each glyph one byte per row. |
Returns a plain list of glyph cell lists, one per character.
Sprites.Media.Text.Blank Undefined
The blank cell of a character list: an absent value, undefined. A blank cell shows the paper colour and no glyph, and a fresh inline screen starts every cell blank.
undefined
Sprites.Media.Text.BlankDocument Object
Sprites.Media.Text.BlankDocument(platform, mode, first, w, h)
A new blank text document: every character, ink, paper and special cell undefined, so an inline screen opens clear and reads the default colours. A boot factory a page hands to the store, plain data rather than a live reactive.
| Input | Type | Description |
|---|---|---|
platform | String | The machine id to stamp on the document. |
mode | String | The mode name to stamp on the document. |
first | Number | The code point of the font's first glyph. |
w | Number | The screen width in characters. |
h | Number | The screen height in characters. |
Returns a plain { platform, mode, w, h, first, character, ink, paper, special } document.
Sprites.Media.Text.CellIndex Value
Sprites.Media.Text.CellIndex(w, x, y)
The flat index of a cell from its column and row, on a screen of a given width: row times width plus column. A composite over Sprites.Maths, for a handler that lays one cell.
| Input | Type | Description |
|---|---|---|
w | Number | The screen width in characters. |
x | Number | The cell column. |
y | Number | The cell row. |
Returns a reactive number, the cell's index in a flat list.
Sprites.Media.Text.CharObjects Array
Sprites.Media.Text.CharObjects(atlas)
A list of plain character objects for the character palette: each glyph of the font as a { pixels } of its decoded one bit cells, in charset order. The font editor's characters window reads this list to draw the glyphs the char tool picks from. A boot helper over the atlas, plain data built once as the editor opens.
| Input | Type | Description |
|---|---|---|
atlas | Array | The font atlas, a list of glyph cell lists. |
Returns a plain list of { pixels } glyph objects.
Sprites.Media.Text.Colourise Value
Sprites.Media.Text.Colourise(colours, indexed, slots)
A colour grid resolved to packed RGBA: each cell mapped through the slots for an indexed machine, or kept as it stands for a free one. A composite over Sprites.Array.Lookup, one node over the whole array, so a slot index becomes its colour while a packed colour passes through, and only the cells whose colour changed pass it on. indexed chooses the path.
| Input | Type | Description |
|---|---|---|
colours | Value | A { w, h, cells } grid of colour values, slot indices or packed colours. |
indexed | Boolean | True to read a cell as a slot index, false to read it as a packed colour. |
slots | Array | The machine's colours as packed 0xRRGGBBAA integers. |
Returns a reactive { w, h, cells } grid of packed colours.
Sprites.Media.Text.DecodeGlyph Array
Sprites.Media.Text.DecodeGlyph(bytes, w, h)
One glyph decoded from a machine charset row list to a flat one bit cell list: for each row a byte, top row first, the leftmost pixel the top bit, a set bit one and a clear bit zero. A boot helper: it reads the raw bytes to build the atlas the screen tiles from.
| Input | Type | Description |
|---|---|---|
bytes | Array | One byte per pixel row, top row first. |
w | Number | The glyph cell width. |
h | Number | The glyph cell height. |
Returns a plain list of w times h one bit cells.
Sprites.Media.Text.DefaultInk Number
The default ink of a fresh screen when the machine names none: white, as a packed RGBA integer, each byte a channel. A machine pack overrides it with its own colour.
0xFFFFFFFF
Sprites.Media.Text.DefaultPaper Number
The default paper of a fresh screen when the machine names none: black, as a packed RGBA integer, each byte a channel. A machine pack overrides it with its own colour.
0x000000FF
Sprites.Media.Text.Editor Void
Sprites.Media.Text.Editor(data, thumb, info, font, charWidth, charHeight, optionalModes, optionalModeName, optionalSlots, wholeCell, optionalDefaultInk, optionalDefaultPaper)
The text screen editor. Builds the screen view on the host, the pan and zoom overlay, the Tools window, the ink and paper palette windows, the file, history and characters panels, and the info window. It edits one screen, laying characters and attributes into the cells. It reuses the shared pixel parts under Sprites.Media.Sprite and the font editor's characters window, so a screen drives them the way a sprite drives the canvas. It builds interface and returns nothing; the doc fields it is given are where the edits land.
| Input | Type | Description |
|---|---|---|
data | Value | The doc's screen data, a two way { platform, mode, w, h, first, character, ink, paper, special }. |
thumb | Value | A value the editor Sets to a fresh PNG data URL of the screen on every edit. |
info | Value | A value the editor Sets to a short mode and size summary on every edit. See Summary. |
font | Object | The character set, { name, w, h, first, glyphs }, the glyphs the screen draws from. |
charWidth | Number | The character cell width in pixels. |
charHeight | Number | The character cell height in pixels. |
optionalModes | Array | The machine's text modes, each { name, pixelAspect, allowedWidths, allowedHeights }. Left out, one free-size mode is used. |
optionalModeName | Value | A two way value of the current mode's name, the doc's stored mode. |
optionalSlots | Array | The machine's colours as packed 0xRRGGBBAA integers, which makes the editor indexed: a cell holds a colour's index. Left out, a cell holds a packed colour. |
wholeCell | Boolean | True when an attribute takes a whole cell and holds along the row, the inline model; false for a per cell attribute. |
optionalDefaultInk | Number | The ink a cell shows with no attribute, a colour index or a packed colour. |
optionalDefaultPaper | Number | The paper a cell shows with no attribute. |
Returns nothing.
Sprites.Media.Text.EffectiveColour Value
Sprites.Media.Text.EffectiveColour(colours, wholeCell, fallback)
The resolved colour of every cell after the attribute model. For an inline machine, wholeCell true, each cell takes the nearest set value to its left, or the fallback; for a per cell machine each cell takes its own value, or the fallback when absent. A composite over Grid.Two.FillAcross, Grid.Two.Default and Sprites.Logic.Select, each one node over the whole array.
| Input | Type | Description |
|---|---|---|
colours | Value | A { w, h, cells } grid of a cell's own colour, or undefined for the default. |
wholeCell | Boolean | True for the inline look-left model, false for the per cell model. |
fallback | Number | The default colour a cell with no attribute shows. |
Returns a reactive { w, h, cells } grid of the resolved colour of every cell.
Sprites.Media.Text.NewDocument Object
Sprites.Media.Text.NewDocument(platform, mode, font, w, h)
A new text document seeded to spaces: every character cell the space glyph, every ink, paper and special cell undefined, so a per cell screen opens on the machine's blank screen at the default colours. A boot factory, plain data for the store.
| Input | Type | Description |
|---|---|---|
platform | String | The machine id to stamp on the document. |
mode | String | The mode name to stamp on the document. |
font | Object | The charset, read for its first code point. |
w | Number | The screen width in characters. |
h | Number | The screen height in characters. |
Returns a plain text document seeded to spaces.
Sprites.Media.Text.PaintChar Value
Sprites.Media.Text.PaintChar(data, w, h, col, row, brush, wholeCell)
The screen with one character cell set to a glyph index, at a column and a row. When wholeCell is true a character and an attribute are exclusive in a cell, so laying a character clears the ink, paper and special of that cell; otherwise only the character changes. A composite over SetCell, Object.With and Sprites.Logic.Select, for the char tool.
| Input | Type | Description |
|---|---|---|
data | Value | The two way screen data. |
w | Number | The screen width in characters. |
h | Number | The screen height in characters. |
col | Number | The cell column. |
row | Number | The cell row. |
brush | Number | The glyph index to lay. |
wholeCell | Boolean | True to clear the cell's attribute as the character is laid, the inline model. |
Returns a reactive screen-data value with the one cell changed.
Sprites.Media.Text.PaintInk Value
Sprites.Media.Text.PaintInk(data, w, h, col, row, brush, wholeCell)
The screen with one cell's ink set to a colour, at a column and a row. When wholeCell is true the cell carries an attribute alone, so the character, paper and special of that cell clear; otherwise only the ink changes. A composite over SetCell, Object.With and Sprites.Logic.Select, for the ink tool.
| Input | Type | Description |
|---|---|---|
data | Value | The two way screen data. |
w | Number | The screen width in characters. |
h | Number | The screen height in characters. |
col | Number | The cell column. |
row | Number | The cell row. |
brush | Number | The ink colour to lay. |
wholeCell | Boolean | True to clear the rest of the cell, the inline model. |
Returns a reactive screen-data value with the one cell changed.
Sprites.Media.Text.PaintPaper Value
Sprites.Media.Text.PaintPaper(data, w, h, col, row, brush, wholeCell)
The screen with one cell's paper set to a colour, at a column and a row. When wholeCell is true the cell carries an attribute alone, so the character, ink and special of that cell clear; otherwise only the paper changes. A composite over SetCell, Object.With and Sprites.Logic.Select, for the paper tool.
| Input | Type | Description |
|---|---|---|
data | Value | The two way screen data. |
w | Number | The screen width in characters. |
h | Number | The screen height in characters. |
col | Number | The cell column. |
row | Number | The cell row. |
brush | Number | The paper colour to lay. |
wholeCell | Boolean | True to clear the rest of the cell, the inline model. |
Returns a reactive screen-data value with the one cell changed.
Sprites.Media.Text.RenderData Value
Sprites.Media.Text.RenderData(data, atlas, charWidth, charHeight, indexed, slots, wholeCell, defaultInk, defaultPaper)
The whole screen of a document drawn to packed RGBA pixels: it reads the four lists and the size, resolves the ink and paper by the attribute model, and tiles the glyphs coloured by them. A composite over EffectiveColour and ScreenPixels, the value the canvas and the thumbnail read. It takes the document, so it serves the live screen and a freshly painted candidate alike.
| Input | Type | Description |
|---|---|---|
data | Value | The screen data. |
atlas | Array | The font atlas, the glyph tiles. |
charWidth | Number | The character cell width in pixels. |
charHeight | Number | The character cell height in pixels. |
indexed | Boolean | True to read a colour cell as a slot index. |
slots | Array | The machine's colours as packed integers. |
wholeCell | Boolean | The attribute model, inline or per cell. |
defaultInk | Number | The default ink. |
defaultPaper | Number | The default paper. |
Returns a reactive { w, h, cells } grid of packed pixels.
Sprites.Media.Text.ResizeAll Value
Sprites.Media.Text.ResizeAll(data, width, height)
The same screen resized to a new width and height in characters, cropping or padding every one of the four lists with the blank cell, undefined. A composite over Grid.Two.Resize and ReadOnly, keeping the platform, mode and first code point.
| Input | Type | Description |
|---|---|---|
data | Value | The two way screen data. |
width | Number | The new screen width in characters. |
height | Number | The new screen height in characters. |
Returns a reactive screen-data value at the new size.
Sprites.Media.Text.ResizeList Value
Sprites.Media.Text.ResizeList(data, key, oldW, oldH, width, height)
One field of the document resized to a new width and height, cropping or padding with the blank cell. A composite over Grid.Two.Resize, shared by the four lists in ResizeAll.
| Input | Type | Description |
|---|---|---|
data | Value | The screen data. |
key | String | The list field, one of character, ink, paper, special. |
oldW | Number | The current screen width. |
oldH | Number | The current screen height. |
width | Number | The new screen width. |
height | Number | The new screen height. |
Returns a reactive list at the new size.
Sprites.Media.Text.ScreenPixels Value
Sprites.Media.Text.ScreenPixels(characters, effectiveInk, effectivePaper, atlas, charWidth, charHeight, indexed, slots)
The whole screen drawn to packed RGBA pixels: every cell's glyph stamped from the atlas, its set pixels the resolved ink and its clear pixels the resolved paper. A composite: it tiles the glyph mask with Grid.Two.Tile, resolves and stretches the ink and paper to pixel size with Colourise and Grid.Two.Stretch, and picks ink or paper per pixel with Grid.Two.Choose.
| Input | Type | Description |
|---|---|---|
characters | Value | A { w, h, cells } grid of glyph indices. |
effectiveInk | Value | A grid of the resolved ink of every cell. |
effectivePaper | Value | A grid of the resolved paper of every cell. |
atlas | Array | The font atlas, the glyph tiles. |
charWidth | Number | The character cell width in pixels. |
charHeight | Number | The character cell height in pixels. |
indexed | Boolean | True to read a colour cell as a slot index. |
slots | Array | The machine's colours as packed integers. |
Returns a reactive { w, h, cells } grid of packed pixels, w times charWidth by h times charHeight.
Sprites.Media.Text.SetCell Value
Sprites.Media.Text.SetCell(cells, w, h, col, row, value)
One flat cell list with a single cell set to a value, at a column and a row on a screen of a width and a height. A composite over Grid.Two.Set, which clips a cell outside the screen, so an out of bounds paint changes nothing.
| Input | Type | Description |
|---|---|---|
cells | Value | The flat cell list. |
w | Number | The screen width in characters. |
h | Number | The screen height in characters. |
col | Number | The cell column. |
row | Number | The cell row. |
value | Number | The value to lay, a colour, a character index, or undefined to clear. |
Returns a reactive cell list with the one cell changed.
Sprites.Media.Text.Space Number
The code point of the space character, the first printable character. A new screen seeds every cell to the space glyph, so it opens on the machine's blank screen.
32
Sprites.Media.Text.Summary String
Sprites.Media.Text.Summary(modeName, w, h)
The meta info summary for a text screen: its mode and screen size as one short string, for the meta record a listing reads. A composite over Sprites.Text.Concat and Sprites.Logic.Select, dropping the mode when there is none.
| Input | Type | Description |
|---|---|---|
modeName | Value | The current mode's name, or absent. |
w | Number | The screen width in characters. |
h | Number | The screen height in characters. |
Returns a reactive summary string, for example Standard · 32×24.
Sprites.Media.Text.CellImage Void
Sprites.Media.Text.CellImage(index, characterCells, inkCells, paperCells, atlas, blankGlyph, charWidth, charHeight, width)
One character cell drawn as an image: the glyph at the cell coloured by the cell's resolved ink and paper, placed as a PNG in the surface with Sprites.Image.Draw.Image. So a whole character is one image element, not a square per pixel. A blank cell, an absent character index, shows the paper alone. A composite over Sprites.Array.Choose and Sprites.Image.Draw.Image.
| Input | Type | Description |
|---|---|---|
index | Number | The cell's flat index. |
characterCells | Value | The glyph index of every cell. |
inkCells | Value | The resolved ink colour of every cell, packed. |
paperCells | Value | The resolved paper colour of every cell, packed. |
atlas | Value | The font atlas, the glyph tiles. |
blankGlyph | Value | The blank glyph an absent character shows. |
charWidth | Number | The character cell width in pixels. |
charHeight | Number | The character cell height in pixels. |
width | Number | The screen width in characters. |
Returns nothing.
Sprites.Media.Text.CellImages Void
Sprites.Media.Text.CellImages(characterCells, inkCells, paperCells, atlas, blankGlyph, charWidth, charHeight, width, count)
The cell images: one image per character cell, built with Repeat over the cell count, so a resize rebuilds the set and each cell follows its own character, ink and paper. A composite over CellImage.
| Input | Type | Description |
|---|---|---|
characterCells | Value | The glyph index of every cell. |
inkCells | Value | The resolved ink colour of every cell. |
paperCells | Value | The resolved paper colour of every cell. |
atlas | Value | The font atlas. |
blankGlyph | Value | The blank glyph an absent character shows. |
charWidth | Number | The character cell width in pixels. |
charHeight | Number | The character cell height in pixels. |
width | Number | The screen width in characters. |
count | Number | The cell count, width times height. |
Returns nothing.
Sprites.Media.Text.GridColour String
The colour of the grid on the character cells, a faint black.
'rgba(0, 0, 0, 0.35)'
Sprites.Media.Text.GridLineWidth Number
The width of the grid lines, in world units, where one unit is one pixel of a character. The grid falls on the character cells, not the pixels.
0.4
Sprites.Media.Text.OutlineColour String
The colour of the outline around the whole screen, a dark green.
'#020d02'
Sprites.Media.Text.OutlineWidth Number
The width of the outline around the whole screen, in world units.
0.7
Sprites.Media.Text.View Void
Sprites.Media.Text.View(characterCells, inkCells, paperCells, atlas, blankGlyph, charWidth, charHeight, width, height, pan, show)
The screen view: a checkerboard backdrop, then a Vector over it with one image per character cell, a grid on the character cells, and a dark outline around the screen. One world unit is one pixel of a character, so a cell spans charWidth by charHeight units. A composite over CellImages, Sprites.Image.Draw.Grid and Sprites.Image.Draw.Rectangle.
| Input | Type | Description |
|---|---|---|
characterCells | Value | The glyph index of every cell. |
inkCells | Value | The resolved ink colour of every cell. |
paperCells | Value | The resolved paper colour of every cell. |
atlas | Value | The font atlas. |
blankGlyph | Value | The blank glyph an absent character shows. |
charWidth | Number | The character cell width in pixels. |
charHeight | Number | The character cell height in pixels. |
width | Number | The screen width in characters. |
height | Number | The screen height in characters. |
pan | Value | The view centre point, { x, y }. |
show | Value | The units across the view. |
Returns nothing.