最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is the getCSSCanvasContext() method of an HTML5 element? - Stack Overflow

programmeradmin0浏览0评论

What is the getCSSCanvasContext() method? I saw it in Chrome’s debuging console, but I cannot find any decent documentation for it.

Does it mean we can draw using canvas commands on any element?

What is the getCSSCanvasContext() method? I saw it in Chrome’s debuging console, but I cannot find any decent documentation for it.

Does it mean we can draw using canvas commands on any element?

Share Improve this question edited Nov 1, 2011 at 8:32 Paul D. Waite 98.8k57 gold badges202 silver badges271 bronze badges asked Aug 8, 2010 at 3:55 tzadortzador 2,6314 gold badges33 silver badges38 bronze badges 1
  • It's worth noting that this method is deprecated in recent chrome builds and is probably going to be removed: groups.google.com/a/chromium.org/forum/#!topic/blink-dev/… – 1800 INFORMATION Commented Jan 25, 2016 at 2:13
Add a comment  | 

2 Answers 2

Reset to default 16

The method is implemented in WebKit (meaning you can also use it in Safari) and returns an object that lets you draw into a CSS image. See this blog post for an example:

In the latest nightlies, you can try out a new feature: the ability to specify named image buffers in CSS and then to draw into them programmatically from JavaScript. Here’s how it works.

background: -webkit-canvas(mycanvas);

Instead of specifying an image URL, you specify a canvas and an identifier to use for that canvas. The following new API on documents can then be used to obtain a drawing context for that canvas.

CanvasRenderingContext getCSSCanvasContext(in DOMString contextType, in DOMString identifier, in long width, in long height);

also don't use ctx.clearRect(0, 0, w, h); for IE9 - it doesn't work after this code if you try to draw something after clearRect() you will get empty canvas anyway

发布评论

评论列表(0)

  1. 暂无评论