lib-svg · crate
kinogaki-svg
Kinogaki SVG reads SVG documents the way resvg (and so, closely, a browser) does, converts them into a render tree with every property resolved, and draws them with an exact-coverage anti-aliased rasterizer.
- Repository
- lib-svg (kinogaki/lib-svg)
- Folder
libs/lib-svg/crates/svg- Source
- 49 files, 16,916 lines
- Tests
- 6 files, 597 lines
What it is
Kinogaki SVG reads SVG documents the way resvg (and so, closely, a browser) does, converts them into a render tree with every property resolved, and draws them with an exact-coverage anti-aliased rasterizer. IconCache draws small icons for UI toolkits, parsed once and rasterized per size.
Depends on
None.
Third-party
None.
Used by
| Crate | Repository | As | What it is |
|---|---|---|---|
kinogaki-svg-tools | lib-svg | normal | Shared pieces of the conformance and benchmark tools: rendering a document with kinogaki-svg and with resvg into premultiplied RGBA8, comparing bitmaps, and writing side-by-side sheets. |
kinogaki-ui | lib-ui | normal | Kinogaki UI: the immediate-mode UI framework Kinogaki applications are built on. |
Modules
errorErrors and the limits that bound parsing and rendering.186 linesfilterFilters: the model a group'sfilterconverts into, and (inrender) how each primitive draws.235 linesfilter::blur(private)Blurs, drop shadows and morphology.257 linesfilter::light(private)feTurbulence and the lighting primitives.430 linesfilter::ops(private)The filter primitives that combine and recolor: feBlend, feComposite (the Porter-Duff operators and arithmetic), feMerge (as blends), feOffset (whole device pixels, as resvg shifts), feTile, feColorMatrix and feComponentTransfer (on unpremultiplied values in ...307 linesfilter::render(private)Running a group's filters.399 linesgeomGeometry shared by every stage: points, affine transforms, rectangles, paths, flattening and stroking.315 linesgeom::flatten(private)Flattening paths into polylines: curves are cut into straight pieces short enough that none strays more thanFLATNESSdevice pixels from the curve.221 linesgeom::path(private)Paths: move, line, cubic and close verbs over points, the form every SVG shape becomes.415 linesgeom::stroke(private)Stroking flattened paths into outlines.477 linessceneThe render tree a document converts into: groups, shapes and images with every property resolved — no inheritance, no CSS, nouseorsymbolleft.382 linestextWhere SVG text gets its glyphs.153 linesvaluesParsers for SVG's attribute microsyntaxes: numbers (an exponent never swallows theeofem), lengths, angles, transform lists, viewBoxes, preserveAspectRatio, CSS colors, path data and point lists.363 linesvalues::color(private)CSS colors:#rgb,#rgba,#rrggbb,#rrggbbaa; the 148 named colors andtransparent;rgb()/rgba()andhsl()/hsla()in the legacy comma syntax and CSS Color 4's space syntax with/ alpha; and CSS Color 4'shwb(),lab(),lch()...584 linesvalues::named_colors(private)The 148 CSS named colors, sorted for binary search.154 linesvalues::path_data(private)SVG path data and point lists.213 linesvalues::scanner(private)A byte cursor over an attribute value, with the number grammar SVG shares.162 linesconvert(private)Converting the document tree into a render tree, as usvg does: elements that are not displayed, fail their conditions or have a singular transform are skipped; each container or shape becomes a group only when it needs one (a transform, opacity, blend mode ...732 linesconvert::clip(private)Clip paths and masks.161 linesconvert::filters(private)Filters: thefilterproperty and filter elements.490 linesconvert::filters::primitives(private)Filter primitives: each fe* element's parameters (flood, color matrix, component transfer, convolution, lighting, image and the rest), with usvg's defaults and the transparent flood an invalid primitive becomes.429 linesconvert::image(private)Theimageelement.288 linesconvert::markers(private)Markers and paint order.384 linesconvert::paint(private)Shapes' fills and strokes.253 linesconvert::servers(private)Gradients and patterns as paint servers, converted once per element.332 linesconvert::shapes(private)Basic shapes into paths, resolving their lengths as usvg does: a rect needs a positive size, rx and ry stand in for each other and are clamped to half the size, circles and ellipses need positive radii, polylines two points.88 linesconvert::structure(private)use,symbol, nestedsvgandswitch.288 linesconvert::text(private)Laying text out and turning it into shapes.534 linesconvert::text::bidi(private)Bidirectional text: which way each run of a chunk reads.288 linesconvert::text::path(private)Text along a path.300 linesconvert::text::read(private)Reading<text>into chunks and spans.536 linesconvert::text::shape(private)Shaping a chunk's characters into glyph clusters, as usvg shapes a chunk: its drawn characters split into bidi runs, and the whole chunk is shaped with the first span's face, run by run, glyphs in visual order; a glyph the face lacks is taken from the ...299 linescss(private)Style sheets, selectors and declarations.529 linesfontsFontFiles: aGlyphSourceover font files, the system's by default (thefontsfeature).704 linesicon(private)Icons: documents parsed once and rasterized per size.102 linesinflate(private)Gzip and DEFLATE decoding (RFC 1952 and RFC 1951), for compressed SVG (.svgz) images.262 linesmask(private)Coverage masks of filled outlines: the anti-aliased alpha of a path over a small pixel grid, for glyph and icon atlases that tint the mask themselves.95 linesraster(private)The coverage rasterizer.615 linesrender(private)Drawing a picture's render tree.562 linesrender::bounds(private)Conservative device bounds of render-tree content, so a group's layer covers only the pixels its content can touch rather than the whole canvas.55 linesrender::canvas(private)Layers of premultiplied color and how they composite.222 linesrender::shader(private)Painting coverage with a brush.272 linestree(private)The SVG document tree: the XML tree with only what SVG draws from.175 linestree::build(private)Building the SVG tree from XML, with the cascade.678 linestree::build::text(private)Text content in the tree.223 linestree::names(private)The element and attribute names the document tree keeps, generated from usvg's name lists and sorted so a name is found by binary search.346 linestree::names::tables(private)The name tables, sorted by name for binary search, and the per-attribute flags and initial values indexed byAttr.507 linesxml(private)An XML reader for SVG documents.771 lines
Public types and traits
At the crate root
Structs ErrorIconIconCacheIconKeyLimitsMaskRasterizerOptionsPicturePixmapPositionRenderOptions
Enums ErrorKindImageFormat
Type aliases ImageDecoder
By module: 61 public types and traits in 16 modules
convert Options
convert::image ImageDecoderImageFormat
error ErrorErrorKindLimitsPosition
filter ColorMatrixCompositeOpEdgeModeFilterInputKindLightPrimitiveTransferFn
fonts FontFiles
geom BoundsPointRectTransform
geom::flatten Polylines
geom::path PathSegmentVerb
geom::stroke CapJoinStrokeStyle
icon IconIconCacheIconKey
mask MaskRasterizer
render RenderOptions
scene BlendBrushClipPathFillGradientGradientKindGroupImageMaskNodePaintPatternPictureRasterShapeSpreadStopStroke
text FaceMetricsFaceQueryFontStyleGlyphRecordGlyphSource
values AlignAspectRatioLengthUnit
values::color Rgba
Besides these, 12 public functions at module level.
