/tg/ Station 13 - Modules - Types — Var Details - Proc Details

graffiti

A graffiti piece being painted: one view of up to GRAFFITI_MAX_LAYERS layers, in colours that may be translucent.

The layers are alike. Each has its own name, glow and id ("l1", "l2", ...), the bottom one included, so none of the hair's rules for its base layer apply. Layer changes are custom sprite history steps, so undo covers them. The piece keeps no palette: it takes its colours from its paint when it saves, at most GRAFFITI_MAX_COLORS of them. Every change counts the pixels of each colour, so checking a stroke's colour never reads the canvas.

Vars

color_countsPixel value -> how many pixels of all the layers hold it, for each value the paint uses; transparent pixels aren't counted. In the order the layers first use them when counted afresh, then as new values come.
draw_mask_bitsThe draw mask as a compact stroke mask's slots, a bit for each pixel that takes paint, as a poster's canvas has it, or null. A stroke is cut down to it as its points are read (stroke_mask_slots()), so none needs checking.
layer_record_cacheLayer id -> its layer_records() record, kept until the layer's pixels or glow change, so a surface session's composite reads only the layers painted since the last one. Studio sessions never composite, so never fill it.
next_layer_idThe number the next layer's id takes. Ids are never reused in a draft, so the window's choice of layer survives undo.

Procs

NewOpens a piece with a layer for each of its own, or a blank one-tile piece.
add_colorChecks a colour the player wants to paint with. The piece keeps no palette, so this only says whether the colour can be painted now.
add_layerAdds a blank layer on top, as an undoable step.
all_points_allowedA stroke read from a compact mask cut down to the draw mask lands only where paint may go.
apply_stepAlso applies the layer swap move_layer() records. A swap undoes itself, so both directions swap.
count_colorsCounts every layer's pixels of each colour afresh, in the order the layers first use the colours: layer 1 row by row from the top, then each layer above it.
count_pointsCounts the pixels a stroke, fill, erasure or placement changed: each point keeps the value it replaced. The other steps change whole layers, which count_colors() counts.
has_paint_right_halfReturns whether any layer has paint in the right tile's columns, which narrowing the canvas would lose.
layer_countReturns how many layers the piece has.
layer_editedReturns which views of a layer have paint. Every layer keeps its own map, the bottom one included, so the map moves with its layer. edited_directions only serves the base constructor's blank layer, which New() replaces.
layer_entriesReturns the layers as the editor's window lists them.
layer_entryBuilds a blank layer under the next id, not yet in the piece.
layer_glowReturns whether a layer's paint glows.
layer_recordsReturns the layers decoded for graffiti_flatten_records(), read straight from their frames. They flatten to the art graffiti_flatten() makes of the piece serialize_piece() returns, without encoding the layers and decoding them again. Each layer's record is kept until it changes (layer_record_cache).
layer_viewReturns a layer's one view.
layers_changedAlso counts the colours afresh: a layer came or went with its paint.
move_layerSwaps a layer with the one above or below it, as an undoable step.
pixels_changedAlso counts the colours afresh when any view may have changed, as opening a piece, a width change or a layer swap leave them. A change to one view is a step, which transact() or reverse_transact() counts.
prepare_selection_placementAlso writes the colours a placement lands as their canonical pixels, and refuses a placement that would take the paint past GRAFFITI_MAX_COLORS colours, and, in a surface session, one that adds paint. A stroke brings one colour, but a placement can bring several, so each one it lands counts, whatever it paints over.
remove_layerRemoves a layer, paint and all, as an undoable step.
rename_layerRenames a layer as an undoable step, cleaning the name as a saved piece's layer names are.
reverse_transactAlso counts what reversing a step changed.
sanitize_transactionAlso writes a stroke's colour as the nine-character pixel it paints, in graffiti_color()'s form, so every pixel value stays canonical.
serialize_pieceReturns the piece as the library saves it: every layer, painted or not, each grid indexing a palette of the colours the paint uses, in the order the layers first use them: layer 1 row by row from the top, then each layer above it. A two-tile canvas with nothing painted on its right tile saves one tile wide, though the canvas keeps its width.
set_layer_glowTurns a layer's glow on or off as an undoable step.
set_widthMakes the canvas one or two tiles wide where it stands: columns come and go on the right, so paint keeps its place and every layer keeps its id. Paint in columns that go is lost, which has_paint_right_half() lets the caller ask about first. History can't span two widths, so it starts over.
stroke_layer_matchesWhether a stroke names the layer it paints by its id as well as its place. The bottom layer is named like any other, so a stroke meant for a layer that undo just moved can't land on another.
stroke_mask_slotsReturns draw_mask_bits, which a stroke's compact mask is cut down to as it is read: a check of each point costs about as much as the rest of the stroke (measured). A canvas with a draw mask holds no paint outside it, so an eraser loses nothing by it.
transactFills by setting each pixel to the fill colour, as the pencil paints: translucent paint blends only when the layers merge. Anything else is applied as a custom sprite workspace applies it. Either way, what changed is counted.
used_colorsReturns the colours the paint uses, read from color_counts. Unlike a drawing's, translucent colours keep their alpha, as graffiti_color() writes them.
validate_palette_colorTakes any brush colour that shows, until the paint uses GRAFFITI_MAX_COLORS colours: then only those.

Var Details

color_counts

Pixel value -> how many pixels of all the layers hold it, for each value the paint uses; transparent pixels aren't counted. In the order the layers first use them when counted afresh, then as new values come.

draw_mask_bits

The draw mask as a compact stroke mask's slots, a bit for each pixel that takes paint, as a poster's canvas has it, or null. A stroke is cut down to it as its points are read (stroke_mask_slots()), so none needs checking.

layer_record_cache

Layer id -> its layer_records() record, kept until the layer's pixels or glow change, so a surface session's composite reads only the layers painted since the last one. Studio sessions never composite, so never fill it.

next_layer_id

The number the next layer's id takes. Ids are never reused in a draft, so the window's choice of layer survives undo.

Proc Details

New

Opens a piece with a layer for each of its own, or a blank one-tile piece.

Arguments:

add_color

Checks a colour the player wants to paint with. The piece keeps no palette, so this only says whether the colour can be painted now.

Arguments:

Returns:

add_layer

Adds a blank layer on top, as an undoable step.

Returns:

all_points_allowed

A stroke read from a compact mask cut down to the draw mask lands only where paint may go.

apply_step

Also applies the layer swap move_layer() records. A swap undoes itself, so both directions swap.

Arguments:

Returns:

count_colors

Counts every layer's pixels of each colour afresh, in the order the layers first use the colours: layer 1 row by row from the top, then each layer above it.

count_points

Counts the pixels a stroke, fill, erasure or placement changed: each point keeps the value it replaced. The other steps change whole layers, which count_colors() counts.

Arguments:

has_paint_right_half

Returns whether any layer has paint in the right tile's columns, which narrowing the canvas would lose.

Returns:

layer_count

Returns how many layers the piece has.

Returns:

layer_edited

Returns which views of a layer have paint. Every layer keeps its own map, the bottom one included, so the map moves with its layer. edited_directions only serves the base constructor's blank layer, which New() replaces.

Arguments:

Returns:

layer_entries

Returns the layers as the editor's window lists them.

Returns:

layer_entry

Builds a blank layer under the next id, not yet in the piece.

Arguments:

Returns:

layer_glow

Returns whether a layer's paint glows.

Arguments:

Returns:

layer_records

Returns the layers decoded for graffiti_flatten_records(), read straight from their frames. They flatten to the art graffiti_flatten() makes of the piece serialize_piece() returns, without encoding the layers and decoding them again. Each layer's record is kept until it changes (layer_record_cache).

Returns:

layer_view

Returns a layer's one view.

Arguments:

Returns:

layers_changed

Also counts the colours afresh: a layer came or went with its paint.

move_layer

Swaps a layer with the one above or below it, as an undoable step.

Arguments:

Returns:

pixels_changed

Also counts the colours afresh when any view may have changed, as opening a piece, a width change or a layer swap leave them. A change to one view is a step, which transact() or reverse_transact() counts.

Arguments:

prepare_selection_placement

Also writes the colours a placement lands as their canonical pixels, and refuses a placement that would take the paint past GRAFFITI_MAX_COLORS colours, and, in a surface session, one that adds paint. A stroke brings one colour, but a placement can bring several, so each one it lands counts, whatever it paints over.

A surface is painted by hand, so its pieces show the staged reveal's work rather than prepared art. A placement there may move, turn, mirror or cut the session's own paint, which never lands more of a colour than it lifts or covers; a paste does, and is refused with a notice.

Arguments:

Returns:

remove_layer

Removes a layer, paint and all, as an undoable step.

Arguments:

Returns:

rename_layer

Renames a layer as an undoable step, cleaning the name as a saved piece's layer names are.

Arguments:

Returns:

reverse_transact

Also counts what reversing a step changed.

Arguments:

sanitize_transaction

Also writes a stroke's colour as the nine-character pixel it paints, in graffiti_color()'s form, so every pixel value stays canonical.

Arguments:

Returns:

serialize_piece

Returns the piece as the library saves it: every layer, painted or not, each grid indexing a palette of the colours the paint uses, in the order the layers first use them: layer 1 row by row from the top, then each layer above it. A two-tile canvas with nothing painted on its right tile saves one tile wide, though the canvas keeps its width.

Arguments:

Returns:

set_layer_glow

Turns a layer's glow on or off as an undoable step.

Arguments:

Returns:

set_width

Makes the canvas one or two tiles wide where it stands: columns come and go on the right, so paint keeps its place and every layer keeps its id. Paint in columns that go is lost, which has_paint_right_half() lets the caller ask about first. History can't span two widths, so it starts over.

Arguments:

Returns:

stroke_layer_matches

Whether a stroke names the layer it paints by its id as well as its place. The bottom layer is named like any other, so a stroke meant for a layer that undo just moved can't land on another.

Arguments:

Returns:

stroke_mask_slots

Returns draw_mask_bits, which a stroke's compact mask is cut down to as it is read: a check of each point costs about as much as the rest of the stroke (measured). A canvas with a draw mask holds no paint outside it, so an eraser loses nothing by it.

Returns:

transact

Fills by setting each pixel to the fill colour, as the pencil paints: translucent paint blends only when the layers merge. Anything else is applied as a custom sprite workspace applies it. Either way, what changed is counted.

Arguments:

used_colors

Returns the colours the paint uses, read from color_counts. Unlike a drawing's, translucent colours keep their alpha, as graffiti_color() writes them.

Returns:

validate_palette_color

Takes any brush colour that shows, until the paint uses GRAFFITI_MAX_COLORS colours: then only those.

Arguments:

Returns: