--------------------

to main ; 4sqrs
3d_frame
setpc 3 squares 90 4
end

to squares :size :step
            draw  1 :size
sph 0 0   0 draw -1 :size
sph 0 0 180 draw  1 :size
sph 0 0 180 draw -1 :size
end

to draw :dir :size
if :size>:step[
  square move
  draw :dir newsize]
end

to square
repeat 4[fd :size rt :dir*90]
end

to move
fd :step
rt :dir*arctan :step/(:size-:step)
end

to newsize
op sqrt :size*:size-2*:step*(:size-:step)
end

to procs
ed[main squares draw square move newsize procs]
end
--------------------

to main ; 6tris
3d_frame
setpc 4 draw 96
end

to draw :size
for[i 0 2][
   sph 0 0 120*:i tris :size  1
   sph 0 0 120*:i tris :size -1]
end

to tris :size :dir
if :size<20[stop]
tri :size :dir
fd :size/15
rt :dir*4
tris .9*:size :dir
end

to tri :size :dir
repeat 3[fd :size rt :dir*120]
end

to procs
ed[main draw tris tri procs]
end
--------------------

to main ; Eye
3d_frame
sphc 86 -86 0 6
repeat 2[draw [] [] 25 7]
end

to draw :ll1 :ll2 :times :incr
repeat :times[fd :incr push "ll1 pos]
lt 90
repeat :times[fd :incr push "ll2 pos]
repeat :times[connect]
fd(:times-1)*:incr lt 90
end

to connect
pu setpos pop "ll1
pd setpos pop "ll2
end

to procs
ed[main draw connect procs]
end
--------------------

to main ; cross by Olga Tusova
3d_frame setpc 3
go 85 14
end

to go :l :n
setup :l/:n :l
end

to setup :step :l
for[i 1 8][run item :i[
  [do   0   0 -:l   0  :step  :step] ; NW inside
  [do   0   0  :l   0 -:step  :step] ; NE inside
  [do   0   0 -:l   0  :step -:step] ; SW inside
  [do   0   0  :l   0 -:step -:step] ; SE inside
  [do -:l  :l   0  :l -:step -:step] ; NW frame
  [do  :l  :l   0  :l  :step -:step] ; NE frame
  [do  :l -:l   0 -:l  :step  :step] ; SE frame
  [do -:l -:l   0 -:l -:step  :step] ; SW frame
    ]]
end

to do :x :y :x1 :y1 :stepx :stepy
setxy :x1 :y1
repeat :n+1[draw]
end

to draw
pd setxy :x :y1
make "x1 :x1+:stepx
make "y1 :y1+:stepy
pu setxy :x1 :y
end

to procs
edit[main go setup do draw procs]
end
--------------------

to main ; 4 Eyes
3d_frame
setpc 6
repeat 4[
     repeat 2[draw [] [] 13 7] lt 90]
end

to draw :ll1 :ll2 :times :incr
repeat :times[fd :incr push "ll1 pos]
lt 90
repeat :times[fd :incr push "ll2 pos]
repeat :times[connect]
fd(:times-1)*:incr lt 90
end

to connect
pu setpos pop "ll1
pd setpos pop "ll2
end

to procs
ed[main draw connect procs]
end
--------------------

to main ; Parabola by Olga Tuzova
3d_frame
setpc 6
collect [] [] 93
end

to collect :l1 :l2 :a ; points on a parabola
pu setxy -:a f :a pd  ;        move to start
for [x -:a 0 3] [setxy :x f :x push "l1 pos]
for [x  0 :a 3] [setxy :x f :x push "l2 pos]
connect
end

to f :x               ;         y coordinate
op .02*:x*:x-88       ;       formula: y=x*x
end

to connect
if emptyp :l1[stop]
pu setpos pop "l1
pd setpos pop "l2
connect
end

to procs
ed[main collect f connect procs]
end
--------------------

to main ; Parabola & Evolute by Mike Sandy
3d_frame
envelope -93 93 -93 93  5
end

to envelope :x.low :x.upp :y.low :y.upp :incr
;1ST 4 PARAMS BOUNDARY VALUES :incr - X INCREMENT
localmake "a 1/:x.upp
for[x0 :x.low :x.upp :incr][
    setpc 2  plot.line pt :x.low "yt "xt pt :x.upp "yt "xt
    ifelse :x0=0
    [setpc 4 plot.line (list 0 :y.low) (list 0 :y.upp)]
    [setpc 4 plot.line pt :x.low "yn "xn pt :x.upp "yn "xn]]
end

to plot.line :p1 :p2
pu setpos :p1
pd setpos :p2
end

to pt :x.bound :fny :fnx
localmake "y run (se :fny  :x.bound)
if :y<:y.low[op (list run (se :fnx :y.low) :y.low)]
if :y>:y.upp[op (list run (se :fnx :y.upp) :y.upp)]
op (list :x.bound :y)
end

to y :x
op :a*:x*:x-50
end

to yt  :x
op (:x-:x0)*(grad :x0)+y :x0
end

to xt  :y
op (:y-y :x0)/(grad :x0)+:x0
end

to yn  :x
op (y :x0)-(:x-:x0)/grad :x0
end

to xn  :y
op (grad :x0)*((y :x0)-:y)+:x0
end

to grad :x
op 2*:a*:x
end

to procs
ed[main envelope plot.line pt y yt xt yn xn grad procs]
end
--------------------

to main ; fish_net
3d_frame
setpc 2 pu
pr[Input Number of Points (3 .. 10)]
do rw 12 8
end

to do :points :times :size
repeat :points[draw [] [] setxy 0 0]
end

to draw :l1 :l2    ;   2 empty lists
fd :times*:size    ;  "spoke" length
repeat :times[push "l1 pos bk :size]
rt 360/:points
repeat :times[fd :size push "l2 pos]
repeat :times[connect]
end

to connect
pu setpos pop "l1
pd setpos pop "l2
end

to procs
ed[main do draw connect procs]
end
--------------------

to main ; Diagonals
3d_frame
setpc 3
pu draw collect [] rw 1
end

to collect :ll :n
repeat :n[
   fd 90 push "ll pos
   bk 90 rt 360/:n]
op :ll
end

to draw :ll :cnt
if :cnt=count :ll[stop]
rays :ll
draw fput last :ll bl :ll :cnt+1
end

to rays :ll
setpos last :ll
pd setpos first :ll
if lessp 2 count :ll[rays bf :ll]
end

to procs
ed[main collect draw rays procs]
end
--------------------

to main ; Mask by Olga Tuzova
3d_frame
mask 23 92 60 4 20
end

to mask :xmax :xmax1 :ymax :k :n
localmake "step1 :xmax/:n
localmake "step2 2*:ymax/:n
setpc 2 connect.side -:xmax -:xmax1 -:ymax -:k :step1 :step2 :n
setpc 4 connect.side -:xmax -:xmax1  :ymax :k :step1 -:step2 :n
setpc 2 connect.side  :xmax  :xmax1 -:ymax :k -:step1 :step2 :n
setpc 4 connect.side  :xmax :xmax1 :ymax -:k -:step1 -:step2 :n
setpc 7 connect.center -:xmax 0 -:k :step1 :n
connect.center -:xmax 0 :k :step1 :n
end

to connect.side :x0 :x1 :y1 :k :step1 :step2 :n
if :n<0[stop]
pu setxy :x0 :k*:x0
pd setxy :x1 :y1
connect.side :x0+:step1 :x1 :y1+:step2 :k :step1 :step2 :n-1
end

to connect.center :x0 :x1 :k :step :n
if :n<0[stop]
pu setxy :x0 :k*:x0
pd setxy :x1 -:k*:x1
connect.center :x0+:step :x1+:step :k :step :n-1
end

to procs
ed[main mask connect.side connect.center procs]
end
--------------------

to main ; trinet by Olga Tuzova
3d_frame
tri.web 100 20
end

to tri.web :r :n
localmake "step1 :r*(sqrt 3)/:n
localmake "step2 .5*:r*(sqrt 3)/:n
setpc 6 connect2 0 -.5*:r*sqrt 3 sqrt 3 -:step2 :step1 :n
setpc 4 connect1 -.5*:r*sqrt 3 0 sqrt 3 -sqrt 3 :step2 :n
setpc 2 connect2 0 .5*:r*sqrt 3 -sqrt 3 :step2 -:step1 :n
end

to connect1 :x0 :x1 :k1 :k2 :step :n
if :n<0[stop]
pu setxy :x0 :k1*:x0+:r
pd setxy :x1 :k2*:x1+:r
connect1 :x0+:step :x1+:step :k1 :k2 :step :n-1
end

to connect2 :x0 :x1 :k1 :step1 :step2 :n
if :n<0[stop]
pu setxy :x0 :k1*:x0+:r
pd setxy :x1 -:r/2
connect2 :x0+:step1 :x1+:step2 :k1 :step1 :step2 :n-1
end

to procs
ed[main tri.web connect1 connect2 procs]
end
--------------------