From 24a976f129f699809eadede99490cbfd967b8668 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Sep 2024 23:13:39 -0400 Subject: [PATCH] I changed the colors in the list, and I added two more branches on the tree. I noticed that the colors change more slowly as it moves towards the end of the list. I didn't really do much since the last commit a little while ago, I was mainly just tweaking the appearance. --- __pycache__/shapes.cpython-310.pyc | Bin 3216 -> 3249 bytes __pycache__/superturt.cpython-310.pyc | Bin 14234 -> 15029 bytes changingcolors.py | 29 ------------------- drawing.py | 11 ++++---- shapes.py | 39 ++++++++++++-------------- superturt.py | 30 +++++++++++++++++++- 6 files changed, 53 insertions(+), 56 deletions(-) delete mode 100644 changingcolors.py diff --git a/__pycache__/shapes.cpython-310.pyc b/__pycache__/shapes.cpython-310.pyc index 7cacde03218861c3a0e1d0952c3ba0af017fb45e..e6cce4257beee69cdb48225ca55421d3c990f921 100644 GIT binary patch delta 1086 zcmZ`&OKVd>6uxtxb8mXnQoBg1scE$~m!LL}+O+g#10q!7A|Q05w7n>Twr~Lum-Edx=gi}qd(OPho@B#=FboW|W4EK-hi*gcg+i`s+_yvQvoB~tE#r$tItauw*gW>(gMgHZ!>Jn zPZeb_Xlp%*NX*1a>{y&CF&o74sSJpmuD!GWq(l)0nwF^u`o_Bw@)254M$nR~d25A% zo+Sk65+HKv7IR)qiwwM$YU-UgJ6Z$PddFDrvij`(c6m$CFR~z3)F1ij?gl$n7*-k9 z7}f!ieU?qCvR5BkVfJtOXa>G}DhyV|uG$KwXJR`sCJbF6Ci37QA8yA)y}+-%mP&$b z)9Dz4%y^A%KnJatyL524U!@H`ga2kfRnyG!09=-Yz&_+{GsFklE($r)%VoRioW6;FXM;MPlwK=&dDXXp^C??u;y6aHS`GX-Qk#m<&f!e*x^SuF?Pi delta 1006 zcmZ`&O=}ZT6rG#QS0H1!y-9)7jDr& zKZGiM(if=ccqjY3A=HMkfB=*b9*dAj6w48D*XO4DWG$9DS(9L*_nK6x9G2;avEcbk z`!ftS*pQia^r@20Q`4+i7trPs`P4CQuQg=1sF%HXm&uXH`Q3ykxbJcAuhOnLM>%7@ zF3I2>p5t>=XsNevjP*|MxIRt8pLU@lYo23v3BUXlye0 zdgKn3w-gIi&@z2V72p|tPqpAFZ8?>*_`dY`YXr<<6DIyPVQ7xD_JdJ-6F;M)jo<@|zvJ5@CO4kY}5-P(G1#-B!{33S9$gFS5 ryNL2tKd8E?lB?p0i*QMxDzGiEL&ursoNk-8Wv6VNQMa?Un{j>tcNw0^ diff --git a/__pycache__/superturt.cpython-310.pyc b/__pycache__/superturt.cpython-310.pyc index a794c72cadfbe83ce694d0b7c364d8d78a873d86..1c1b1c10218657e84aafe99ada1eb5429a3959d9 100644 GIT binary patch delta 756 zcmZuvOK%e~5MFOk6|IsG=z|nWIw=UUG)+@fS{^qZfdlkHPmvHZu{UeFS*Ny_5Y(!N z&@iVw^>%hQxS5v`CEX@p$|_G?L%T&q+xZi=KnAzw#sadV5-0A`hpl zA2xs$S!qH#mmWLpEGthORvx>ZC01jzY!3UEu|Lliu)l!)DudJ`kEZLDVwEjVoX!x-C-Gj@n$$boY}#x7Q_y)%M*m+m3_nS8@Fn2>`> zl!@?=P=DJP`7jhFl!*bR=upJHrso01ZYVV1Qk+K72wop0+5iPD`U52EP%6_!QXmyX zA}~nI#0NZXKqkC_mmVsxVx3w^qWgJ~Y?Y$jBfziAn(Z#mSI1V7FU-e%@K;t_RhAvH|?8MTE+yS?LIO%J!ekmIzy TeT}rz{`P7<@8%0-QgD9(;xofS delta 143 zcmdm5IxC+qpO=@50SLATd`r7vI+0I?QDvg`Izzb>-W0wT#wclbh7|r3ffj}ofo7&C znH2dH;S>>|xGYdyG(`+3E(R2rOOcz*#pue)6U?Bgu(^a$!c?$G5oo9;OOY9na&z<3 mRG!>xd6rRba-gL!KZi|jeoARhsvRRxvRG?!la)3T4-)_obRrG_ diff --git a/changingcolors.py b/changingcolors.py deleted file mode 100644 index 7b756f7..0000000 --- a/changingcolors.py +++ /dev/null @@ -1,29 +0,0 @@ -from turtle import * -from superturt import * -from shapes import * - -# I'm trying to figure out how to get the leaves to change colors. - -fillcolor('green') -begin_fill() -draw_leaf(20) -end_fill() -save('green.png') - -#fillcolor('yellow') -#begin_fill() -#draw_leaf(20) -#end_fill() -#save('yellow.png') - -#fillcolor('orange') -#begin_fill() -#draw_leaf(20) -#end_fill() -#save('orange.png') - -#fillcolor('red') -#begin_fill() -#draw_leaf(20) -#end_fill() -#save('red.png') \ No newline at end of file diff --git a/drawing.py b/drawing.py index c64440e..df7d816 100644 --- a/drawing.py +++ b/drawing.py @@ -2,17 +2,18 @@ # ---------- # By Stacy S # -# (Drew a tree, and the leaves change colors. Trying to make the leaves fall now?) +# (Drew a tree, and the leaves change colors.) from turtle import * from shapes import * from superturt import * -colors = ['green', 'greenyellow', 'yellow', 'goldenrod', 'darkorange', 'orange', 'orangered', 'red', 'firebrick', 'brown'] +fly(0,-150) + +colors = ['green', 'greenyellow', 'yellow', 'goldenrod', 'darkorange', 'orange', 'orangered', 'red', 'violetred4', 'violetred', 'purple4', 'midnightblue'] for color in colors: with no_delay(): with restore_state_when_finished(): - draw_tree_nl(20) + draw_tree_nl(25) with restore_state_when_finished(): - draw_tree_wl(20, color) - + draw_tree_wl(25, color) \ No newline at end of file diff --git a/shapes.py b/shapes.py index aaf1cb4..567783d 100644 --- a/shapes.py +++ b/shapes.py @@ -21,42 +21,37 @@ def draw_leaves(color): right(115) pendown() -def draw_trunk(size): - forward(10*size) - circle(size/8,90) - def draw_branch_nl(size): - angles = [150, 150, 150, 150, 150, 150, 90] + angles = [165, 150, 150, 150, 150, 150, 150, 165, 105] for angle in angles: branch_end_nl(size) circle(size/8,angle) def draw_branch_wl(size, color): - angles = [150, 150, 150, 150, 150, 150, 90] + angles = [165, 150, 150, 150, 150, 150, 150, 165, 105] for angle in angles: branch_end_wl(size, color) circle(size/8,angle) draw_leaves(color) +def draw_turn(d1,a1,d2,a2,d3,a3,d4): + forward(d1) + right(a1) + forward(d2) + right(a2) + forward(d3) + right(a3) + forward(d4) + def tip_nl(size): - forward(size) - right(45) - forward(size/10) - right(90) - forward(size/10) - right(45) - forward(size) + draw_turn(size,45,size/10,90,size/10,45,size) def tip_wl(size, color): tip_nl(size) draw_leaves(color) def branching_nl(ang1, d1, ang2, d2, ang3): - right(ang1) - forward(d1) - right(ang2) - forward(d2) - right(ang3) + draw_turn(0,ang1,d1,ang2,d2,ang3,0) def branching_wl(ang1, d1, ang2, d2, ang3, color): branching_nl(ang1, d1, ang2, d2, ang3) @@ -92,10 +87,11 @@ def branch_end_nl(size): forward(4*size) def draw_tree_nl(size): - fillcolor('brown') + fillcolor('rosybrown4') begin_fill() circle(size/4,90) - draw_trunk(size) + forward(10*size) + circle(size/8,105) draw_branch_nl(size) forward(10*size) circle(size/4,90) @@ -104,7 +100,8 @@ def draw_tree_nl(size): def draw_tree_wl(size, color): penup() circle(size/4,90) - draw_trunk(size) + forward(10*size) + circle(size/8,105) draw_branch_wl(size, color) forward(10*size) circle(size/4,90) \ No newline at end of file diff --git a/superturt.py b/superturt.py index 8b54ff6..ea3f8d5 100644 --- a/superturt.py +++ b/superturt.py @@ -359,4 +359,32 @@ def save(filename): getcanvas().postscript(file=temp_file) cmd = f"convert {temp_file} -colorspace RGB {filename}" run(cmd, shell=True, check=True) - temp_file.unlink() \ No newline at end of file + temp_file.unlink() + +from turtle import * +from itertools import chain, cycle + +def fly(x,y): + """Moves the turtle to (x,y) without drawing. + + This is really just a simple shortcut for lifting the pen, + going to a position, and putting the pen down again. But it's such + a commonly-used pattern that it makes sense to put it into a function. + Here's an example:: + + from turtle import forward, right + from superturtle.movement import fly + + def square(size): + for side in range(4): + forward(size) + right(90) + + for col in range(10): + for row in range(10): + fly(40 * col, 40 * row) + square(20) + """ + penup() + goto(x,y) + pendown() \ No newline at end of file