logo 编程

玩了一把logo语言,好学易懂,小朋友有兴趣是个挺不错的玩意。当然也可用于一些机器人等控制

apt install ucblogo

;一个多边形  l 边长 n 边数
to sj :l :n
  repeat :n [fd :l rt 360/n]
end
;l 边长  p 偏转边的百分比  n 边个数
to lxs1 :l :p :n
  if :l<5 [stop]
  sj :l :n
  make "k :l*:p
  make "kk :l-:k
  make "h :k*(sin 60)
  make "h2 :kk-sqrt(:k*:k-:h*:h)
  make "l2 sqrt(:h*:h+:h2*:h2)
  make "d arctan(:h/:h2)
  fd :k rt :d
  lxs1 :l2 :p :n
end
;l 边长 p偏移百分比 n边个数 m旋转一圈画几个
to lxs :l :p :n :m
  make "a 1
  repeat :m [lxs1 :l :p :n home rt :a*360/:m make "a :a+1]
  home
end
to lxsv :l :p
  make "nn 3
  make "mm 1
  repeat 10 [repeat 8-:nn [repeat 10 [lxs :l :p :nn :mm wait 10 cs make "mm :mm+1] make "mm 1 make "nn :nn+1] make "nn 3]
end
原文地址:https://www.cnblogs.com/zhenfei/p/6681453.html