Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use linear gradient as fill/stroke colour? #29

Open
ivanbacher opened this issue Apr 17, 2017 · 1 comment
Open

Use linear gradient as fill/stroke colour? #29

ivanbacher opened this issue Apr 17, 2017 · 1 comment
Labels

Comments

@ivanbacher
Copy link

Is it possible to use a gradient fill instead of a single colour?

var def = svg.append('defs');
var gradient = def.append('linearGradient')
    .attr('id', 'custom_id_1')
    .attr('x1', '50%')
    .attr('y1', '0%')
    .attr('x2', '50%')
    .attr('y2', '100%');

//set start
gradient.append('stop')
    .attr('offset', '0%')
    .attr('stop-color', 'white')

//set color at the end
gradient.append('stop')
    .attr('offset', '100%')
    .attr('stop-color', 'blue')
var t = textures
    .lines()
    .shapeRendering("crispEdges")
    .background('url(#custom_id_1)');

screen shot 2017-04-17 at 14 06 30

var t = textures
    .lines()
    .shapeRendering("crispEdges")
    .stroke('url(#custom_id_1)');

screen shot 2017-04-17 at 14 06 18

@riccardoscalco
Copy link
Owner

No, at the moment the library does not provide methods for linear gradients.
I leave this issue open for future investigations, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants