A decoder for the canvas binary format of spec/09 §4 and §5, written against the record
layouts the specification states — not against the encoder — so that
decode(encode(x)) is a genuine round trip (D-36).
decode/1 returns the records of a stream in order:
{:path, [{x, y}]},{:path_cubic, [command]}withVisualize.IR.Pathcommands, and{:path32, [{x, y}]},{:path_cubic32, [command]}for the f32 records (D-73), and{:cubic_run, {x0, y0}, [{x1, y1, x2, y2, x, y}]}for the cubic run (D-74){:circles, [{cx, cy, r}]},{:rects, [{x, y, w, h}]}{:style, %{fill:, stroke:, stroke_width:, opacity:}}(nilfor an absent field), withfill_paint:andstroke_paint:indexes under bits 5 and 6{:effect, :shadow, radius, {dx, dy}, {r, g, b, a}}and{:effect, :blur, radius}(§4.3.14){:motion, json}and:motion_end, a motion span and its end (§4.3.15, §4.3.16, #653)- the version 3 record
{:paint_state, %{fill_alpha:, stroke_alpha:, cap:, join:, dash:}},nilfor an absent field (§4.3.17, #675) - the version 2 records
{:version, v},{:paint, index, %{type:, geometry: [f32], stops: [{at, {r, g, b, a}}]}}and{:box, {x, y, w, h}}(spec/09 §4.3.11–4.3.13) {:transform, :translate, {tx, ty}},{:transform, :translate_scale, {tx, ty, sx, sy}},{:transform, :matrix, {a, b, c, d, e, f}}the version 4 records
{:clip, :inside | :outside}and{:blend, word}, the word the CSSmix-blend-modeone (§4.3.18, §4.3.19, #788):save,:restore,:fill,:stroke{:incremental, mode, dx, dy, {x, y, w, h}, [{{x, y, w, h}, records}]}and{:full_redraw, viewport, records}for the0x60records ofVisualize.Backend.CanvasIncremental
An unknown opcode or a truncated record raises, since either is an encoder bug.
Summary
Functions
The records of a stream, in order (spec/09 §4.1, #270). Raises on an unknown opcode or a truncated record, since either is an encoder bug — or a decoder that has drifted from the encoder, which is what a consumer's test of its own streams is for.
The one path record of a stream as a Visualize.IR.Path.
Functions
The records of a stream, in order (spec/09 §4.1, #270). Raises on an unknown opcode or a truncated record, since either is an encoder bug — or a decoder that has drifted from the encoder, which is what a consumer's test of its own streams is for.
@spec decode_path(binary()) :: Visualize.IR.Path.t()
The one path record of a stream as a Visualize.IR.Path.