import turtle
import time
import os #
def draw_square(org_x, org_y, x, y):
turtle.setpos(org_x, org_y) # to left and bottom connor
turtle.color('red', 'red')
turtle.begin_fill()
turtle.fd(x)
turtle.lt(90)
turtle.fd(y)
turtle.lt(90)
turtle.fd(x)
# print(turtle.pos())
turtle.lt(90)
turtle.fd(y)
turtle.end_fill() def draw_star(center_x, center_y, radius):
print(center_x, center_y)
turtle.pencolor('black')
turtle.setpos(center_x, center_y)
pt1 = turtle.pos()
turtle.circle(-radius, 360 / 5)
pt2 = turtle.pos()
turtle.circle(-radius, 360 / 5)
pt3 = turtle.pos()
turtle.circle(-radius, 360 / 5)
pt4 = turtle.pos()
turtle.circle(-radius, 360 / 5)
pt5 = turtle.pos()
turtle.color('yellow', 'yellow')
turtle.begin_fill()
turtle.goto(pt3)
turtle.goto(pt1)
turtle.goto(pt4)
turtle.goto(pt2)
turtle.goto(pt5)
turtle.end_fill() print(turtle.pos()) turtle.pu()
draw_square(-320, -260, 660, 440)
star_part_x = -320
star_part_y = -260 + 440
star_part_s = 660 / 30
center_x, center_y = star_part_x + star_part_s * 5, star_part_y - star_part_s * 5
turtle.setpos(center_x, center_y) # big star center
turtle.lt(90)
draw_star(star_part_x + star_part_s * 5, star_part_y - star_part_s * 2, star_part_s * 3) # draw 1st small star
turtle.goto(star_part_x + star_part_s * 10, star_part_y - star_part_s * 2) # go to 1st small star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s) # draw 2nd small star
turtle.goto(star_part_x + star_part_s * 12, star_part_y - star_part_s * 4) # go to 1st small star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s) # draw 3rd small star
turtle.goto(star_part_x + star_part_s * 12, star_part_y - star_part_s * 7) # go to 1st small star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s) # draw 4th small star
turtle.goto(star_part_x + star_part_s * 10, star_part_y - star_part_s * 9) # go to 1st small star center
turtle.lt(round(turtle.towards(center_x, center_y)) - turtle.heading())
turtle.fd(star_part_s)
turtle.rt(90)
draw_star(turtle.xcor(), turtle.ycor(), star_part_s)
turtle.ht()
time.sleep(5)
os._exit(1)

3.用Python画五角星的更多相关文章

  1. 【Python】【demo实验29】【练习实例】【使用turtle画五角星】

    原题: 使用turtle画五角星: 我的代码: #!/usr/bin/python # encoding=utf-8 # -*- coding: UTF-8 -*- from turtle impor ...

  2. 沉淀再出发:用python画各种图表

    沉淀再出发:用python画各种图表 一.前言 最近需要用python来做一些统计和画图,因此做一些笔记. 二.python画各种图表 2.1.使用turtle来画图 import turtle as ...

  3. python画樱花

    用python画简单的樱花 代码如下: import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, t): ...

  4. python 画小猪佩奇

    转自:python画个小猪佩奇 # -*- coding: utf-8 -*- """ Created on Mon May 20 11:36:03 2019 @auth ...

  5. 用python画 pareto front

    用python画 pareto front 觉得有用的话,欢迎一起讨论相互学习~Follow Me 2D pf import os import matplotlib.pyplot as plt im ...

  6. python 画3D的高斯曲线

    用python画3D的高斯曲线,我想如果有多个峰怎么画? import numpy as npimport matplotlib.pyplot as pltimport mathimport mpl_ ...

  7. CSS3画五角星和六角星

    最终想要实现的效果 一.五角星 在画五角星之前首先分析这个五角星是如何实现,由哪几个部分构成的,示意图如下: 三个顶角向上的三角形,通过设置旋转和定位相互重叠和拼接实现最终的五角星效果. 为了语义化和 ...

  8. python画一只佩奇

    用python画一只佩奇 from turtle import* def nose(x,y):#鼻子 penup()#提起笔 goto(x,y)#定位 pendown()#落笔,开始画 sethead ...

  9. 利用python画出动态高优先权优先调度

    之前写过一个文章. 利用python画出SJF调度图 动态高度优先权优先调度 动态优先权调度算法,以就绪队列中各个进程的优先权作为进程调度的依据.各个进程的优先权在创建进程时所赋予,随着进程的推进或其 ...

随机推荐

  1. centos 7 U盘 uefi 模式装机

    公司买了一台新的dell机器,因为装的是window ,所以想给改成Centos 的做服务器,但是问题来了,一上来装好,就完全进入不了引导系统,换了ubuntu 有一次意外装上了,但一直是什么原因,然 ...

  2. Ubuntu 安装最新版 (1.12) Golang 并使用 go mod

    wget https://dl.google.com/go/go1.12.4.linux-amd64.tar.gz sudo tar -zxvf go1.12.4.linux-amd64.tar.gz ...

  3. Sql中substr的使用

    pandas和SQL数据分析实战 https://study.163.com/course/courseMain.htm?courseId=1006383008&share=2&sha ...

  4. cannot connect to daemon at tcp:5037: cannot connect to 127.0.0.1:5037: 由于目标计算机积极拒绝,无法连接。 (10061)

    原因是:5037端口被占用 解决方法:1.查找5037被谁占用   netstat -ano | findstr "3037" 2.查看对应的是哪个任务  tasklist | f ...

  5. Logstash配置以服务方式运行

    Logstash官网最新版下载地址以及YUM源:https://www.elastic.co/cn/downloads/logstash Logstash最常见的运行方式即命令行运行 ./bin/lo ...

  6. JAVA 创建也项目平级文件

    String url = System.getProperty("user.dir") +"/logs/test.txt" File file = new Fi ...

  7. EasyNVR网页摄像机无插件H5、谷歌Chrome直播方案使用过程中问题的自我排查-设备不在线问题自我排查检测

    由于EasyNVR的受众越来越多,时常会遇到很多类似的问题咨询,之前虽然有写过很多的博文进行技术的或者使用问题的解答,随着客户询问的增多,我发现,要想让客户了解问题和解决问题,往往引导和给一个思路比直 ...

  8. go 代码玩耍

    //小游戏 num := rand.Intn() var input int fmt.Println("请输入数字") fmt.Scanf("%d", & ...

  9. UE4 Animation]IK Related

    转自:https://dawnarc.com/2018/05/ue4animationik-related/ Examples 工程1 在油管上看到一个UE4 IK动画的demo工程示例 该示例作者的 ...

  10. solr的创建分片的方式

    在Solr4.4之后,Solr提供了SolrCloud分布式集群的模式,它带来的主要好处是: (1)大数据量下更高的性能 (2)更好扩展性 (3)更高的可靠性 (4)更简单易用 什么时候应该使用Sol ...