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. 试图从目录中执行 CGI、ISAPI 或其他可执行程序

    首先来看我遇到问题时的情况,直接上图!   从上图的错误提示信息可以看出,是权限不够,被拒绝访问,开始我以为是我的程序的php程序的原因,但是其他站点没事啊,就对这个站点的权限重新分配了下,给了最高权 ...

  2. 【转载】 tf.Print() (------------ tensorflow中的print函数)

    原文地址: https://blog.csdn.net/weixin_36670529/article/details/100191674 ------------------------------ ...

  3. 【翻译】Flink Table Api & SQL — SQL客户端Beta 版

    本文翻译自官网:SQL Client Beta  https://ci.apache.org/projects/flink/flink-docs-release-1.9/dev/table/sqlCl ...

  4. Delphi根据不同分隔符获取字符串内容

    function GetFieldValue(separator:Char;strLine: string; nNum: Integer): string; var Strs :TStrings; R ...

  5. eclipse 中的注释 快捷键 多行注释快捷键 单行注释快捷键

    本文链接:https://blog.csdn.net/a0701302/article/details/76177244 Eclipse 中的两种注释方法: (1)多行注释 (2)单行注释 一. 多行 ...

  6. Visual Studio + Qt:GetVarsFromMakefile任务意外失败

    问题: IntelliSense报告找不到头文件: 编译时报告GetVarsFromMakefile任务意外失败. 解决: 删除从Visual Studio装的Qt插件: 从Qt官网下载最新的插件:h ...

  7. linq to entity group by 时间

    CreationTime是DateTime类型 group by 年/月/日/小时 group by 年 (from d in YourData.OrderBy(x => x.CreationT ...

  8. 二级C语言模拟试题(第1套)

    1. 选择题. 1-1,判断各种变量所占的字节数. #include<stdio.h> int main() { char p[] = {'6','2','3'}, *q = p; int ...

  9. (CSDN 迁移) jFinal找不到或无法加载主类

    错误: 找不到或无法加载主类 com.demo.common.DemoConfig 项目上右键 -> Build Path -> Order and Export 修改顺序: 从上到下依次 ...

  10. 修改IP地址之后认证信息问题

    $ ssh lvph@172.16.20.20 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOT ...