###### tags: `Python` `code` # 12/23 機器人組-turtle ## Replit [Sign up](https://replit.com/) :::success - 線上集成開發環境服務 ( Online IDEs ) - 可以共編 - 不用另外安裝套件 ( Replit會自己偵測引用了甚麼套件 -> 自動安裝 ) ::: ### 簡單操作 - 可以 +file 或 +folder 來整理程式 - 執行按 `Run` - `Output` 是拿來看畫圖成果的 - `Console` 可以看程式是否正常執行 --- ## 畫圖turtle :::success - Python 內建套件 - 拿來畫畫ㄉ - 反正就是趣味性的小工具 ::: 建立Project - `+create`:先開一個新的replit - `Search Template`:搜尋python with turtle - `Title`:Project的名字,可以叫 `myturtle` 然後就會看到這個 ```python= """ This is the Template Repl for Python with Turtle. Python with Turtle lets you make graphics easily in Python. Check out the official docs here: https://docs.python.org/3/library/turtle.html """ import turtle t = turtle.Turtle() for c in ['red', 'green', 'blue', 'yellow']: t.color(c) t.forward(75) t.left(90) ``` ### 基本款 那我們來分析一下吧~ ```python= # 將套件 import進來使用,*表示全部 from turtle import * # 設定背景顏色,S要記得大寫!! Screen().bgcolor('#34d57f') # 設定筆畫粗細 pensize(2) # 設定筆畫顏色 color('black') # 前進! forward(20) ``` ### 一些些例子 #### 封閉圖形 [Citation](https://ithelp.ithome.com.tw/articles/10297642?sc=iThelpR) ```python= color('blue', 'red') begin_fill() circle(30) end_fill() ``` #### 畫愛心 >大家可以去追蹤這個 [instagram帳號](https://www.instagram.com/pythonlearnerr/) 有不少python的東東,也很常出turtle的影片 我會想要教turtle也是因為這個帳號喔~ ```python= from turtle import * color('red') begin_fill() pensize(3) left(50) forward(133) circle(50, extent=200) right(140) circle(50, extent=200) forward(133) end_fill() ``` >基本上這些參數都是一筆一筆試出來的,要很有耐心喔 >別忘了可以結合function和for-loops等幫助畫圖 --- 以上,有問題找程教林文繡 #### Citation [IT邦 turtle](https://ithelp.ithome.com.tw/articles/10297642?sc=iThelpR) [turtle circle](https://www.geeksforgeeks.org/turtle-circle-method-in-python/) [turtle example](https://www.instagram.com/pythonlearnerr/)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up