How can I smooth out the circle? At some points there are bumps and it's quite .. rough. I need to draw multiple circles inside and it really looked bad when I tried it. Is this some issue with PIL or something I miss?
我该如何平滑圆圈?在某些地方有颠簸,而且非常粗糙。我需要在里面绘制多个圆圈,当我尝试它时它看起来真的很糟糕。这是PIL的一些问题还是我想念的东西?
Here is how I draw it:
这是我绘制它的方式:
import Image, ImageDraw, ImageFont
OUT_PATH = "" # of your liking
DRAW_CLR = (255,204,0)
DRAW_IMG_BCKG_CLR=(15,48,90)
w = h = 586
im = Image.new("RGB", (w, h), DRAW_IMG_BCKG_CLR)
draw = ImageDraw.Draw(im)
thick = 3
circlesize= min(w, h)
circle = circlesize*0.9
circle_bbox = (w/2 - circle/2 - thick, h/2 - circle/2 - thick, w/2 + circle/2 + thick, h/2 + circle/2 + thick)
draw.ellipse(circle_bbox , fill=DRAW_CLR)
im.save(OUT_PATH+"circle.png",DRAW_CHART_IMAGE_TYPE)
1 个解决方案
#1
3
To make your circle appear smoother you need to add antialias.
要使您的圆圈看起来更流畅,您需要添加抗锯齿。
Example with and without antialias:
有和没有抗锯齿的示例:
Resource: Draw Ellipse in Python PIL with line thickness
资源:使用线条粗细在Python PIL中绘制椭圆
#1
3
To make your circle appear smoother you need to add antialias.
要使您的圆圈看起来更流畅,您需要添加抗锯齿。
Example with and without antialias:
有和没有抗锯齿的示例:
Resource: Draw Ellipse in Python PIL with line thickness
资源:使用线条粗细在Python PIL中绘制椭圆