User:Inge Hoonte/turtle: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with " b = random.randint(0, 55) h = random.randint(10,100) def building-straight(h): pd() fd(10); lt(90) fd(h); lt(90) fd(10); lt(90) fd(h); lt(90) # styles is a python ...")
 
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Prototyping]]
[[Category:Turtle Graphics]]


 
def building-straight(h):
b = random.randint(0, 55)
h = random.randint(10,100)
 
def building-straight(h):
   pd()
   pd()
   fd(10); lt(90)
   fd(10); lt(90)
Line 11: Line 9:
   fd(h); lt(90)
   fd(h); lt(90)
   # styles is a python dictionary
   # styles is a python dictionary
  r = random.randint(0, 255)
   styles['fill'] = rgb(r,r,r)
   styles['fill'] = rgb(r,r,r)
   pu()
   pu()
 
import random
import random
 
def building-angle(h)
def building-angle(h)
   pd()
   pd()
   lt(45)
   lt(45)
Line 24: Line 21:
   fd(8); lt(45)
   fd(8); lt(45)
   fd(h); lt(45)
   fd(h); lt(45)
  b = random.randint(0, 55)
  r = random.randint(0, 255)
   styles['fill'] = rgb(b,r,b)
   styles['fill'] = rgb(b,r,b)
   pu()  
   pu()  
 
def block-straight():
def block-straight():
   startgroup()
   startgroup()
   for i in range(10):
   for i in range(10):
Line 33: Line 32:
     fd(10)
     fd(10)
   endgroup()
   endgroup()
 
def block-angle():
def block-angle():
   startgroup()
   startgroup()
   for i in range(10):
   for i in range(10):
     building-angle(random.randomint(10,100))
     building-angle(random.randomint(10,100))
   endgroup()
   endgroup()
 
def block():
def block():
   startgroup()
   startgroup()
   for i in range(2):
   for i in range(2):
Line 46: Line 45:
     block-angle(1)
     block-angle(1)
   endgroup()
   endgroup()
 
block()
block()
 
#goto(300, 200)
#goto(300, 200)
#face(0)
#face(0)
#building-straight(100)
#building-straight(100)
#goto(300, 400)
#goto(300, 400)
#face(0)

Latest revision as of 12:41, 14 June 2011


def building-straight(h):
 pd()
 fd(10); lt(90)
 fd(h); lt(90)
 fd(10); lt(90)
 fd(h); lt(90)
 # styles is a python dictionary
 styles['fill'] = rgb(r,r,r)
 pu()

import random

def building-angle(h)
 pd()
 lt(45)
 fd(8); lt(45)
 fd(h); lt(45)
 fd(8); lt(45)
 fd(h); lt(45)
 b = random.randint(0, 55)
 r = random.randint(0, 255)
 styles['fill'] = rgb(b,r,b)
 pu() 

def block-straight():
 startgroup()
 for i in range(10):
   building-straight(random.randint(10, 100))
   fd(10)
 endgroup()

def block-angle():
 startgroup()
 for i in range(10):
   building-angle(random.randomint(10,100))
 endgroup()

def block():
 startgroup()
 for i in range(2):
   block-straight(1)
   block-angle(1)
 endgroup()

block()

#goto(300, 200)
#face(0)
#building-straight(100)
#goto(300, 400)