Documentation
¶
Overview ¶
Package lowlevel provides a low-level decoder for the IconVG file format.
IconVG is specified at https://github.com/google/iconvg/blob/main/spec/iconvg-spec.md
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultPalette = Palette{ color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, color.RGBA{0x00, 0x00, 0x00, 0xff}, }
DefaultPalette is the default Palette. Its values should not be modified.
DefaultViewBox is the default ViewBox. Its values should not be modified.
Functions ¶
func Decode ¶
func Decode(dst Destination, src []byte, opts *DecodeOptions) error
Decode decodes an IconVG graphic.
opts may be nil, which means to use the default options.
func Disassemble ¶
Disassemble writes src's disassembly to w.
See https://github.com/google/iconvg/blob/main/spec/iconvg-spec.md#example (look for the text "annotated disassembly") or test/data/*.ivg.disassembly for example output.
Types ¶
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
Color is an IconVG color, whose RGBA values can depend on context. Some Colors are direct RGBA values. Other Colors are indirect, referring to an index of the custom palette, a color register of the decoder virtual machine, or a blend of two other Colors.
See the "Colors" section in the specification for details.
func BlendColor ¶
BlendColor returns an indirect Color that blends two other Colors. Those two other Colors must both be encodable as a 1 byte color.
To blend a Color that is not encodable as a 1 byte color, first load that Color into a CREG color register, then call CRegColor to produce a Color that is encodable as a 1 byte color. See testdata/favicon.ivg for an example.
See the "Colors" section in the specification for details.
TODO: update this for FFV1.
func CRegColor ¶
CRegColor returns an indirect Color referring to a color register of the decoder virtual machine.
func PaletteIndexColor ¶
PaletteIndexColor returns an indirect Color referring to an index of the custom palette.
type DecodeOptions ¶
type DecodeOptions struct { // Palette is an optional 64 color palette. If one isn't provided, the // IconVG graphic's suggested palette will be used. Palette *Palette }
DecodeOptions are the optional parameters to the Decode function.
type Destination ¶
type Destination interface { Reset(m Metadata) // QueryLevelOfDetail returns whether the height-in-pixels H satisfies // ((lod0 <= H) && (H < lod1)). QueryLevelOfDetail(lod0, lod1 float32) bool ClosePathMoveTo(x, y float32) LineTo(x, y float32) QuadTo(x1, y1, x, y float32) CubeTo(x1, y1, x2, y2, x, y float32) Ellipse(nQuarters uint32, x1, y1, x2, y2, x, y float32) Parallelogram(x1, y1, x2, y2, x, y float32) ClosePathFill() // TODO. }
Destination handles the actions decoded from an IconVG graphic's byte code.
When passed to Decode, the first method called (if any) will be Reset. No methods will be called at all if an error is encountered in the encoded form before the metadata is fully decoded.
type Metadata ¶
type Metadata struct { ViewBox Rectangle // Palette is a 64 color palette. When encoding, it is the suggested // palette to place within the IconVG graphic. When decoding, it is either // the optional palette passed to Decode, or if no optional palette was // given, the suggested palette within the IconVG graphic. Palette Palette }
Metadata is an IconVG's metadata.
func DecodeMetadata ¶
DecodeMetadata decodes only the metadata in an IconVG graphic.
type Rectangle ¶
Rectangle is defined by its minimum and maximum coordinates.
func (*Rectangle) AspectRatio ¶
AspectRatio returns the Rectangle's aspect ratio. An IconVG graphic is scalable; these dimensions do not necessarily map 1:1 to pixels.