I am trying to create a canvas object which I can use to create an image from (using canvas.toDataURL()
).
One of the key elements of this canvas, has to be the background gradient set using the following css:
background: -webkit-linear-gradient(-45deg, #1e5799 0%,#2989d8 36%,#207cca 71%,#7db9e8 100%);
.
As you can see this is set using a certain angle (-45deg)
.
Is there any way for me to create this using canvas and also being able to create an image from this which includes this background?
This doesn't work when manually setting the css-background property, as toDataURL
does not take into account any css. I have also looked at drawing it into the canvas myself, but ctx.createLinearGradient
does not support drawing of angles.
How can I achieve a canvas which allows toDataURL
which includes my desired background?