如何使线与圆一样粗?

How to make line as thick as circle?

我想制作一条宽度等于圆直径的圆线。 经过反复试验,这似乎产生了想要的输出。

import Diagrams.Prelude
import Diagrams.Backend.Cairo.CmdLine
main = mainWith example

path = fromVertices [p2 (0,0), p2 (3,0)] # lw 80

example :: Diagram B
example = atPoints [p2 (0,0)] n
  <> (path # lineCap LineCapRound  . lineJoin LineJoinRound)
  <> atPoints [p2 (3,0)] n
  <> square 10 # lw none # fc white
 where
   n =[circle 1 # fc green # lw none]

不过感觉不对。我希望 lw 2 对应于 circle 1 因为 2 是半径的两倍,但肯定不是 lw 80?!
为什么它适用于80? 假设我漏掉了一些东西,如何使圆线像圆一样宽?

您需要 lwL,它代表 "line weight, local",并使用与长度相同的线宽单位。

the manual中有更多详细信息,这里是相关摘录:

local units are the most straightforward to explain. Values in local units are interpreted in the context of the local vector space, just as most other length measurements (e.g. arguments to functions like circle and square). For example, square 1 # lwL 0.2 specifies a square which is drawn with lines one fifth as wide as its sides are long—and will always be, even if it is scaled: the line width scales right along with the square. (The L in lwL stands for "Local".)