1. 程式人生 > >turtle

turtle

gin img port 1-1 logs gree image .com bgcolor

畫一組同切圓

輸入

import turtle


turtle.color(red)
turtle.circle(30)
turtle.circle(60)
turtle.circle(90)
turtle.circle(120)
turtle.circle(150)
turtle.circle(180)
turtle.hideturtle()

輸出

技術分享

畫一組同心圓

輸入

import turtle

turtle.pos()

turtle.color(red)
turtle.begin_fill()
turtle.up()
turtle.goto(0,-10)
turtle.down()
turtle.circle(
10) turtle.color(orange) turtle.up() turtle.goto(0,-30) turtle.down() turtle.circle(30) turtle.color(yellow) turtle.up() turtle.goto(0,-60) turtle.down() turtle.circle(60) turtle.color(green) turtle.up() turtle.goto(0,-90) turtle.down() turtle.circle(90) turtle.color(blue) turtle.up() turtle.goto(0,
-120) turtle.down() turtle.circle(120) turtle.color(purple) turtle.up() turtle.goto(0,-150) turtle.down() turtle.circle(150) turtle.color(pink) turtle.up() turtle.goto(0,-180) turtle.down() turtle.circle(180)

輸出

技術分享

畫一個五角星

輸入

import turtle

turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(
144) turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.right(144) turtle.forward(100) turtle.right(144) turtle.hideturtle()

輸出

技術分享

畫一個黃色實心五角星

輸入

import turtle
turtle.color(yellow)
turtle.fillcolor(yellow)
turtle.begin_fill()
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
turtle.hideturtle()

輸出

技術分享

畫左上角的五顆五角星

import turtle

turtle.bgcolor(red)
turtle.speed(100)
turtle.pos()
turtle.up()
turtle.goto(-400,200)
turtle.color(yellow)
turtle.fillcolor(yellow)
turtle.begin_fill()
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
turtle.down()

turtle.up()
turtle.goto(-270,320)
turtle.color(yellow)
turtle.fillcolor(yellow)
turtle.begin_fill()
turtle.right(45)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.end_fill()
turtle.down()

turtle.up()
turtle.goto(-200,210)
turtle.color(yellow)
turtle.fillcolor(yellow)
turtle.begin_fill()
turtle.right(160)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.end_fill()
turtle.down()

turtle.up()
turtle.goto(-190,130)
turtle.color(yellow)
turtle.fillcolor(yellow)
turtle.begin_fill()
turtle.left(0)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.end_fill()
turtle.down()

turtle.up()
turtle.goto(-250,60)
turtle.color(yellow)
turtle.fillcolor(yellow)
turtle.begin_fill()
turtle.right(20)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.forward(50)
turtle.right(144)
turtle.end_fill()
turtle.down()

turtle.hideturtle()

輸出

技術分享

turtle