Skip to content

Importing SVG gradients with userSpaceOnUse #2524

@0HyperCube

Description

@0HyperCube

We don't currently handle importing SVGs with gradientUnits="userSpaceOnUse".

Relevant code:

// TODO: fix this
// let to_doc_transform = if linear.base.units() == usvg::Units::UserSpaceOnUse {

Sample svg:
circle with userSpaceOnUse gradient

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="174" height="174" viewBox="0,0,174,174"><defs><radialGradient cx="240" cy="180" r="87" gradientUnits="userSpaceOnUse" id="color-1"><stop offset="0" stop-color="#ffffff"/><stop offset="1" stop-color="#000000"/></radialGradient></defs><g transform="translate(-153,-93)"><g data-paper-data="{&quot;isPaintingLayer&quot;:true}" fill="url(#color-1)" fill-rule="nonzero" stroke="#000000" stroke-width="0" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" style="mix-blend-mode: normal"><path d="M153,180c0,-48.04877 38.95123,-87 87,-87c48.04877,0 87,38.95123 87,87c0,48.04877 -38.95123,87 -87,87c-48.04877,0 -87,-38.95123 -87,-87z"/></g></g></svg>

A test that this works properly would also be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    Short-Term

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions