diff options
author | James Cameron <quozl@laptop.org> | 2010-06-19 03:26:19 (GMT) |
---|---|---|
committer | James Cameron <quozl@laptop.org> | 2010-06-22 01:38:25 (GMT) |
commit | ce1f461da70a0c43e56eba56128683e644944557 (patch) | |
tree | f6ef8bad92955de3d78190ad32ac3dec64faf63f /data | |
parent | 267d1ae0047edf6720c3c89bda73c22dd81ad4e9 (diff) |
change example to plain text format
Signed-off-by: James Cameron <quozl@laptop.org>
Acked-by: Anish Mangal <anish@sugarlabs.org>
Reviewed-by: Anish Mangal <anish@sugarlabs.org>
Diffstat (limited to 'data')
-rw-r--r-- | data/graphics/tree | 144 |
1 files changed, 72 insertions, 72 deletions
diff --git a/data/graphics/tree b/data/graphics/tree index e01cf8e..6d70ee3 100644 --- a/data/graphics/tree +++ b/data/graphics/tree @@ -1,72 +1,72 @@ -# tree
-
-import pippy, pygame, sys
-from pygame.locals import *
-from random import *
-import math
-
-# always need to init first thing
-pygame.init()
-
-# create the window and keep track of the surface
-# for drawing into
-screen = pygame.display.set_mode()
-
-# ask for screen's width and height
-width, height = screen.get_size()
-
-# turn off the cursor
-pygame.mouse.set_visible(False)
-
-color = (250, 250, 250)
-min_factor = 0.8
-max_factor = 0.9
-start_length = 130
-min_length = 40
-min_angle_delta = 0.4
-max_angle_delta = 0.5
-
-# start the screen all black
-bgcolor = (0,0,0)
-screen.fill(bgcolor)
-
-def draw_tree(x, y, length, angle):
- x2 = x + length * math.sin(angle)
- y2 = y - length * math.cos(angle)
- pygame.draw.line(screen, color, (x, y), (x2, y2))
-
- if length > min_length:
- # draw left branch
- left_angle = angle - \
- uniform(min_angle_delta, max_angle_delta)
- left_length = length * \
- uniform(min_factor, max_factor)
- draw_tree(x2, y2, left_length, left_angle)
- # draw middle branch
- middle_length = length * \
- uniform(min_factor, max_factor)
- draw_tree(x2, y2, middle_length, angle)
- # draw right branch
- right_angle = angle + \
- uniform(min_angle_delta, max_angle_delta)
- right_length = length * \
- uniform(min_factor, max_factor)
- draw_tree(x2, y2, right_length, right_angle)
-
-# clear the screen
-screen.fill(bgcolor)
-
-# draw a tree, starting at the bottom centre of the
-# screen
-draw_tree((width / 2), height - 20, start_length, 0)
-pygame.display.flip()
-
-while pippy.pygame.next_frame():
- # chill until escape key is pressed
- for event in pygame.event.get():
- if event.type == QUIT:
- sys.exit()
-
- if event.type == KEYDOWN:
- if event.key == K_ESCAPE:
- sys.exit()
+# tree + +import pippy, pygame, sys +from pygame.locals import * +from random import * +import math + +# always need to init first thing +pygame.init() + +# create the window and keep track of the surface +# for drawing into +screen = pygame.display.set_mode() + +# ask for screen's width and height +width, height = screen.get_size() + +# turn off the cursor +pygame.mouse.set_visible(False) + +color = (250, 250, 250) +min_factor = 0.8 +max_factor = 0.9 +start_length = 130 +min_length = 40 +min_angle_delta = 0.4 +max_angle_delta = 0.5 + +# start the screen all black +bgcolor = (0,0,0) +screen.fill(bgcolor) + +def draw_tree(x, y, length, angle): + x2 = x + length * math.sin(angle) + y2 = y - length * math.cos(angle) + pygame.draw.line(screen, color, (x, y), (x2, y2)) + + if length > min_length: + # draw left branch + left_angle = angle - \ + uniform(min_angle_delta, max_angle_delta) + left_length = length * \ + uniform(min_factor, max_factor) + draw_tree(x2, y2, left_length, left_angle) + # draw middle branch + middle_length = length * \ + uniform(min_factor, max_factor) + draw_tree(x2, y2, middle_length, angle) + # draw right branch + right_angle = angle + \ + uniform(min_angle_delta, max_angle_delta) + right_length = length * \ + uniform(min_factor, max_factor) + draw_tree(x2, y2, right_length, right_angle) + +# clear the screen +screen.fill(bgcolor) + +# draw a tree, starting at the bottom centre of the +# screen +draw_tree((width / 2), height - 20, start_length, 0) +pygame.display.flip() + +while pippy.pygame.next_frame(): + # chill until escape key is pressed + for event in pygame.event.get(): + if event.type == QUIT: + sys.exit() + + if event.type == KEYDOWN: + if event.key == K_ESCAPE: + sys.exit() |