# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/mathriddle/ColabTurtlePlus/blob/main/examples/files/fill_example.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + [markdown] id="oOmT6u-jTlI6"
# How to do a fill when you also want to have different colors along the boundary of the object being filled.

# + id="mNDcb4tEl4Xr"
# !pip install ColabTurtlePlus

# + id="fDp3eovimAmy"
import ColabTurtlePlus.Turtle as T

# + [markdown] id="vEnQACygSIB8"
# Here we draw a square with two sides in red and two sides in blue, then a circle drawn in green. When the fill is done, all the sides and the circle are changed to the last pen color, green.

# + id="2loZU_XvmBTa"
T.initializeTurtle((500,500))
T.width(5)
T.fillcolor("yellow")
T.begin_fill()
T.pencolor("red")
T.forward(200)
T.left(90)
T.forward(200)
T.left(90)
T.pencolor("blue")
T.forward(200)
T.left(90)
T.forward(200)
T.pencolor("green")
T.circle(100)
T.end_fill()




# + [markdown] id="_PCoXrtnTHab"
# So to fix this to keep the original side/circle colors, we do the entire drawing first in one color and with the fill, then return to the starting point and initial heading to repeat the drawing with the desired colors.

# + id="JmhOybcMSATq"
T.initializeTurtle((500,500))
init_pos = T.pos()
init_angle = T.heading()
T.width(1)
T.fillcolor("yellow")
T.begin_fill()
T.forward(200)
T.left(90)
T.forward(200)
T.left(90)
T.forward(200)
T.left(90)
T.forward(200)
T.circle(100)
T.end_fill()
T.jumpto(init_pos)
T.setheading(init_angle)
T.width(5)
T.speed(13)
T.pencolor("red")
T.forward(200)
T.left(90)
T.forward(200)
T.left(90)
T.pencolor("blue")
T.forward(200)
T.left(90)
T.forward(200)
T.pencolor("darkgreen")
T.circle(100)

StarcoderdataJupyterScriptsDedupFiltered