怎么画自己喜欢的图形,怎么能画出漂亮的图形呢

首页 > 实用技巧 > 作者:YD1662023-12-20 03:09:32

turtle画一个彩色螺旋图形

import turtle turtle.shape('turtle') turtle.speed(9) # 画笔速度 turtle.pensize(2) # 画笔的宽度 turtle.bgcolor("black") # 画布背景色 colors = ["red","yellow","green","blue"] # 定义画笔线色 for i in range(255): # 循环一次 画一条线 turtle.forward(2 * i) # 向当前方向前进n像素 turtle.color(colors[i % 4]) # 根据求余 调整画笔线色 turtle.left(91) # 向左旋转91度 turtle.done()

怎么画自己喜欢的图形,怎么能画出漂亮的图形呢(1)

仙人球

import turtle turtle.shape('turtle') turtle.color('orange', 'green') turtle.begin_fill() while True: turtle.forward(200) turtle.left(170) if abs(turtle.pos()) < 1: break turtle.end_fill() turtle.done()

怎么画自己喜欢的图形,怎么能画出漂亮的图形呢(2)

国旗

import turtle turtle.shape('turtle') turtle.screensize(2000, 2000, 'white') # 设置画布大小 turtle.speed(9) # 绘制旗面 turtle.pencolor('red') # pu() turtle.goto(-300, -200) turtle.pd() turtle.fillcolor('red') turtle.begin_fill() for i in range(0, 2): turtle.fd(600) turtle.lt(90) turtle.fd(400) turtle.lt(90) turtle.end_fill() # 绘制大五角星 turtle.pu() turtle.pencolor('yellow') turtle.goto(-260, 120) turtle.pd() turtle.fillcolor('yellow') turtle.begin_fill() for i in range(0, 5): turtle.fd(113.137) # 大星一划的边长 turtle.rt(144) turtle.end_fill() # 绘制四个小五角星 list1 = [(-100, 160), (-60, 120), (-60, 60), (-100, 20)] # 四个五角星的中心坐标 list2 = [31.98, 8.13, -15.59, -38.66] # 相对角度0的后退1.111需要左转的角度 for j in range(0, 4): turtle.seth(0) # 这是龟头角度为0 turtle.pu() turtle.goto(list1[j]) # 定位到五角星中心 turtle.lt(list2[j]) # 旋转角度,以背向指向大五角星的角尖 turtle.bk(20) # 从五角星中心到指向大五角星的角尖(龟倒着爬)退一个小圆半径 turtle.lt(18) # 五角星的半角角度 turtle.pd() turtle.begin_fill() for i in range(0, 5): turtle.fd(113.137 / 3) # 小星一划的边长 turtle.rt(144) turtle.end_fill() turtle.pu() turtle.ht() turtle.done()

怎么画自己喜欢的图形,怎么能画出漂亮的图形呢(3)

玫瑰花

import turtle import time turtle.shape('turtle') turtle.speed(5) # 设置初始位置 turtle.penup() turtle.left(90) turtle.fd(200) turtle.pendown() turtle.right(90) # 花蕊 turtle.fillcolor("red") turtle.begin_fill() turtle.circle(10,180) turtle.circle(25,110) turtle.left(50) turtle.circle(60,45) turtle.circle(20,170) turtle.right(24) turtle.fd(30) turtle.left(10) turtle.circle(30,110) turtle.fd(20) turtle.left(40) turtle.circle(90,70) turtle.circle(30,150) turtle.right(30) turtle.fd(15) turtle.circle(80,90) turtle.left(15) turtle.fd(45) turtle.right(165) turtle.fd(20) turtle.left(155) turtle.circle(150,80) turtle.left(50) turtle.circle(150,90) turtle.end_fill() # 花瓣1 turtle.left(150) turtle.circle(-90,70) turtle.left(20) turtle.circle(75,105) turtle.setheading(60) turtle.circle(80,98) turtle.circle(-90,40) # 花瓣2 turtle.left(180) turtle.circle(90,40) turtle.circle(-80,98) turtle.setheading(-83) # 叶子1 turtle.fd(30) turtle.left(90) turtle.fd(25) turtle.left(45) turtle.fillcolor("green") turtle.begin_fill() turtle.circle(-80,90) turtle.right(90) turtle.circle(-80,90) turtle.end_fill() turtle.right(135) turtle.fd(60) turtle.left(180) turtle.fd(85) turtle.left(90) turtle.fd(80) # 叶子2 turtle.right(90) turtle.right(45) turtle.fillcolor("green") turtle.begin_fill() turtle.circle(80,90) turtle.left(90) turtle.circle(80,90) turtle.end_fill() turtle.left(135) turtle.fd(60) turtle.left(180) turtle.fd(60) turtle.right(90) turtle.circle(200,60) turtle.done()

怎么画自己喜欢的图形,怎么能画出漂亮的图形呢(4)

首页 123下一页

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.