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

Add gradient support to fill #104

Open
nym opened this issue Jan 19, 2017 · 3 comments
Open

Add gradient support to fill #104

nym opened this issue Jan 19, 2017 · 3 comments
Labels
feature feature request to implement
Projects

Comments

@nym
Copy link

nym commented Jan 19, 2017

Noticed there's no way to do a shape with a gradient. Would be a nice addition if anyone has time to implement!

@nym nym changed the title No gradient support Add gradient support Jan 19, 2017
@nym nym changed the title Add gradient support Add gradient support to fill Jan 19, 2017
@legomushroom
Copy link
Member

Hi @nym,

Thanks for the issue! Something like this?

const new mojs.Shape({
  fill: 'url(#greadient)'
});

Or you mean a CSS gradient?

@nym
Copy link
Author

nym commented Mar 2, 2017

@legomushroom I was thinking more like a CSS gradient, something that could support transparency. I had not considered using an image for a gradient.

// basic example with hexadecimal colors
const new mojs.Shape({
  fill: 'linear-gradient(to bottom, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%)'
});

// lots of control over color stops
const new mojs.Shape({
  fill: 'linear-gradient(45deg, rgba(206,219,233,1) 0%,rgba(170,197,222,1) 17%,rgba(97,153,199,1) 50%,rgba(58,132,195,1) 51%,rgba(65,154,214,1) 59%,rgba(75,184,240,1) 71%,rgba(58,139,194,1) 84%,rgba(38,85,139,1) 100%)'
});

// transparency with rgba colors
const new mojs.Shape({
  fill: 'linear-gradient(45deg, rgba(30,87,153,1) 0%,rgba(125,185,232,0) 100%)'
});

@eybarta
Copy link

eybarta commented Jul 12, 2018

@legomushroom actually the example you wrote above is exactly what I would do, the only thing is where would I put the tag with the gradient stops? could the #gradientTag be used from a different SVG on the page? is there a way to implement this as of today? thx

@xavierfoucrier xavierfoucrier added the feature feature request to implement label Mar 20, 2019
@xavierfoucrier xavierfoucrier added this to Features in mojs@next Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature feature request to implement
Projects
No open projects
mojs@next
Features
Development

No branches or pull requests

4 participants