SVG Palette

Parse an SVG to discover which colors it contains.

Usage

require "svg_palette"

SVGPalette.parse(File.read("flag_of_togo.svg"))
#=> [RGB [#006a4e], RGB [#ffce00], RGB [#d21034], RGB [#ffffff]]

The array contains instances of Color.

Note: The color black may not be detected unless it is explictly set as a property value.

Properties

The following properties are considered:

fill stroke stop-color flood-color lighting-color style

When checking style rules, only the keys for those properties are considered, e.g:

<foo style="fill:red"></foo>