From 6966760b2b5dcce1bd5cc40a6c2a15b2b9aacda8 Mon Sep 17 00:00:00 2001 From: angelotr Date: Sun, 5 Oct 2025 17:35:20 -0400 Subject: [PATCH] My third commit will consist of my third round of changes. What has changed during my third commit were my functions. In this attempt I was given feedback to consider how can I add more parameters or loops to my existing code. I did both by adding customizable parameters to allow a house and sun of any color. I also added a for loop that gives me three houses of different color instead of one. What got me stuck in the beginning was how can I add more parameters or loops to my existing code. What I figured out was that by adding more parameters and loops to my existing code I would be able to create a drawing that would give me three house and a sun with customizable color of my choosing. A strategy I used to get unstuck was to continue using ideas from previous lessons about parameters and trial and error to see where things went right and wrong. What I wonder is how can I use super turtle to create an animated sun. What I want to learn more about is how to properly use super turtle. Since I have more houses and sun with customizable color my future project idea could be to create three houses and a sun with customizable coloring but this time using super turtle to creaete an animated rising sun. --- .commit_template | 5 +- __pycache__/shapes.cpython-313.pyc | Bin 2103 -> 2497 bytes drawing.py | 75 +++++++++++++++++++---------- shapes.py | 59 +++++++++++++---------- 4 files changed, 85 insertions(+), 54 deletions(-) diff --git a/.commit_template b/.commit_template index ca9c82f..10d50da 100644 --- a/.commit_template +++ b/.commit_template @@ -1,7 +1,6 @@ -My second commit will consist of my second round of changes. What has changed is -my functions in drawing.py and shapes.py have been updated to show a house and sun. +My third commit will consist of my third round of changes. What has changed during my third commit were my functions. In this attempt I was given feedback to consider how can I add more parameters or loops to my existing code. I did both by adding customizable parameters to allow a house and sun of any color. I also added a for loop that gives me three houses of different color instead of one. -What got me stuck in the beginning is figuring out where to begin. It was an easy fix because I used the previous assignments to help me with making shapes using various parameters. I figured out that the previous lessons still prove to be a great help to look back at when stuck. I was specifically stuck with the animation of the sun rising. A different method was used to create a rising sun but was outside of the realm of super turtle which ultimately had me back track. It took longer to try and learn animation with super turtle so I reached out to my professor and decided I will continue with my house but the sun will be stationary rather than rising. Something I want to learn more about is animating using super turtle. An idea for a future project will be to create a house and a rising sun using the tools of super turtle. +What got me stuck in the beginning was how can I add more parameters or loops to my existing code. What I figured out was that by adding more parameters and loops to my existing code I would be able to create a drawing that would give me three house and a sun with customizable color of my choosing. A strategy I used to get unstuck was to continue using ideas from previous lessons about parameters and trial and error to see where things went right and wrong. What I wonder is how can I use super turtle to create an animated sun. What I want to learn more about is how to properly use super turtle. Since I have more houses and sun with customizable color my future project idea could be to create three houses and a sun with customizable coloring but this time using super turtle to creaete an animated rising sun. # ----------------------------------------------------------------- # Write your entire commit message above this line. diff --git a/__pycache__/shapes.cpython-313.pyc b/__pycache__/shapes.cpython-313.pyc index 44185554f307d7cb308d1577fe1b3a5936a67652..db7586d44dd41a3e2d2f179f7d209ccef9df88a7 100644 GIT binary patch literal 2497 zcmeH}OOMk?5Xal`BhF+T9>Zf8(5@GRARLHBTK2T!G(3hCIZPC3wHzYj^dx3Hb|^b! z;k2A~BJs$D4>8|_50C>g2oQUk8z{h;s&UF&QO@4H()cOe-ySzSJxOk2M&il^1PT3w!qXKU)NY3yD|hD>%NpU&2# zbkzd8dYUm$!QBh#Y<91Y<1ibxR?KEnuQrkI^)rkW*=Knl5P2JEbav0OYRN6RtlT@Z z0#?to%;0v{0&e!4ux2HErMZ;rtH0#+|>=RJZeyDh8th1;p;$P2O_6 z1`R|iSYC@q`E?(97BsQ%wAx{$bFV1^w$(`Pa4%8<=N<=oJCPz5N{xWtq)9DWtJDJy zL522m{Sdh8@}RQ9gN@MdR5q;*$7?kx--hisd1bR_FIT#r6E0Ue;NRkQ*l6OTVNfM# zTOA&p@7#@wG}MTn6%OH1^i)9u%|Gn5lK*%0{^}MVDu-U?i_i4pW20{jnnV3K`K5ko zs4u=S4i1(d{kbL4P_bVetPJ&I^bP;Ld>dYJzt5?6aeNEv4K(DI`8rrf3`|uX2J*OGABdyJeV1X)N0t^nK2`EyqYQh3Vmjqqo<6sE~ z_fy~1psYhWtcfd!bKy zUmq+?*QYNzp(mni^c2lheVY6=?{V2gbr=^;Od)BXmB#GESQY-KlxBL@lJE~gZd~we z2kfs&Lba^!`jC+puMr=xti%eTfz@=nK_(3W2|KAm{7vJElPo-iQ|IssR?y5S2+y!A zUAup6>&{R)l9Z*atccH6&PD1?*RnS-b(tqFdn_ZV* n1pN2F=)X^J0?k`llBDO%c(2V#N8c~bqd9@zhecgFDpr32iE^ls literal 2103 zcmeHI%}*0S6o1?9Zog6aFkp;nM8saKBoHsglLm~DM4B3+hi2I>?ZVR5x7$=b$w`_Z za^YVv;s4=4M&m(GBpxtD&%QU^cA=(52uCN`H*aR%yf-uN_kP<-rQ$$sDD<_AVSsNu z=(Lcpw5CbffgI$N$AFO2bD=A+qM$-rSZX2CRH=nY)1;=BluYD+UCf)R?}H0lpqtHKj6zBJSVZM3(c%LRTS|h zt7KOS%eLbP4UJ045|QO9HViD%*e;bl5w$8sX|Ssa#S^M)zp;>SB2>9eDY$&=G&ix3 z&AS%5S@z^qJ+vIha-sOL`$$3i*7ccx1XNYWS%hM6J3;orkELBr{DwWP zhr*Tlj2b+(&`ldnss?^yT99?6qfxZ$ZctDz6ByT0`_TkSGOXKvpcS-awBj(t- z^|_5_d+M;yu>oVsm(7HPw&WP*s(_3pbgzycor|ejmMU^`k)!Q`v~Qm!dT*^-tUK0y koTMfGTe??C9EKG|`2?vWHL8pp4aZ50lJ;|0S4QOS-+HA*ZU6uP diff --git a/drawing.py b/drawing.py index ca1f815..ace05c0 100644 --- a/drawing.py +++ b/drawing.py @@ -1,61 +1,84 @@ # drawing.py # ---------- -# By ____(you)___________ +# By Angelo Trelles # -# (Briefly describe what this program does.) +# This program allows me to create a drawing of a house and a sun. The code is split +# into two files for organization. Shapes.py contains functions to draw basic shapes +# such as squares, rectangles, trianlges, and circles. Each function includes +# options for size, outline color, and fill color so they can be reused in +# different ways. The second file, drawing.py, uses the functions to draw a complete +# scene that includes a house with a roof, windows, and a door, along with a sun +# in the corner. The project shows how to use functions, loops, and parameters to +# make drawings customizable. import turtle from shapes import draw_square, draw_triangle, draw_rectangle, draw_circle # setup screen = turtle.Screen() -screen.setup(width=800, height=600) +screen.setup(width=1000, height=600) screen.bgcolor("skyblue") pen = turtle.Turtle() pen.speed(0) pen.hideturtle() -# draw house -def draw_house(): - # house base +# first house with color options +def draw_house(x, base_color="lightgrey", roof_color="brown", door_color="darkred", window_color="lightblue"): + # base position pen.penup() - pen.goto(-100, -200) + pen.goto(x, -200) pen.pendown() - draw_square(pen, 200, color="black", fill="lightgrey") + draw_square(pen, 200, color="black", fill=base_color) - # roof (lowered) + # roof pen.penup() - pen.goto(-100, -200) + pen.goto(x, -200) pen.pendown() - draw_triangle(pen, 200, color="black", fill="brown") + draw_triangle(pen, 200, color="black", fill=roof_color) # door pen.penup() - pen.goto(-30, -200) + pen.goto(x + 70, -200) pen.pendown() - draw_rectangle(pen, 60, 100, color="black", fill="darkred") + draw_rectangle(pen, 60, 100, color="black", fill=door_color) - # windows (lowered) + # windows (left and right) pen.penup() - pen.goto(-80, -210) + pen.goto(x + 20, -210) pen.pendown() - draw_square(pen, 40, color="black", fill="lightblue") + draw_square(pen, 40, color="black", fill=window_color) pen.penup() - pen.goto(40, -210) + pen.goto(x + 140, -210) pen.pendown() - draw_square(pen, 40, color="black", fill="lightblue") + draw_square(pen, 40, color="black", fill=window_color) -# draw sun (stationary) -def draw_sun(): +# draw stationary sun +def draw_sun(x=300, y=180, sun_color="yellow"): pen.penup() - pen.goto(250, 180) # top-right corner + pen.goto(x, y) pen.pendown() - draw_circle(pen, 50, color="black", fill="yellow") + draw_circle(pen, 50, color="black", fill=sun_color) -# main -draw_house() -draw_sun() +# --- main scene --- +def main(): + # draw the sun (customizable color) + draw_sun(sun_color="yellow") -turtle.done() \ No newline at end of file + # a loop to draw multiple houses with different colors (customizable color options) + colors = [ + ("lightgrey", "brown", "darkred", "lightblue"), + ("lightyellow", "red", "blue", "white"), + ("lightgreen", "purple", "darkblue", "yellow") + ] + + x_position = -400 + for base, roof, door, window in colors: + draw_house(x_position, base, roof, door, window) + x_position += 300 + + turtle.done() + +# to run program +main() \ No newline at end of file diff --git a/shapes.py b/shapes.py index 7c23fd3..6f042b1 100644 --- a/shapes.py +++ b/shapes.py @@ -1,41 +1,50 @@ import turtle -def draw_square(t, size, color="black", fill=""): - t.color(color, fill) + +def draw_square(pen, size, color="black", fill=None): + """Draw a square with optional fill color.""" + pen.color(color) if fill: - t.begin_fill() + pen.fillcolor(fill) + pen.begin_fill() for _ in range(4): - t.forward(size) - t.right(90) + pen.forward(size) + pen.right(90) if fill: - t.end_fill() + pen.end_fill() -def draw_rectangle(t, width, height, color="black", fill=""): - t.color(color, fill) +def draw_rectangle(pen, width, height, color="black", fill=None): + """Draw a rectangle with optional fill color.""" + pen.color(color) if fill: - t.begin_fill() + pen.fillcolor(fill) + pen.begin_fill() for _ in range(2): - t.forward(width) - t.right(90) - t.forward(height) - t.right(90) + pen.forward(width) + pen.right(90) + pen.forward(height) + pen.right(90) if fill: - t.end_fill() + pen.end_fill() -def draw_triangle(t, size, color="black", fill=""): - t.color(color, fill) +def draw_triangle(pen, size, color="black", fill=None): + """Draw an equilateral triangle with optional fill color.""" + pen.color(color) if fill: - t.begin_fill() + pen.fillcolor(fill) + pen.begin_fill() for _ in range(3): - t.forward(size) - t.left(120) + pen.forward(size) + pen.left(120) if fill: - t.end_fill() + pen.end_fill() -def draw_circle(t, radius, color="black", fill=""): - t.color(color, fill) +def draw_circle(pen, radius, color="black", fill=None): + """Draw a circle with optional fill color.""" + pen.color(color) if fill: - t.begin_fill() - t.circle(radius) + pen.fillcolor(fill) + pen.begin_fill() + pen.circle(radius) if fill: - t.end_fill() \ No newline at end of file + pen.end_fill() \ No newline at end of file