in shared/java/svg/SVGLengthContext.java [21:50]
public float resolve(@NotNull SVGLength length, @NotNull SVGLengthType type) {
switch (length._unit) {
case NUMBER:
return length._value;
case PX:
return length._value;
case PERCENTAGE:
switch (type) {
case HORIZONTAL:
return length._value * _width / 100f;
case VERTICAL:
return length._value * _height / 100f;
case OTHER:
// https://www.w3.org/TR/SVG11/coords.html#Units_viewport_percentage
return (float) (length._value * Math.hypot(_width, _height) / Math.sqrt(2.0) / 100.0);
}
case CM:
return length._value * _dpi / 2.54f;
case MM:
return length._value * _dpi / 25.4f;
case IN:
return length._value * _dpi;
case PT:
return length._value * _dpi / 72.272f;
case PC:
return length._value * _dpi * 12f / 72.272f;
default:
throw new IllegalArgumentException("Unknown SVGLengthUnit: " + length._unit);
}
}