要求

创作的内容可以是:

  1. 简单图形
  2. 正多边形图形
  3. 图形的组合图形
  4. 各种有意义的图形

示例图形

  1. 旋转三角形组合的图形 image
  2. 城堡 image
  3. 几何图形 image

示例代码

# 这段代码可以绘制一个三角形,课上讲过
import turtle as t
t.forward(100)
t.right(120)
t.forward(100)
t.right(120)
t.forward(100)
t.right(120)

20 comments

  • @ 2023-11-17 20:41:57

    image

    • @ 2023-11-10 21:10:24

      image

      • @ 2023-11-4 23:02:35

        image

        • @ 2023-11-4 21:53:31

          image

          • @ 2023-11-4 21:53:05

            image

            • @ 2023-11-4 21:24:55

              image

              • @ 2023-11-3 22:28:34
                pygame.init()
                
                screen = pygame.display.set\_mode((400, 400))
                
                rect = pygame.Rect(100, 100, 200, 200)
                
                pygame.draw.rect(screen, (255, 0, 0), rect)
                
                pygame.display.update()
                
                while True:
                
                for event in pygame.event.get():
                
                if event.type == pygame.QUIT:
                
                pygame.quit()
                
                quit()
                
                • @ 2023-11-3 21:25:00

                  image

                  🌿 2
                  • @ 2023-10-28 17:16:25

                    image

                    👍 2
                    • @ 2023-10-28 17:12:18

                      image

                      👍 2
                      • @ 2023-10-28 17:07:56

                        image

                        👍 2
                        • @ 2023-10-28 16:54:20

                          image

                          👍 2
                          • @ 2023-10-28 16:49:07

                            image

                            👍 2
                            • @ 2023-10-28 16:09:44

                              image

                              🌿 1
                              • @ 2023-10-28 10:16:49

                                画了一个奥运五环,没有涂色 image

                                • @ 2023-10-28 10:07:15

                                  image

                                  • @ 2023-10-28 8:14:16

                                    import turtle as t t.shape("turtle") t.forward(200) t.left(60) t.forward(-200) t.left(60) t.forward(200)

                                    • @ 2023-10-27 19:47:53

                                      import turtle as t for(180) t.forward(100) t.right(120) t.forward(100) t.right(120) t.forward(100) t.right(120)

                                      • @ 2023-10-26 21:47:31

                                        import turtle as t import math

                                        t.setup(1000, 750) #设置窗口大小 t.setworldcoordinates(-800,-600,800,600) #设置坐标系 t.title('I am ikun!!') t.width(8) t.speed(0) t.pencolor('black')

                                        #以圆心和半径画圆 def my_circle(rad,c_x,c_y,color=None): if color is not None: t.fillcolor(color) t.begin_fill() t.penup() t.setheading(0) t.goto(c_x,c_y-rad) t.pendown() t.circle(rad) if color is not None: t.end_fill()

                                        #求θ角度方向上椭圆的坐标 def get_ellipse_xy(a,b,theta): if theta < 0:theta=theta+math.pi2 x = a * b / math.sqrt(b * b + a * a * math.tan(theta) * math.tan(theta)) if theta < math.pi/2: return {'x':x,'y':xmath.tan(theta)} elif theta < math.pi: return {'x':x*(-1),'y':x*(-1)math.tan(theta)} elif theta < math.pi3/2: return {'x':x*(-1),'y':x*(-1)math.tan(theta)} else: return {'x': x, 'y': xmath.tan(theta)}

                                        画一个椭圆,shape为椭圆形状参数,start_ang、end_ang为起始角度(相对于椭圆中心)

                                        shape = {"X0": 0,"Y0": 0,"a": 200,"b": 100,"angle": math.pi/3}

                                        def draw_ellipse(shape, start_ang, end_ang, color=None): if color is not None: t.fillcolor(color) t.begin_fill() a = shape['a'] b = shape['b'] shape_ang = shape['angle'] theta = start_ang - shape_ang x1, y1 = get_ellipse_xy(a, b, theta).values() x = shape['X0'] + x1 * math.cos(shape_ang) - y1 * math.sin(shape_ang) y = shape['Y0'] + x1 * math.sin(shape_ang) + y1 * math.cos(shape_ang) t.penup() t.goto(x,y) t.pendown() step = math.pi/180*2 # 以方位角2°一步 num_steps = math.ceil((end_ang-start_ang)/step) # 总步数 for i in range(num_steps): theta = theta + step x1, y1 = get_ellipse_xy(a, b, theta).values() t.goto(shape['X0'] + x1 * math.cos(shape_ang) - y1 * math.sin(shape_ang), shape['Y0'] + x1 * math.sin(shape_ang) + y1 * math.cos(shape_ang)) if color is not None: t.end_fill()

                                        #画篮球 my_circle(150, -206, -212, '#BA7148') baskt_line1 = {"X0": -120,"Y0": -34,"a": 186,"b": 162,"angle": 0} draw_ellipse(baskt_line1, math.pi / 180 * 198, math.pi / 180 * 290) baskt_line2 = {"X0": -294,"Y0": -402,"a": 186,"b": 162,"angle": 0} draw_ellipse(baskt_line2, math.pi / 180 * 21, math.pi / 180 * 110) t.penup() t.goto(-346,-160) t.pendown() t.goto(-66,-274)

                                        画脸蛋

                                        face = {"X0": 80,"Y0": -22,"a": 256,"b": 198,"angle": 0} draw_ellipse(face, 0, math.pi * 2, '#F5D477')

                                        #眼睛 my_circle(77, 63, 41, 'white') my_circle(68, 217, 41, 'white') my_circle(24, 100, 34, 'black') my_circle(24, 244, 34, 'black')

                                        #嘴巴 t.width(5) mouth = {"X0": 145, "Y0": -73, "a": 75, "b": 53, "angle": 0} draw_ellipse(mouth, 0, math.pi * 2, '#F4A644') mouse_line = {"X0": 138,"Y0": -40,"a": 92,"b": 53,"angle": 0} draw_ellipse(mouse_line, math.pi / 180 * 208, math.pi / 180 * 342, '#F4A644')

                                        #腮红 t.width(1) t.pencolor('#F5D477') my_circle(62, -82, -62, 'red') # 左边 face_cheek = {"X0": 294,"Y0": -66,"a": 37,"b": 60,"angle": -math.pi/180*12} draw_ellipse(face_cheek, 0, math.pi * 2, 'red') # 右边 #腮红有点遮住脸的轮廓,重新绘制一遍 t.pencolor('black') t.width(8) draw_ellipse(face, -math.pi / 3, math.pi / 3)

                                        定义一个画polygon的函数

                                        def draw_poly(poly_data,color=None): x=poly_data['x'] y=poly_data['y'] t.penup() t.goto(x[0], y[0]) t.pendown() if color is not None: t.fillcolor(color) t.begin_fill() for i in range(len(x)): t.goto(x[i], y[i]) if color is not None: t.end_fill()

                                        画头发

                                        poly_hair = {'x': [-258, -161, -74, 0, 55, 111, 211, 315, 362, 329, 293, 283, 269, 227, 269, 283, 208, 194, 160, 160, 85, 44, 61, 44, 31, 1, -33, 1, -60, -51, -60, -62, -129, -142, -144, -108, -144, -142, -209, -216, -200, -216, -258], 'y': [57, 187, 238, 267, 251, 296, 260, 171, 47, -9, 29, 61, 110, 166, 110, 61, 72, 132, 178, 178, 174, 162, 206, 162, 29, 35, 54, 35, 4, 40, 4, -37, -45, -8, 71, 152, 71, -8, -31, 31, 90, 31, 57] } draw_poly(poly_hair, '#D0CED1')

                                        头发下那个小三角

                                        hair2 = {'x': [160, 114, 85], 'y': [178, 218, 174]} draw_poly(hair2, '#797572')

                                        衣服

                                        poly_cloth = {'x': [-142, -112, -22, 50, 132, 218, 249, 247, 295, 328, 318, 321, 309, 338, 353, -167, -150, -165, -166, -150, -162, -157, -142], 'y': [-135, -155, -144, -140, -150, -166, -163, -150, -145, -165, -194, -233, -244, -290, -326, -328, -248, -233, -209, -195, -167, -146, -135] } draw_poly(poly_cloth, '#222222') cloth2 = {'x': [-58, 0, 89, 146, 205, 250, 212, 179, 89, 26, -27, -58], 'y': [-207, -203, -178, -184, -202, -208, -236, -246, -243, -237, -233, -207] } t.width(2) draw_poly(cloth2, '#0A0A0C') #中间黑的那一块

                                        左右背带

                                        strap1 = {'x': [-150, -92, -57, -41, -39, -46], 'y': [-220, -227, -243, -277, -306, -328]} strap2 = {'x': [309, 269, 238, 224, 222], 'y': [-222, -233, -257, -292, -326]} t.width(18) t.pencolor('#D3D1D4') draw_poly(strap1) draw_poly(strap2)

                                        #中间背带 t.width(10) strap3 = {'x': [-17, 90, 209, 90, 93],'y': [-251, -273, -248, -273, -290]} draw_poly(strap3) t.width(2) t.pencolor('white') my_circle(30, 97, -320, '#D1D1D3')

                                        文字kun

                                        k = {'x': [78, 78, 78, 88, 78, 88], 'y': [-312, -326, -319, -312, -319, -326]} draw_poly(k) u = {'x': [93, 93, 98, 103, 103], 'y': [-312, -323, -326, -323, -312]} draw_poly(u) n = {'x': [109, 109, 119, 119], 'y': [-326, -312, -326, -312]} draw_poly(n)

                                        t.resizemode("user") t.shapesize(0.8, 0.8) t.hideturtle() t.done()

                                        • @ 2023-10-26 21:44:06

                                          import turtle as t t.shape("turtle") t.right(135) t.forward(100) t.left(135) t.forward(140) t.left(135) t.forward(100) t.penup() t.goto(-60,-70) t.pendown() t.left(135) t.forward(100) t.left(90) t.forward(120) t.left(90) t.forward(100) t.forward(-100) t.right(90) t.forward(300) t.forward(-300) t.left(180) t.forward(400)

                                          • 1