Use python to draw windmill specific code, use python to draw simple windmill

Hello everyone, the editor will answer the following questions for you, how to write homework with python six-color windmill code, how to write with python six-color windmill code, let us take a look now!

 

There is a very famous drawing library in python, which is:

turtle

The turtle library is a very popular function library for drawing images in the Python language. Imagine a little turtle, starting at the origin of a coordinate system with x on the horizontal axis and y on the vertical axis, starting at (0,0), it uses a set of functions to The command's control moves in this plane coordinate system, thus drawing graphics on the path it crawls.

install library

pip install turtle

combat

Use python to draw a big windmill, just use this library to achieve;

The main code is as follows:

import turtle
#画一个扇叶
def draw_sector(col1,col2):  
    turtle.color(col1,col1)
    turtle.circle(30,90)
    turtle.right(90)
    turtle.begin_fill()
    turtle.fd(120)
    turtle.right(90)
    turtle.fd(150)
    turtle.right(135)
    turtle.fd(150*(1.414)-30)
    turtle.end_fill()
    
    turtle.color(col2,col2)
    turtle.begin_fill()
    turtle.right(90)
    turtle.circle(30,90)
    turtle.right(90)
    turtle.fd(75*1.414-30)
    turtle.right(90)       
    turtle.fd(150/1.414)
    turtle.right(135)
    turtle.fd(120)
    turtle.end_fill()
    turtle.ri

Guess you like

Origin blog.csdn.net/mynote/article/details/132404927