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 draw SpongeBob Image by Python

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is about how Python draws SpongeBob images. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Tool use

Development tool: pycharm

Development environment: python3.7, Windows10

Use the toolkit: turtle

Analysis of project ideas

1. Define the basic configuration of turtle. Determine the height of the frame and the size of the brush, as well as the corresponding frame title and the speed at which the brush runs.

Screensize (800,600, 'white') pensize (3) title (' SpongeBob') speed (19)

2. First adjust the brush position to find the corresponding origin position.

Def go_to (x, y): penup () goto (x, y) pendown () go_to (0,0)

3. Draw SpongeBob's body parts step by step.

Draw SpongeBob's head sponge, select the corresponding width, coordinate size can adjust the positioning function can be reused, SpongeBob is surrounded by wave lines, add the corresponding Radian, add yellow.

Def head (): go_to (- 200,180) fillcolor ('yellow') begin_fill () seth (- 30) for _ in range (6): circle (36,60) circle (- 36 60) seth (- 125i) for _ in range (5): circle (40LINE60) circle (- 40LINE60) seth (- 210C) for _ in range (4): circle (45LING 60) circle (- 45LING 60) seth (65) for _ in range (5): circle (40LINE60) circle (- 40LINE60) end_fill ()

Add facial expressions to SpongeBob, the data of the eyes are mostly arcs, and the size of the nose for small barbs can be adjusted by yourself.

Def eye (): # White go_to (14,-5) fillcolor ('# f0f0f0') begin_fill () circle (65 End_fill () begin_fill () go_to (13 black' 12) seth (98) circle (- 65360) end_fill () # eyeball go_to (- 10 Magneto 20) fillcolor ('blue') begin_fill () circle (20360) end_fill () go_to (- 22 black') begin_fill () circle (7360) end_ Fill () go_to (40, 15) fillcolor ('blue') begin_fill () circle (- 20) End_fill () go_to (53) 15) fillcolor ('black') begin_fill () circle (- 7360) end_fill () # eyelash go_to (- 95) 65) left (20) forward (40) go_to (- 50) 87) right (25) forward (32) go_to (0J70) right (25) forward (40) go_to (40) 75) left (35) forward (40) go_to (90,87) right (18) forward (30) go_to (120,70) right (25) forward (40) def nose (): fillcolor ('yellow') go_to (0,-7) begin_fill () right (50) circle (- 60,30) color (' yellow') goto (15) -40) end_fill () color ('black') go_to (0) seth (- 75) forward (30) go_to (30)

After completing the face, begin to improve some of the structure of the body to add a small white shirt and SpongeBob's arms.

Def body (): go_to (- 170) seth 180) circle (- 150) 30) seth (0) forward (40) seth (100) forward (35) seth (- 80) forward ('brown') begin_fill () seth (0) forward (300) seth (80) forward (10) seth (- 100) forward (65) seth (180) forward (315) go_to (- 118) go_to () Fillcolor ('yellow') begin_fill () seth (- 75) forward (80) seth (0) forward (17) seth (105) forward (85) end_fill () go_to Seth (- 60) circle (- 150) seth (- 180) forward (45) begin_fill () seth (0) forward (20) seth (- 100) forward (85) seth (20) forward (20) end_fill ()

The last step is to add SpongeBob's red scarf.

Def tie (): go_to (- 50) forward (40) forward (30) forward (52) go_to (30) seth (- 30) forward (40) seth (40) forward (45) fillcolor ('red') go_to (0) -240,240) begin_fill () seth (- 60) forward (10) seth (0) forward (30) seth (60) forward (15) go_to (30) end_fill () go_to (4) Begin_fill () seth (- 100) forward (80) seth (0) forward (55) seth (100) forward (80) end_fill () Thank you for reading! This is the end of the article on "how to draw SpongeBob Image by Python". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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