Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #66786 > unrolled thread

Re: Function and turtle help

Started byScott W Dunning <swdunning@cox.net>
First post2014-02-20 22:27 -0700
Last post2014-02-20 22:27 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Function and turtle help Scott W Dunning <swdunning@cox.net> - 2014-02-20 22:27 -0700

#66786 — Re: Function and turtle help

FromScott W Dunning <swdunning@cox.net>
Date2014-02-20 22:27 -0700
SubjectRe: Function and turtle help
Message-ID<mailman.7206.1392960474.18130.python-list@python.org>
On Feb 20, 2014, at 9:41 PM, Scott W Dunning <swdunning@cox.net> wrote:

> Hello,
> 
> I am trying to make a function that allows me to color in a star that was drawn in Turtle.  I just keep having trouble no matter what I do.  I’ll post the code I have for the star (just in case).  The ultimate goal is to create a script that’ll draw the American flag (we’re learning this piece by piece in class.  So, I need to create a function that will color in the star that I can call multiple times for each star.  Any help is greatly appreciated!
> 
> Scott
> 
> from turtle import *
> from math import sin, sqrt, radians
> 
> showturtle()
> def star(width):
>    R = (width)/2*sin(radians(72))
>    A = (2*width)/(3+sqrt(5))
>    penup()
>    left(18)
>    penup()
>    forward(R)
>    pendown()
> 
>    left(162)
>    forward(A)
>    right(72)
>    forward(A)
> 
>    left(144)
>    forward(A)
>    right(72)
>    forward(A)
> 
>    left(144)
>    forward(A)
>    right(72)
>    forward(A)
> 
>    left(144)
>    forward(A)
>    right(72)
>    forward(A)
> 
>    left(144)
>    forward(A)
>    right(72)
>    forward(A)
> 
>    penup()
>    left(180-18)
>    penup()
>    forward(R)
>    penup()
>    left(180-18)
>    pendown()
> showturtle()
> star(500)

I think I’m having trouble with how functions operate.  Here is what I have so far for the function to fill in the star with the color red.  It’s obviously not working and not sure where I’m going wrong. 

def fill_color(color):
    color(red)
    begin_fill()
    penup()
    end_fill()

fill_color(red)

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web