gpt4 book ai didi

javascript - 在绘制矩形之前更改 lineCap 和 lineJoin 没有任何作用?

转载 作者:行者123 更新时间:2023-11-30 18:24:16 28 4
gpt4 key购买 nike

我有这个代码:

context.lineWidth = 10;

context.lineCap = "square";
context.lineJoin = "square";

context.strokeRect(x, y, w, h);

lineWidth 似乎工作正常,但更改 lineCaplineJoin 没有任何作用。当我将 lineCaplineJoin 设置为 "round" 时,矩形仍然是圆形的。有谁知道这是为什么吗?

最佳答案

这是因为您需要为 lineJoin 使用 miter,因为 square 不是有效值。

Live Demo

The lineJoin attribute defines the type of corners that UAs will place where two lines meet. The three valid values are bevel, round, and miter.

W3 reference

此外,如果您只是在做矩形,则不需要 lineCap

关于javascript - 在绘制矩形之前更改 lineCap 和 lineJoin 没有任何作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11319738/

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