> For the complete documentation index, see [llms.txt](https://sharinghub.kittenbot.hk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sharinghub.kittenbot.hk/mcu/futureboard/micropython/api4.md).

# 未來板MicroPython編程4：海龜繪圖

### 導入未來板庫

需要先導入未來板的庫才可以使用未來板的硬件。

```
from future import *
```

### 04: 海龜繪圖類

#### 1. 設置海龜顏色

```
turtle.fillcolor(color)
```

color為RGB數值，0～255。例如(255,100,0)。

#### 2. 海龜前進

```
turtle.forward(steps)
```

steps為前進步數。

#### 3. 海龜左轉／右轉

```
turtle.left(angle)
turtle.right(angle)
```

angle為角度。

#### 4. 海龜設定向前角度

```
turtle.setheading(angle)
```

angle為角度。

#### 5. 海龜移動到某一點

```
turtle.goto(x,y)
```

x，y參數為座標，分別為0\~159和0\~127。

#### 6. 海龜設定座標

```
turtle.setx(x)
turtle.sety(y)
```

x，y參數為座標，分別為0\~159和0\~127。

#### 7. 海龜繪畫點

```
turtle.dot(d)
```

d參數為直徑。

#### 8. 海龜繪畫圓圈

```
turtle.circle(r,angle)
```

r參數為半徑。angle參數為角度，360為之一個完整的圓圈。

#### 9. 海龜設定填充

```
turtle.begin_fill()
turtle.end_fill()

#注意：由於未來板的硬件像素未達到海龜之需求，使用填充可能會有bug，無法正常填充。
```

#### 10. 海龜落筆抬筆

```
turtle.pendown()
turtle.penup()
```

#### 11. 海龜清屏

```
turtle.clear()
```

#### 海龜使用範例

```
from future import *

turtle.clear()
turtle.penup()
turtle.setx(80)
turtle.sety(64)
turtle.pendown()
for i in range(5):
    turtle.forward(40)
    turtle.right(144)
```

[Next ](https://kittenbothk.readthedocs.io/en/latest/futureboard/micropython/api5.html)[ Previous](https://kittenbothk.readthedocs.io/en/latest/futureboard/micropython/api3.html)<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sharinghub.kittenbot.hk/mcu/futureboard/micropython/api4.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
