简体   繁体   English

使用Javascript是否可以获取由线性或径向渐变呈现的背景图像?

[英]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;... 我对渐变特别感兴趣,但我想这个问题适用于使用任何方法渲染的图像,例如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: 对于有兴趣保存CSS3线性或径向渐变的.png的任何人,请转到:

http://www.visualcsstools.com/gradient-generator.htm 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. 设计渐变,单击CVS(画布)按钮,然后右键单击渐变预览以将其另存为图像。

A DOM element with a CSS gradient background, no way to do that without a screen shot utility. 一个具有CSS渐变背景的DOM元素,没有屏幕截图实用程序就无法做到这一点。

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. 但是,如果在canvas元素(以及canvas元素中的任何其他图形)上绘制渐变,则可以使用浏览器中的JavaScript将画布元素的图形导出为JPG或PNG。 See this question . 看到这个问题

通过截图吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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