/FP1

final project exploration #1: learn Github, play with a Racket library

Primary LanguageRacket

Final Project Assignment 1: Exploration (FP1)

Name: Leang Seu Kim

This project I will be exploring turtles lib. The plan is to draw something cool with this lib. EX: sierpinski triangle

Starter lib

#lang racket

(require graphics/turtles)

(turtles)

This will create the turtle for drawing

p1

#lang racket

(require graphics/turtles)

(turtles)

(move-offset 0 -100)
(draw-offset -100 200)
(draw-offset 200 0)
(draw-offset -100 -200)

(move-offset 0 -100) move the turtle up 100 pixel without draw. (draw-offset -100 200) move the turtle to the left 100 pixel and down 200pixel and draw it.

p2

More advance lib

#lang racket

(require graphics/turtles graphics/turtle-examples)

(turtles)

(turn 90)
(regular-poly 3 200)

(turn 90) Turn the turtle 90 degree counter clockwise. The purple of this is to make top of triangle is pointing upward. (regular-poly 3 200) Draw 3 side with 200 pixels each sides.

p3

Sierpinski Triangle

There are multiple way of doing this. 1.

#lang racket

(require graphics/turtles graphics/turtle-examples)

(turtles)

(turn 90)

(sierp-nosplit sierp-size)

p4

But doing this is not efficient because it will go through a lot the recursion 2.

#lang racket

(require graphics/turtles graphics/turtle-examples)

(turtles)

(turn 90)

(tprompt (sierp sierp-size))

This would give the same result however, it is more efficient because of the split of turtle. tprompt would limit the spliting. It evaluated the expression then return turtle to original state. Without this function, there would be a lot of turtle left on the screen.