toLengthFloat

fun String.toLengthFloat(width: Float, height: Float): Float(source)

Some properties on SVG can receive a Number or a percentage. This extension function helps to extract the percentage, in case of present, and transform in the correct float value.

Return

The percentage calculation based on the max of width and height, in case of String with %, or a direct conversion to Float

Parameters

width

The SVG/AVD width

height

The SVG/AVD height