Skip to content

Conversation

@benjamintd
Copy link
Contributor

Fixes #1098

This PR allows defining gradient transforms as part of the defs for linear gradients.
This fixes the (now stale, but still relevant) associated feature request #1098.

Example usage:

 <Line
        {...commonProperties}
        enableArea={true}
        yScale={{
            type: 'linear',
            stacked: true,
        }}
        curve={select('curve', curveOptions, 'linear')}
        defs={[
            linearGradientDef(
                'gradientA',
                [
                    { offset: 0, color: 'inherit' },
                    { offset: 100, color: 'inherit', opacity: 0 },
                ],
                { gradientTransform: 'rotate(90 0.5 0.5)' }
            ),
        ]}
        fill={[{ match: '*', id: 'gradientA' }]}
    />

The transform attribute follows the SVG spec documented here: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform

I added a test and modified the gradient example to show how to use that new property, which for instance allows horizontal gradients on lines:
image

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@benjamintd benjamintd mentioned this pull request Oct 27, 2021
Copy link
Owner

@plouc plouc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@plouc
Copy link
Owner

plouc commented Nov 7, 2021

@benjamintd thank you for your contribution! That's a nice addition to the lib.

@plouc plouc merged commit 76062b5 into plouc:master Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gradient rotation

2 participants