gpt4 book ai didi

python - 在 python : Why is my circle so ugly? 中绘图

转载 作者:太空宇宙 更新时间:2023-11-03 10:50:27 25 4
gpt4 key购买 nike

我怎样才能把圆弄平?在某些点上有颠簸,而且非常..粗糙。我需要在里面画多个圆圈,当我尝试的时候它看起来真的很糟糕。这是 PIL 的问题还是我想念的东西?

我是这样画的:

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)

circle

最佳答案

为了使您的圆看起来更平滑,您需要添加抗锯齿。

使用和不使用抗锯齿的示例: enter image description here

资源:Draw Ellipse in Python PIL with line thickness

关于python - 在 python : Why is my circle so ugly? 中绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51559043/

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