From 80073316b2b71a9b6251f79fc7f7e146640a7fb4 Mon Sep 17 00:00:00 2001 From: ilmabura Date: Mon, 29 Sep 2025 22:09:26 -0400 Subject: [PATCH] Commit 1: Created a static image of a penguin on an iceberg I was struggling how to draw an oval for my penguin. I needed to look up videos/read up how to do it. I also had to look up how to set the size of the image. I found it really difficult to just start the penguin, but once I got the shapes I felt more comfortable. Commit 2: Created an iteration of penguins Created a function penguins which iterates the drawing of the penguin until the end of the screen. I needed to do some debugging for this to work, I managed to solve it, but I don't know how I fixed the issue. For some strange reason it's drawing the first penguin twice and I don't know why. I need to figure that out. This part was much easier than drawing out the shapes. --- .commit_template | 5 ++ __pycache__/drawing.cpython-312.pyc | Bin 0 -> 4715 bytes drawing.py | 7 ++- penguins.py | 24 ++++++++ shapes.py | 49 ---------------- trial.py | 88 ---------------------------- 6 files changed, 33 insertions(+), 140 deletions(-) create mode 100644 __pycache__/drawing.cpython-312.pyc create mode 100644 penguins.py delete mode 100644 shapes.py delete mode 100644 trial.py diff --git a/.commit_template b/.commit_template index 4f86725..2c39558 100644 --- a/.commit_template +++ b/.commit_template @@ -1,4 +1,9 @@ +Commit 1: Created a static image of a penguin on an iceberg +I was struggling how to draw an oval for my penguin. I needed to look +up videos/read up how to do it. I also had to look up how to set the size of the image. +I found it really difficult to just start the penguin, but once I got the shapes +I felt more comfortable. # ----------------------------------------------------------------- # Write your entire commit message above this line. diff --git a/__pycache__/drawing.cpython-312.pyc b/__pycache__/drawing.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e4df4f223de55fb533482e0780aebcc4faaaa6a4 GIT binary patch literal 4715 zcmb7HYitzP6~1?NX7=Ir+t@rp7~bAs?AWFuN>Lgc3MB!`E2Jz`)_Ct=kJ%S@#@K7E zC0laEZXjV1sW58VIt@}m_(v=C2WtDX>Yx6>iXE9LQd>1Yy8i(4qe`XHb7uB2hIJF} zYR`R~bI-l^-0z%o=P%XO0Rm<7TYnvV2CaW$r&xT2#?r3@LT(U77>$xJ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l6*(jQFLv)rN!~{O_}8 z`k$Twc?#aE&qH_2ySba~+7)>tB-lsc3hXM6@gR@sN*@AgklB3>fB8K)j$iWmSCH%n z0yb-ditj|yjs#(A-F^%Ilh!YStVrv%?^mUGxe23Up zx8uOqzCE!78;)vka|SH1J~0jh1!tyosgBT^zmaWUkZq4-LaQg_OTo!t=47sWp0q6b zn={Q<*JsyX-Y_9A5}S3ux?`Taj-8sx8hE;rmcNVj6ZTG}GhwM%sp-S)VF&|qd?Zgb9< z-ZzuF7g`|ua9cuA%L7tXVvpSOFOc44Z1*CMVO}7!Dbt@jKHWQW?Dhu> q1+r`T2+Ay<2O~Riq!#j9SB`^Y>|Y=|iX+{S?|NrWeM#DEbN>&y7@yz( literal 0 HcmV?d00001 diff --git a/drawing.py b/drawing.py index be73eeb..f819276 100644 --- a/drawing.py +++ b/drawing.py @@ -14,7 +14,7 @@ screen = turtle.Screen() screen.title("Penguin on Ice (with real ovals)") screen.bgcolor("white") -t = turtle.Turtle(visible=False) +t = turtle.Turtle(visible=True) t.speed(0) t.pensize(3) t.pencolor("black") @@ -71,7 +71,7 @@ def right_triangle(ax, ay, leg1, leg2, angle=0, fill=None): # Ocean (bottom half) filled_rect(-500, -60, 500, -300, fill="#3d44c6", outline="#3d44c6") -# Ice block (white with light gray outline) +# Iceberg (white with light gray outline) t.pensize(4) filled_rect(-500, -60, 120, -150, fill="white", outline="#7f7f7f") @@ -102,4 +102,5 @@ right_triangle(70, -60, 35, 15, fill="gold") # beak (92, 60) # feet (70, -60) -input() \ No newline at end of file + + diff --git a/penguins.py b/penguins.py new file mode 100644 index 0000000..71fc7c8 --- /dev/null +++ b/penguins.py @@ -0,0 +1,24 @@ +from drawing import * +from turtle import * +def penguins(ax): + for x in range (ax, -500, -100): + pendown() + # Body (tall oval) + draw_oval(x-60, 10, rx=28, ry=70, tilt=0, fill="black") + # Belly (smaller inner oval) + draw_oval(x-42, 12, rx=12, ry=65, tilt=0,fill="white") + # Arm (middle oval) + draw_oval(x-57, -5, rx=13, ry=30, tilt=0, fill="black") + # Head (circle = oval with equal radii) + draw_oval(x-42, 80, rx=25, ry=25, fill="black") + # Beak (little triangle pointing right) + right_triangle(x-28, 60, 25, 20, fill="gold") + # Feet (two small triangles resting on ice) + right_triangle(x-50, -60, 35, 15, fill="gold") + penup() + + +penguins (120) + + + diff --git a/shapes.py b/shapes.py deleted file mode 100644 index 14538dc..0000000 --- a/shapes.py +++ /dev/null @@ -1,49 +0,0 @@ -import turtle -from math import cos, sin, pi, radians - -def move_to(x, y): - t.penup(); t.goto(x, y); t.pendown() - -def filled_rect(x1, y1, x2, y2, fill, outline="black"): - t.pencolor(outline) - t.fillcolor(fill) - move_to(x1, y1) - t.begin_fill() - t.goto(x2, y1) - t.goto(x2, y2) - t.goto(x1, y2) - t.goto(x1, y1) - t.end_fill() - -def draw_oval(cx, cy, rx, ry, tilt=0, fill=None, steps=180): - """Parametric ellipse; steps controls smoothness.""" - ang = radians(tilt) - def R(x, y): # rotate (x,y) by tilt - return (x*cos(ang) - y*sin(ang), x*sin(ang) + y*cos(ang)) - - t.fillcolor(fill if fill else "") - move_to(cx + rx, cy) # start at angle 0 - if fill: - t.begin_fill() - for i in range(1, steps + 1): - theta = 2*pi*i/steps - x, y = rx*cos(theta), ry*sin(theta) - xr, yr = R(x, y) - t.goto(cx + xr, cy + yr) - if fill: - t.end_fill() - -def poly(points, fill=None): - if fill: t.fillcolor(fill); t.begin_fill() - move_to(*points[0]) - for p in points[1:]: - t.goto(*p) - t.goto(*points[0]) - if fill: t.end_fill() - -def right_triangle(ax, ay, leg1, leg2, angle=0, fill=None): - """Right angle at (ax, ay). leg1 along 'angle' degrees, leg2 perpendicular.""" - a = radians(angle) - B = (ax + leg1*cos(a), ay + leg1*sin(a)) # along angle - C = (ax - leg2*sin(a), ay + leg2*cos(a)) # 90° to the left - poly([(ax, ay), B, C], fill=fill) diff --git a/trial.py b/trial.py deleted file mode 100644 index 1871fa4..0000000 --- a/trial.py +++ /dev/null @@ -1,88 +0,0 @@ -import turtle - -# --- Setup --- -turtle.setup(800, 500) -screen = turtle.Screen() -screen.title("Penguin on Ice") -screen.bgcolor("white") - -pen = turtle.Turtle() -pen.speed(8) -pen.pensize(2) - -# --- Draw ocean --- -pen.penup() -pen.goto(-400, -100) -pen.pendown() -pen.fillcolor("royalblue") -pen.begin_fill() -for _ in range(2): - pen.forward(800) - pen.right(90) - pen.forward(250) - pen.right(90) -pen.end_fill() - -# --- Draw ice block --- -pen.penup() -pen.goto(-400, -100) -pen.pendown() -pen.pencolor("black") -pen.fillcolor("white") -pen.begin_fill() -pen.forward(350) # top edge -pen.right(90) -pen.forward(100) # side edge -pen.right(90) -pen.forward(350) -pen.end_fill() - -# --- Draw penguin body --- -pen.penup() -pen.goto(0, -100) -pen.left(90) -pen.pendown() -pen.circle(40, 180) # big oval side -pen.circle(40, 180) - -# --- Draw penguin belly (smaller oval) --- -pen.penup() -pen.goto(10, -100) -pen.setheading(90) -pen.pendown() -pen.circle(20, 360) - -# --- Draw head --- -pen.penup() -pen.goto(0, -20) -pen.setheading(0) -pen.pendown() -pen.circle(20) - -# --- Draw beak (triangle) --- -pen.penup() -pen.goto(20, -10) -pen.pendown() -pen.setheading(0) -pen.forward(20) -pen.right(120) -pen.forward(20) -pen.right(120) -pen.forward(20) - -# --- Draw feet --- -pen.penup() -pen.goto(-5, -100) -pen.pendown() -pen.setheading(-30) -pen.forward(20) - -pen.penup() -pen.goto(5, -100) -pen.pendown() -pen.setheading(-150) -pen.forward(20) - -# Done -pen.hideturtle() -turtle.done() \ No newline at end of file