python画彩虹和小熊

前言

今天,我们来画两个简单的图形。

一、彩虹

彩虹,又称天弓(客家话)、天虹、绛等,简称为"虹",是气象中的一种光学现象。当太阳光照射到半空中的水滴时,光线被折射及反射,在天空上形成拱形的七彩光谱,雨后常见。形状弯曲,通常为半圆状。色彩艳丽。东亚、中国对于七色光的最普遍说法(按波长从大至小排序):红、橙、黄、绿、蓝、靛、紫。

from turtle import *
 
 
rainbow_color = ["red", "orange", "yellow", "green", "cyan", "blue", "purple"]
pensize(12)  
for i in range(7):
    fd(i*10) 
    left(90)  
    pendown()  
    pencolor(rainbow_color[i])  
    circle(i*10+100, 180)
    penup()  
    home()  
ht() 

二、小熊

很简单,黑白的。

import turtle as t
 
t.pensize(2)
t.speed(0)
 
t.pu()
t.goto(-150, 0)
t.pd()
t.left(90)
t.circle(-300, 30)
 
t.seth(180)
t.circle(-40, 270)
 
t.seth(20)
t.circle(-150, 40)
 
t.seth(90)
t.circle(-40, 270)
 
t.seth(-60)
t.circle(-300, 30)
 
t.seth(-80)
t.circle(-(t.pos()[0]--150+4)/2, 200)
 
t.pu()
t.goto(-84, 50)
t.dot(20)
t.goto(47.5, 50)
t.dot(20)
 
t.goto(-18.25, 25)
t.dot(30)
t.goto(-18.25, 10)
t.pd()
t.seth(-90)
t.circle(-20, 90)
t.pu()
t.goto(-18.25, 10)
t.seth(-90)
t.pd()
t.circle(20, 90)
 
t.pu()
h = 0
pos = -74, -25
for i in range(3):
    t.pu()
    t.goto(pos[0], pos[1])
    t.seth(h)
    t.pd()
    t.circle(-35, 40)
    h = t.heading()
    pos = t.pos()
    t.seth(-135)
    t.fd(20)
t.seth(-135)
t.fd(20)
 
t.pu()
h = 180
pos = 47.5, -25
for i in range(3):
    t.pu()
    t.goto(pos[0], pos[1])
    t.seth(h)
    t.pd()
    t.circle(35, 40)
    h = t.heading()
    pos = t.pos()
    t.seth(-45)
    t.fd(20)
t.seth(-45)
t.fd(20)
 
t.hideturtle()
t.done()

总结

今天到这了~~

站在巨人的肩上是为了超过巨人。

相关推荐

  1. python彩虹

    2024-01-09 20:46:02       54 阅读
  2. Python应用—给暑假孩子出算术题

    2024-01-09 20:46:02       23 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-09 20:46:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-09 20:46:02       101 阅读
  3. 在Django里面运行非项目文件

    2024-01-09 20:46:02       82 阅读
  4. Python语言-面向对象

    2024-01-09 20:46:02       91 阅读

热门阅读

  1. Vue2和Vue3的区别

    2024-01-09 20:46:02       61 阅读
  2. DD小桔高级数分 2面挂

    2024-01-09 20:46:02       60 阅读
  3. Spring面试整理-Autowired和Resource关键字的区别

    2024-01-09 20:46:02       59 阅读
  4. beego框架编写食品溯源区块链后端

    2024-01-09 20:46:02       46 阅读
  5. 神经网络中的梯度爆炸

    2024-01-09 20:46:02       59 阅读
  6. Golang语言switch case

    2024-01-09 20:46:02       65 阅读
  7. 【XDOJ】C语言期末真题带练及思路分析

    2024-01-09 20:46:02       51 阅读
  8. mybatisplus Invalid bound statement (not found)

    2024-01-09 20:46:02       54 阅读
  9. docker 支持 gpu

    2024-01-09 20:46:02       64 阅读
  10. Vue使用vue-img-cropper实现图片裁剪

    2024-01-09 20:46:02       61 阅读