;; SUMMARY ;;;; A Koch Island fractal is drawn. ;; COPYRIGHT & LICENSE ;;;; Copyright (C) 2005 James P. Steiner ;;;; Some Rights Reserved. ;;;; Creative Commons Attribution-NonCommercial-ShareAlike License v. 2.0. ;;;; Visit http://creativecommons.org/licenses/by-nc-sa/2.0/ for more information. ;; APPLET DIMENSIONS (width x height) ;;;; 710 x 550 ;; globals [ step steps ] to setup ca end to go do-koch-island line-color end to do-koch-island [ hue ] ; island-size is a slider ; island-freq is a slider set steps screen-edge-x * (island-size * .01) * sqrt 3 set step 1 / (screen-size-x * 3 / sqrt 3) create-turtles 1 ask turtle 0 [ ;; position turtle so that island will be centered home set heading 0 jump steps / sqrt 3 ;; why sqrt 3? check back with your geometry, and the properties of 30/60/90 triangles! rt 150 ;; think 180 - 30 set color hue pd ;; draws lines on the drawing layer koch-island steps island-freq pu ;; mark the starting/ending spot ;; set color white die ] end to koch-island [ isle-size isle-level ] repeat 3 [ k-side isle-size isle-level rt 120 ] end to k-side [ side-size side-level ] ifelse side-level = 0 [ jump side-size ] [ set side-size side-size / 3 ; local copies of inputs can be changed! set side-level side-level - 1 k-side side-size side-level lt 60 k-side side-size side-level rt 120 k-side side-size side-level lt 60 k-side side-size side-level ] end @#$#@#$#@ GRAPHICS-WINDOW 188 10 703 546 50 50 5.0 1 10 1 1 1 0 0 0 1 CC-WINDOW 5 560 712 655 Command Center 0 SLIDER 8 53 180 86 island-size island-size 1 100 50.0 0.01 1 % SLIDER 9 89 181 122 island-freq island-freq 0 8 5 1 1 NIL BUTTON 77 10 132 43 NIL go NIL 1 T OBSERVER T NIL BUTTON 9 10 64 43 NIL setup NIL 1 T OBSERVER T NIL BUTTON 56 180 122 213 series clear-drawing\nset island-size 100\nlet col 135\nrepeat 50\n[ do-koch-island col\n set col wrap-color col - 1\n set island-size island-size - 1\n] NIL 1 T OBSERVER T NIL SLIDER 9 125 181 158 line-color line-color 0 139 46 1 1 NIL @#$#@#$#@ WHAT IS IT? ----------- A short model to draw a koch island COPYRIGHT & LICENSE ------------------- Copyright (C) 2005 James P. Steiner, Some Rights Reserved. This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.0/ or send a letter to Creative Commons 559 Nathan Abbott Way Stanford, California 94305, USA @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 @#$#@#$#@ NetLogo 3.0 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@