globals [ ospace oscale oline default ] breed [ typewriters typewriter ] breed [ letters letter ] typewriters-own [ text dels bx by ] letters-own [ bx by ] to startup test end to test ca ask patches [ set pcolor gray - 2 + 1 * ((pxcor + pycor) mod 2) ] set ospace char-space set oline line-space set oscale scale let this nobody set default (word "This is a test of using turtle shapes for text from a \"string.\"" "\n\nDid it work correctly? @#$%^&*()_+-={}[]/\\" "\n\nabcdefghijklmnopqrstuvwxyz 193.254.67.80" ) create-typewriters 1 [ set shape "_blank" set size scale set color white set heading 0 pagefeed set this self ] ask this [ let string sample if string = "" [ set string default ] set dels " -\n" set text split string dels print text foreach text [ ifelse ? = "\n" [ newline ] [ if xcor > 0 and ( (xcor + (length ? - 1) * scale * char-space >= max-pxcor ) and not ( length ? = 1 and member? ? dels and xcor <= max-pxcor)) [ newline ] let i 0 repeat length ? [ let char lower (item i ?) let new-shape "" ifelse member? char shapes [ set new-shape char ] [ set new-shape "[x]" ] hatch-letters 1 [ ifelse new-shape = "[x]" [ set shape "_blank" set label char ] [ set shape new-shape ] ask other letters-here with [ bx = [ bx ] of myself and by = [ by ] of myself ] [ die ] ] advance set i i + 1 ] ] ] die ] end to applybxby end to advance set bx ( xcor + char-space * scale ) ifelse bx + scale > max-pxcor + .49 [ newline ] [ setxy bx by ] end to newline ;; typewriter procedure set bx (min-pxcor + char-space * scale) set by (ycor + line-space * scale ) ifelse by - scale < min-pycor - .49 [ pagefeed ] [ setxy bx by ] end to pagefeed set bx (min-pxcor + char-space * scale) set by (max-pycor + line-space * scale) setxy bx by end to-report split [ string delims ] let result [] let piece "" let char "" repeat length string [ set char first string ;; is char a word delimiter? ifelse member? char delims [ ;; yes, add current piece to result if piece != "" [ set result fput piece result set piece "" ] ;; add delimiter to result set result fput char result ] [ ;; no, add to piece set piece (word piece char) ] ;; remove first character set string but-first string ] ;; is there a piece in progress?, if so, add it to the result if piece != "" [ set result fput piece result set piece "" ] ;; reverse the result set result reverse result ;; report the result report result end to-report lower [ char ] let c position char "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ifelse c = false [ set c char ] [ set c item c "abcdefghijklmnopqrstuvwxyz" ] report c end to-report upper [ char ] let c position char "abcdefghijklmnopqrstuvwxyz" ifelse c = false [ set c char ] [ set c item c "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ] report c end @#$#@#$#@ GRAPHICS-WINDOW 375 10 760 416 12 12 15.0 1 18 1 1 1 0 1 1 1 -12 12 -12 12 1 1 1 ticks CC-WINDOW 5 430 769 525 Command Center 0 SLIDER 50 290 170 323 char-space char-space 1 2 1 .05 1 NIL HORIZONTAL SLIDER 10 250 43 370 line-space line-space -2 -1 -1.5 .05 1 NIL VERTICAL SLIDER 50 250 170 283 scale scale .1 2 1.06 .01 1 NIL HORIZONTAL BUTTON 10 210 170 243 active every .1\n[ if char-space != ospace or line-space != oline or scale != oscale\n [ test display ]\n] T 1 T OBSERVER NIL NIL NIL NIL BUTTON 10 380 170 413 reset set char-space 1\nset line-space -1\nset scale 1\ntest NIL 1 T OBSERVER NIL NIL NIL NIL TEXTBOX 15 10 160 66 Click \"active\" to enable the scaling sliders. Change the sliders to change the text display. 11 0.0 1 INPUTBOX 10 75 290 205 sample null 1 1 String BUTTON 295 75 365 108 update test NIL 1 T OBSERVER NIL NIL NIL NIL BUTTON 295 115 365 148 default set sample default test NIL 1 T OBSERVER NIL NIL NIL NIL BUTTON 295 155 365 188 clear set sample \"\" NIL 1 T OBSERVER NIL NIL NIL NIL @#$#@#$#@ WHAT IS IT? ----------- A model to demonstrate layout of text using a turtle to "print" the text into the drawing layer. HOW IT WORKS ------------ Each printable character has a defined turtle shape. This is the "font" that the turtle uses to imprint characters into the view. If a particular character is not defined, then the turtle label is set to the character needed. @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 false 0 ! false 6 Rectangle -13840069 true true 120 15 180 195 Rectangle -13840069 true true 120 225 180 285 " false 6 Rectangle -13840069 true true 75 30 135 120 Rectangle -13840069 true true 165 30 225 120 # false 6 Polygon -13840069 true true 210 30 240 60 165 285 135 255 Polygon -13840069 true true 135 15 165 45 90 270 60 240 Rectangle -13840069 true true 45 75 270 120 Rectangle -13840069 true true 30 165 255 210 $ false 6 Polygon -13840069 true true 135 15 165 15 165 60 225 60 225 90 165 90 165 135 210 135 225 150 225 225 210 240 165 240 165 285 135 285 135 240 75 240 75 210 195 210 195 165 165 165 165 210 135 210 135 165 90 165 75 150 75 75 90 60 135 60 135 90 105 90 105 135 135 135 % false 6 Polygon -13840069 true true 240 30 270 60 45 285 15 255 Rectangle -13840069 true true 30 30 105 105 Rectangle -13840069 true true 180 195 255 270 & false 0 Rectangle -7500403 true true 105 15 195 60 Rectangle -7500403 true true 180 60 225 105 Rectangle -7500403 true true 60 60 105 105 Rectangle -7500403 true true 90 105 135 150 Rectangle -7500403 true true 150 105 195 150 Rectangle -7500403 true true 75 150 165 195 Rectangle -7500403 true true 165 165 210 210 Rectangle -7500403 true true 45 180 90 225 Rectangle -7500403 true true 30 225 75 270 Rectangle -7500403 true true 75 240 195 285 Rectangle -7500403 true true 210 180 255 225 Rectangle -7500403 true true 165 210 210 255 Rectangle -7500403 true true 210 240 255 285 Rectangle -7500403 true true 240 150 285 195 ' false 6 Rectangle -13840069 true true 135 30 180 120 ( false 6 Polygon -13840069 true true 195 -30 150 -30 105 0 75 60 75 240 105 300 150 330 195 330 210 300 150 285 120 225 120 75 150 15 210 0 ) false 6 Polygon -13840069 true true 105 -30 150 -30 195 0 225 60 225 240 195 300 150 330 105 330 90 300 150 285 180 225 180 75 150 15 90 0 * false 6 Polygon -13840069 true true 90 135 135 165 150 120 165 165 210 135 165 105 225 105 210 60 165 75 180 30 120 30 135 75 90 60 75 105 135 105 + false 6 Polygon -13840069 true true 90 135 135 135 135 90 180 90 180 135 225 135 225 180 180 180 180 225 135 225 135 180 90 180 , false 6 Polygon -13840069 true true 120 225 180 225 180 285 120 330 75 330 120 285 - false 6 Rectangle -13840069 true true 60 120 240 165 . false 6 Rectangle -13840069 true true 120 225 180 285 / false 6 Polygon -13840069 true true 270 0 300 30 30 300 0 270 0 false 6 Polygon -13840069 true true 150 15 150 60 195 75 210 105 210 195 195 225 150 240 105 225 90 195 90 105 105 75 150 60 150 15 120 15 75 30 45 90 45 225 75 270 120 285 180 285 225 270 255 225 255 90 225 30 180 15 Circle -13840069 true true 120 120 60 1 false 6 Polygon -13840069 true true 75 75 120 15 180 15 180 240 240 240 240 285 60 285 60 240 120 240 120 90 2 false 6 Polygon -13840069 true true 45 75 75 30 150 15 225 30 255 75 255 120 225 165 105 240 255 240 255 285 45 285 45 225 195 135 210 90 180 60 120 60 90 90 3 false 6 Polygon -13840069 true true 45 75 90 90 120 60 180 60 210 90 180 120 120 120 120 165 180 165 195 210 180 240 120 240 90 210 45 225 75 270 135 285 225 270 255 210 225 150 255 90 225 30 150 15 75 30 4 false 6 Polygon -13840069 true true 60 30 105 30 105 135 180 135 180 30 225 30 225 135 255 135 255 180 225 180 225 285 180 285 180 180 60 180 5 false 6 Polygon -13840069 true true 90 30 240 30 240 75 135 75 120 120 165 105 210 120 255 165 255 225 210 285 120 285 60 225 120 210 150 240 195 240 210 180 165 150 105 180 60 165 6 false 6 Polygon -13840069 true true 225 90 150 60 105 90 105 165 150 135 225 150 270 210 225 270 150 285 75 270 45 195 105 210 135 240 195 240 225 210 165 180 105 210 45 195 45 105 75 45 150 15 240 45 7 false 6 Polygon -13840069 true true 60 45 225 45 240 105 135 180 105 285 60 285 90 165 195 90 60 90 8 false 6 Polygon -13840069 true true 150 285 150 240 195 225 195 180 150 165 105 180 105 225 150 240 150 285 90 270 60 240 60 165 105 135 195 135 240 165 240 240 210 270 Polygon -13840069 true true 150 15 150 60 195 75 195 120 150 135 105 120 105 75 150 60 150 15 90 30 60 60 60 135 105 165 195 165 240 135 240 60 210 30 9 false 6 Polygon -13840069 true true 75 30 150 15 225 45 240 120 195 225 105 285 60 255 135 210 165 165 120 165 60 135 45 90 105 90 120 120 165 120 195 90 165 60 120 60 105 90 45 90 : false 6 Rectangle -13840069 true true 120 225 180 285 Rectangle -13840069 true true 120 120 180 180 ; false 6 Rectangle -13840069 true true 120 150 180 210 Polygon -13840069 true true 120 225 180 225 180 285 120 330 75 330 120 285 = false 6 Rectangle -13840069 true true 60 60 240 105 Rectangle -13840069 true true 60 150 240 195 ? false 0 Rectangle -7500403 true true 120 150 180 195 Rectangle -7500403 true true 225 60 270 105 Rectangle -7500403 true true 180 105 225 150 Rectangle -7500403 true true 120 225 180 285 Rectangle -7500403 true true 75 15 225 60 Rectangle -7500403 true true 30 60 75 105 @ false 6 Polygon -13840069 true true 165 90 165 120 135 120 135 165 165 165 165 120 195 120 195 180 210 180 225 150 225 90 195 60 105 60 90 90 90 210 120 240 195 240 210 225 270 225 240 270 90 270 45 225 45 75 75 30 225 30 270 75 270 165 225 210 195 210 165 195 135 195 105 165 105 120 135 90 [ false 6 Polygon -13840069 true true 210 15 75 15 75 285 210 285 210 240 120 240 120 60 210 60 [x] false 6 Rectangle -13840069 true true 225 60 240 240 Polygon -13840069 true true 75 60 240 225 225 240 60 75 Rectangle -13840069 true true 60 60 240 75 Rectangle -13840069 true true 60 60 75 240 Rectangle -13840069 true true 60 225 240 240 Polygon -13840069 true true 225 60 60 225 75 240 240 75 \ false 6 Polygon -13840069 true true 0 30 30 0 300 270 270 300 ] false 6 Polygon -13840069 true true 90 15 225 15 225 285 90 285 90 240 180 240 180 60 90 60 ^ false 6 Polygon -13840069 true true 30 135 75 165 150 90 225 165 270 135 150 15 _ false 6 Rectangle -7500403 true false 0 300 300 330 Rectangle -13840069 true true 0 285 300 315 _blank false 0 a false 6 Polygon -13840069 true true 15 285 15 150 105 15 195 15 285 150 285 285 240 285 240 150 150 30 60 150 240 150 240 195 60 195 60 285 b false 0 Rectangle -7500403 true true 15 15 60 285 Rectangle -7500403 true true 45 15 240 60 Rectangle -7500403 true true 45 105 240 150 Rectangle -7500403 true true 45 240 240 285 Rectangle -7500403 true true 240 60 285 105 Rectangle -7500403 true true 240 150 285 240 c false 6 Polygon -13840069 true true 240 90 285 60 210 15 120 15 45 45 15 120 15 180 45 255 120 285 210 285 285 240 240 210 165 240 90 210 75 150 90 90 165 60 d false 0 Rectangle -7500403 true true 195 195 240 240 Rectangle -7500403 true true 195 60 240 105 Rectangle -7500403 true true 240 105 285 195 Rectangle -7500403 true true 45 240 195 285 Rectangle -7500403 true true 45 15 195 60 Rectangle -7500403 true true 15 15 60 285 e false 6 Polygon -13840069 true true 15 15 285 15 285 60 60 60 60 120 240 105 240 150 60 165 60 240 285 240 285 285 15 285 f false 6 Polygon -13840069 true true 15 15 285 15 285 60 60 60 60 120 240 105 240 150 60 165 60 285 15 285 g false 6 Polygon -13840069 true true 240 105 285 75 225 15 105 15 45 60 15 120 15 180 45 240 105 285 270 285 270 135 150 135 150 180 225 180 225 240 135 240 90 210 60 150 90 90 135 60 195 60 h false 6 Polygon -13840069 true true 15 15 60 15 60 120 240 105 240 15 285 15 285 285 240 285 240 150 60 165 60 285 15 285 i false 6 Polygon -13840069 true true 15 15 285 15 285 60 180 60 180 240 285 240 285 285 15 285 15 240 120 240 120 60 15 60 j false 6 Polygon -13840069 true true 60 15 285 15 285 210 270 240 225 270 150 285 60 270 30 240 15 210 15 150 60 150 60 210 105 240 195 240 240 210 240 60 60 60 k false 6 Polygon -13840069 true true 15 15 60 15 60 105 210 15 285 15 285 60 225 60 105 135 225 240 285 240 285 285 210 285 60 150 60 285 15 285 l false 6 Polygon -13840069 true true 15 15 60 15 60 240 285 240 285 285 15 285 m false 6 Polygon -13840069 true true 15 270 60 285 105 90 150 165 195 90 240 285 285 270 225 15 180 15 150 75 120 15 75 15 n false 6 Polygon -13840069 true true 15 285 15 15 60 15 240 210 240 15 285 15 285 285 240 285 60 90 60 285 o false 0 Rectangle -7500403 true true 60 60 105 105 Rectangle -7500403 true true 60 195 105 240 Rectangle -7500403 true true 15 105 60 195 Rectangle -7500403 true true 105 15 195 60 Rectangle -7500403 true true 105 240 195 285 Rectangle -7500403 true true 195 195 240 240 Rectangle -7500403 true true 195 60 240 105 Rectangle -7500403 true true 240 105 285 195 p false 0 Rectangle -7500403 true true 15 15 60 285 Rectangle -7500403 true true 45 15 240 60 Rectangle -7500403 true true 45 105 240 150 Rectangle -7500403 true true 240 60 285 105 q false 0 Rectangle -7500403 true true 60 60 105 105 Rectangle -7500403 true true 60 195 105 240 Rectangle -7500403 true true 15 105 60 195 Rectangle -7500403 true true 105 15 195 60 Rectangle -7500403 true true 105 240 195 285 Rectangle -7500403 true true 195 195 240 240 Rectangle -7500403 true true 195 60 240 105 Rectangle -7500403 true true 240 105 285 195 Rectangle -7500403 true true 150 150 195 195 Rectangle -7500403 true true 240 240 285 285 r false 6 Polygon -13840069 true true 15 15 240 15 285 60 285 105 225 150 105 165 135 180 180 210 240 240 285 240 285 285 240 285 150 255 90 210 60 180 60 285 15 285 15 135 60 135 225 105 240 90 240 75 225 60 60 60 60 135 15 135 s false 6 Polygon -13840069 true true 120 15 180 15 270 60 240 90 150 60 75 90 90 120 240 135 270 195 255 255 180 285 120 285 30 240 60 210 150 240 225 210 210 180 60 165 30 105 45 45 t false 6 Polygon -13840069 true true 15 15 285 15 285 60 180 60 180 285 120 285 120 60 15 60 u false 6 Polygon -13840069 true true 15 15 60 45 60 210 90 240 210 240 240 210 240 15 285 60 285 225 225 285 75 285 15 225 v false 6 Polygon -13840069 true true 15 30 60 15 150 225 240 15 285 30 180 285 120 285 w false 6 Polygon -13840069 true true 15 30 60 15 105 210 150 135 195 210 240 15 285 30 225 285 180 285 150 225 120 285 75 285 x false 6 Polygon -13840069 true true 15 45 60 15 150 120 240 15 285 45 180 150 285 255 240 285 150 180 60 285 15 255 120 150 y false 6 Polygon -13840069 true true 15 45 45 15 150 120 255 15 285 45 180 150 180 285 120 285 120 150 z false 6 Polygon -13840069 true true 15 15 285 15 285 60 90 240 270 240 270 285 15 285 15 240 210 60 15 60 @#$#@#$#@ NetLogo 4.0.4 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 0.0 1.0 0.0 1 1.0 0.0 0.2 0 0.0 1.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@