Activities/Turtle Art/Tutorials/Turtle Art and Logo: Difference between revisions

Mokurai (talk | contribs)
m Left: Spelling
Mokurai (talk | contribs)
Line 248: Line 248:
==Logo Code for TA Examples==
==Logo Code for TA Examples==


TBD
This is the code generated for the examples in the [[Activities/TurtleArt/Tutorials/Mathematics_and_art|Mathematics and Art]] tutorial for Turtle Art, with line breaks and indents added for clarity. Square and Squares are of little more difficulty than the Turtle Art they aer derived from. Flowers has a substantial section on handling colors in the manner of Turtle Art. The last three procedures, stack1, stack2, and start, are very similar to the stacks in the Turtle Art version.
 
==Square program==
 
window
to start
  repeat 4.0
  [ forward 100.0
    right 90.0
  ]
end
 
==Squares program==
 
window
to start
  clean
  repeat 36.0
  [ repeat 4.0
    [ forward 300.0
      right 90.0
    ]
    right 10.0
  ]
end
 
==Flower program==
 
window
to tasetpalette :i :r :g :b :myshade
  make "s ((:myshade - 50) / 50)
  ifelse lessp :s 0 [
  make "s (1 + (:s *0.8))
  make "r (:r * :s)
  make "g (:g * :s)
  make "b (:b * :s)
  ] [ make "s (:s * 0.9)
  make "r (:r + ((99-:r) * :s))
  make "g (:g + ((99-:g) * :s))
  make "b (:b + ((99-:b) * :s))
  ] setpalette :i (list :r :g :b)
end
to rgb :myi :mycolors :myshade
  make "myr first :mycolors
  make "mycolors butfirst :mycolors
  make "myg first :mycolors
  make "mycolors butfirst :mycolors
  make "myb first :mycolors
  make "mycolors butfirst :mycolors
  tasetpalette :myi :myr :myg :myb :myshade
  output :mycolors
end
to processcolor :mycolors :myshade
  if emptyp :mycolors [stop]
  make "i :i + 1
  processcolor (rgb :i :mycolors :myshade) :myshade
end
to tasetshade :shade
  make "myshade modulo :shade 200
  if greaterp :myshade 99 [make "myshade (199-:myshade)]
  make "i 7
  make "mycolors :colors
  processcolor :mycolors :myshade
end
to tasetpencolor :c
  make "color (modulo (round :c) 100)
  setpencolor :color + 8
end
make "colors [
99  0  0\
99  5  0\
99 10  0\
99 15  0\
99 20  0\
99 25  0\
99 30  0\
99 35  0\
99 40  0\
99 45  0\
99 50  0\
99 55  0\
99 60  0\
99 65  0\
99 70  0\
99 75  0\
99 80  0\
99 85  0\
99 90  0\
99 95  0\
99 99  0\
90 99  0\
80 99  0\
70 99  0\
60 99  0\
50 99  0\
40 99  0\
30 99  0\
20 99  0\
10 99  0\
  0 99  0\
  0 99  5\
  0 99 10\
  0 99 15\
  0 99 20\
  0 99 25\
  0 99 30\
  0 99 35\
  0 99 40\
  0 99 45\
  0 99 50\
  0 99 55\
  0 99 60\
  0 99 65\
  0 99 70\
  0 99 75\
  0 99 80\
  0 99 85\
  0 99 90\
  0 99 95\
  0 99 99\
  0 95 99\
  0 90 99\
  0 85 99\
  0 80 99\
  0 75 99\
  0 70 99\
  0 65 99\
  0 60 99\
  0 55 99\
  0 50 99\
  0 45 99\
  0 40 99\
  0 35 99\
  0 30 99\
  0 25 99\
  0 20 99\
  0 15 99\
  0 10 99\
  0  5 99\
  0  0 99\
  5  0 99\
10  0 99\
15  0 99\
20  0 99\
25  0 99\
30  0 99\
35  0 99\
40  0 99\
45  0 99\
50  0 99\
55  0 99\
60  0 99\
65  0 99\
70  0 99\
75  0 99\
80  0 99\
85  0 99\
90  0 99\
95  0 99\
99  0 99\
99  0 90\
99  0 80\
99  0 70\
99  0 60\
99  0 50\
99  0 40\
99  0 30\
99  0 20\
99  0 10]
make "shade  50 
to taminus :y :x
  output sum :x minus :y
end
to stack1
  repeat 4.0 [ forward :box1 right 90.0 ]
end
to stack2
  repeat 10.0 [ stack1 right 36.0 ]
end
to start
  clean
  make "box1 0.0
  repeat 300.0 [
  tasetshade taminus 100.0 :box1
  tasetpencolor quotient :box1 3.0 stack2
  make "box1 sum :box1 1.0 ]
end


==See Also==
==See Also==