Drawing in python: Why is my circle so ugly?
Asked Answered
E

1

6

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?

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)

circle

Entomologize answered 27/7, 2018 at 13:29 Comment(0)
N
2

To make your circle appear smoother you need to add antialias.

Example with and without antialias: enter image description here

Resource: Draw Ellipse in Python PIL with line thickness

Nephogram answered 27/7, 2018 at 13:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.