【问题标题】:Clearing pixels of font path in HTML <canvas>清除 HTML <canvas> 中字体路径的像素
【发布时间】:2013-01-28 22:54:53
【问题描述】:

我想知道如何创建一个彩色画布,但带有透明部分的字体。我希望字体在这个画布上创建一个洞。这可能吗?如何?我的目标是营造一种图像嵌入字体的印象......

谢谢你:)

【问题讨论】:

  • 为什么不使用text-shadow

标签: css image fonts html5-canvas


【解决方案1】:

&lt;canvas&gt; 提供了一种叫做复合操作的东西,用于截断和此类效果。我相信您想要的操作称为destination out

https://developer.mozilla.org/samples/canvas-tutorial/6_1_canvas_composite.html

以下是规范中的更多技术细节:

http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#compositing

我无法为您提供实际的工作代码(您的用例非常少见),但您应该能够找到 globalComposite 教程,并且几乎不玩他们的代码,您就可以了解如何应用为您的案例做手术。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2011-03-06
  • 2010-10-14
  • 2012-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-07
  • 1970-01-01
相关资源
最近更新 更多