gpt4 book ai didi

javascript - 在 JavaScript Canvas 上创建文本轮廓

转载 作者:太空宇宙 更新时间:2023-11-04 14:20:06 28 4
gpt4 key购买 nike

在 Canvas 上绘图时,如何使用 JavaScript 为文本添加轮廓?请参阅下图,了解我尝试做的事情。

enter image description here

最佳答案

Daniel Langh 向我展示了解决方案:

var txt = 'Hello World!';
var x = 30,
y = 50;

context.font = "40px Helvetica";

context.strokeStyle = 'white';

// setup these to match your needs
context.miterLimit = 2;
context.lineJoin = 'circle';

// draw an outline, then filled
context.lineWidth = 7;
context.strokeText(txt, x, y);
context.lineWidth = 1;
context.fillText(txt, x, y);

关于javascript - 在 JavaScript Canvas 上创建文本轮廓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14126298/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com