How do you fill an angular sector all the way to the center?
pieslice closes an arc with two radii so the entire sector can be filled.
Pixel experiment and interpretation
For a scan-direction indicator, both an interior probe and the center should be labeled. An outline arc alone leaves the interior empty.
from PIL import Image, ImageDraw
im=Image.new('L',(9,9))
ImageDraw.Draw(im).pieslice((0,0,8,8),0,90,fill=1)
[im.getpixel(p) for p in [(4,4),(6,6),(2,2)]]Result [1, 1, 0]
中文
怎样画出包含圆心的扇形区域?
pieslice 用两条半径与一段圆弧闭合轮廓,可以填充内部。
像素实验与适用边界
制作扫描方向指示图时,扇形内的一点和圆心都应有标签。仅画弧线不会覆盖内部。
from PIL import Image, ImageDraw
im=Image.new('L',(9,9))
ImageDraw.Draw(im).pieslice((0,0,8,8),0,90,fill=1)
[im.getpixel(p) for p in [(4,4),(6,6),(2,2)]]结果 [1, 1, 0]