I'm having trouble drawing the oval shown in the picture. The problem is that half of the oval should be exactly at the point (200, -200). When I draw an oval, half of it misses the point (200, -200). But here's the main condition: the program introduces only a smaller radius of the oval (in this case 120. Does anyone know how to do this, maybe you need to move it to a certain position before drawing? How to do that without using other libraries? The font size, its color, the radius of the small arc, and the color of the oval are entered.
Example:
60
MidnightBlue
120
LawnGreen
Result:
My code:
import turtle
fontsize = int(input()) # size of font (60)
maincol = input() # color of text and axis (MidnightBlue)
r = int(input()) # smaller radius of oval (120)
ovalcol = input() # color of oval (LawnGreen)
st = turtle.Turtle() # name of turtle
st.pu()
st.goto(-300, 150)
st.color(maincol)
s1 = '\N{GREEK SMALL LETTER THETA}'
s2 = '='
s3 = '\N{GREEK SMALL LETTER OMEGA}'
s4 = 't'
s5 = '+'
s6 = '\N{VULGAR FRACTION ONE HALF}'
s7 = '\N{GREEK SMALL LETTER EPSILON}'
s8 = 't'
s9 = '\N{SUPERSCRIPT TWO}'
res = s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 # all symbols in one formula
st.write(res, move=False, align='left', font=('Times New Roman',
fontsize, 'normal'))
st.pu()
st.goto(200, -200) # here is the half of the vertical oval
st.color(ovalcol)
st.pd()
st.seth(45) # I don't know what the angle should be here
st.begin_fill()
for i in range(2):
st.circle(r * 2, 90) # drawing a larger arc
st.circle(r, 90) # drawing a smaller arc
st.end_fill()
st.pu()
st.goto(200, -200 - r / 4) # drawing an axis
st.color(maincol)
st.pd()
st.seth(90)
st.fd(r * 4) # as you can see, the axis does not divide the oval in half and this is the whole problem
st.hideturtle()
turtle.done()
And my result: unexpected result
I tried to draw oval from different corners, but this did not help me
Here's an alternate approach using stamping instead of drawing. It simplifies the logic but doesn't produce as good looking an ellipse:
Here we're drawing the ellipse from it's center, basically fitting a circle into a rectangle: