Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Turtle Library to draw a Tiger by Python

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how Python uses the Turtle library to draw a tiger. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Introduction

Hello, iron juices. I haven't seen you for a long time. The editor has returned to work, so he came non-stop to prepare New year's gifts for everyone.

Sea turtles come to make pictures.

The year of the Tiger is about drawing tigers.

2022 without paper and pen ~

Draw a tiger tonight.

One, two, three, four, five.

Schematic diagram of baby tiger

How can there be fewer tigers in the year of the Tiger? Draw a lovely tiger with a tiger's head and light it on New year's Eve. Do not need paper and pen, rely on Python sea turtles to draw, children hurry up the code to knock it!

1. Definition library and initialization interface def laohu (): import turtle as t # sets the screen size and color t.screensize (50,50, bg='yellow') t.title ("tiger baby") t.shape ("classic") t.pensize (10) t.color ("orange") t.fillcolor ("pink") t.speed (100) t.hideturtle () 2. Draw the left and right ears # t.penup () t.goto (- 105,97) t.setheading (160,160) t.begin_fill () t.pendown () t.circle (- 30,230) t.setheading (180) t.circle (37,90) t.end_fill () # right ear t.penup () t.goto 97) t.setheading (20) t.begin_fill () t.pendown () t.circle (30,230) t.setheading (0) t.circle (- 37,90) t.end_fill () 3. Draw the outline of the tiger's head # t.penup () t.goto (- 67,140) t.setheading (30) t.pendown () t.circle (- 134,60) t.penup () t.goto (- 50,-25) t.setheading (180) t.pendown () t.circle (- 100,30) t.circle (- 30) 90) t.setheading (100,20) t.penup () t.goto (50,25) t.setheading (0) t.pendown () t.circle (100,30) t.circle (30,90) t.setheading (80) t.circle (200,20) 4. Draw the tiger's two eyes # two tiger eyes # left eye t.penup () t.goto (- 90,25) t.setheading (- 45) t.fillcolor ("orange") t.begin_fill () t.pendown () # Ellipse drawing technique a = 0.2for i in range (120): if 0

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report