/avd-to-svg

Android VectorDrawable to SVG

Primary LanguageJavaScriptMIT LicenseMIT

Android VectorDrawable to SVG

MIT License

There are several converters for converting vector drawables to svg (I know 3 of them, including ShapeShifter), but no one supports gradients.

This tool tries to support almost everything.

Usage

node <path-to-avd-to-svg>/index.js <source-vector-drawable.xml> <output.svg>

Mappings

  • <vector><svg>

    • nameid
    • viewportWidth, viewportHeightwidth, height, viewBox
    • alphaopacity
    • tint, tintModenot supported, ignored
  • <group><g>

    • nameid
    • translateX, translateY, pivotX, pivotY, rotation, scaleX, scaleYtransform
  • <path><path>

    • nameid
    • pathDatad
    • fillColorfill, fill-opacity
    • fillTypefill-rule
    • strokeColorstroke, stroke-opacity
    • strokeWidthstroke-width
    • strokeLineCapstoke-linecap
    • strokeLineJoinstoke-linejoin
    • strokeMiterLimitstoke-miterlimit
    • trimPathStart, trimPathEnd, trimPathOffsetstroke-dasharray, stroke-dashoffset
  • <clip-path><clipPath> + <path>

    • nameid
    • pathDatad in <path>
  • <aapt:attr> + <gradient> - supported in <path> for fillColor and strokeColor

    • type → maps to <linearGradient> or <radialGradient>
    • startColor<stop offset="0%" stop-color="..." stop-opacity="...">
    • centerColor<stop offset="50%" stop-color="..." stop-opacity="...">
    • endColor<stop offset="100%" stop-color="..." stop-opacity="...">
    • tileModenot supported, ignored
  • <item> inside <gradient><stop>

    • offsetoffset
    • colorstop-color, stop-opacity
  • <gradient android:type="linear">linearGradient

    • startXx1
    • startYy1
    • endXx2
    • endYy2
  • <gradient android:type="radial">radialGradient

    • centerXcx
    • centerYcy
    • gradientRadiusfr
  • <gradient android:type="sweep">no direct mapping in svg, converted to radialGradient

TODO

  • Resource references (eg. @color/some_color)