nano-ui
Safe HaskellNone
LanguageGHC2024

NanoUI.Svg

Description

SVG documents for icons: a parser for the static subset icon sets use and an anti-aliased rasterizer.

Supported: svg (with viewBox, width, height), g, path, rect, circle, ellipse, line, polyline and polygon; the presentation attributes fill, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-miterlimit, fill-rule, opacity, fill-opacity and stroke-opacity, also inside style; transform; and colours as names, #rgb, #rrggbb, rgb() and currentColor. Gradients, patterns, text, masks, clipping, filters and use are ignored.

Synopsis

Documentation

data Svg Source #

A parsed SVG document.

Instances

Instances details
Eq Svg Source #

Documents are equal when their sources hash the same.

Instance details

Defined in NanoUI.Svg

Methods

(==) :: Svg -> Svg -> Bool #

(/=) :: Svg -> Svg -> Bool #

Show Svg Source # 
Instance details

Defined in NanoUI.Svg

Methods

showsPrec :: Int -> Svg -> ShowS #

show :: Svg -> String #

showList :: [Svg] -> ShowS #

svgSize :: Svg -> (Float, Float) Source #

The document's own width and height, from its width and height or else its viewBox.

svgKey :: Svg -> Int Source #

A hash of the source, for caching rasters.

svgMonochrome :: Svg -> Bool Source #

Every paint is currentColor or unspecified, so the drawing is one colour and can be tinted.

parseSvg :: Text -> Either String Svg Source #

Parse an SVG document.

rasterizeSvg :: Int -> Int -> Color -> Svg -> ByteString Source #

Render the document into a width by height RGBA image (rows top to bottom), scaled to fit and centred as SVG's default xMidYMid meet does. current is what currentColor, and an unspecified fill, paint with.