简体   繁体   中英

Drawing a letter using circles in python turtle

I'd like to draw two letters using circles in turtle module.

显示用圆圈绘制的字母“c”的屏幕截图

I would like to get such a result, but with the letters "T" and "S". How can this be done?

I have the code here:

from turtle import *

radius = 20

def t():
   x_formation = [((i*25)-115,200) for i in range(10)]
   y_formation = [(0,(i*25)-50) for i in range(10)]

   def draw_form(formation):
      for i in formation:
         penup()
         goto(i)
         pendown()
         circle(radius)

   draw_form(x_formation)
   draw_form(y_formation)

T drawing

The code for drawing an s is below:

def s():
   
   def draw_semicircle(direction):
      if direction == 'left':
         for x in range(9):
            penup()
            forward(20)
            left(-25)
            pendown()
            circle(radius)
      else:
         for x in range(7):
            penup()
            forward(20)
            right(25)
            pendown()
            circle(radius)

   draw_semicircle('left')
   penup()
   goto(40,25)
   draw_semicircle('right')

S drawing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM