简体   繁体   中英

Using Javascript is there a way to grab the background image rendered by a linear or radial gradient?

I'm specifically interested in gradients but I suppose the question applies to images rendered with any method, such as data:image/svg+xml;...

Is it possible?

ETA:

This was possible by rendering the gradient onto a canvas. For anyone interested in saving a .png of a CSS3 linear or radial gradient, go to:

http://www.visualcsstools.com/gradient-generator.htm

Design your gradient, click the CVS (canvas) button and right-click the gradient preview to save it as an image.

A DOM element with a CSS gradient background, no way to do that without a screen shot utility.

However, if you drew a gradient in a canvas element (and any other graphics in the canvas element), you could export the graphic of the canvas element as a JPG or PNG using JavaScript in the browser. See this question .

通过截图吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM