How does stroke width change a rasterized path's coverage?
line joins supplied coordinates with a stroke whose width is measured in pixels.
Pixel experiment and interpretation
Draw the same horizontal trajectory one and three pixels wide. Treating painted area as path length would make distance depend on brush width.
from PIL import Image, ImageDraw
def area(w):
im=Image.new('L',(9,9))
ImageDraw.Draw(im).line([(2,4),(6,4)],fill=1,width=w)
return im.histogram()[1]
[area(1),area(3)]Result [5, 15]
中文
标注轨迹的线宽会怎样改变覆盖的像素数?
line 连接给定点,width 指定线条以像素计的宽度。
像素实验与适用边界
把同一条水平轨迹画成一格和三格宽。若把覆盖面积当作路程,结果会随笔宽变化。
from PIL import Image, ImageDraw
def area(w):
im=Image.new('L',(9,9))
ImageDraw.Draw(im).line([(2,4),(6,4)],fill=1,width=w)
return im.histogram()[1]
[area(1),area(3)]结果 [5, 15]