Fractal Programming

Variables and Repetition and Procedures

.A geometric shape that can be subdivided in parts, each of which is (at least approximately) a reduced/size copy of the whole

Basic Spiral

spiral = (size) ->
    if size > 0
        fd size * 10
        rt 90
        spiral  size - 1
        lt 90
        bk size * 10
        

This procedure develops the basic spiral code. If the size is 5, then the code will run 5 times, each time being 1 step smaller than the first

Notice that we are calling the "spiral" inside of the code - see Line 5

Network Notebook: What is the result of line 7 bk size * 10? Does it relate to symmetry? Identify the variable in this code and explain (in english) both the value it holds AND how that value is updated when the seed procedure is called

Recursive Kolam

Network Notebook: Define Kolam and sketch one

movexy -101,250
pen black, 1
speed  2

seed = (num) ->
    if num > 13
        for [1..4]
        rt 90
        fd num
    fill random color
    lt 90
    seed(num/2)
    
seed(160)
jumpto 98,51
seed(160)
ht()

This assignment based on lessonplans found at https://manual.pencilcode.net/home/pdf/110-Chapter10.pdf

Last updated