查看原文
其他

小海龟告诉你【啥是佩奇】

Y叔叔 YuLabSMU 2022-09-23

在1966年,Seymour Papert和Wally Feurzig发明了一种专门给儿童学习编程的语言——LOGO语言,它的特色就是通过编程指挥一个小海龟(turtle)在屏幕上绘图。

The turtle has three attributes: a location, an orientation (or direction), and a pen. The pen, too, has attributes: color, width, and on/off state.


The turtle moves with commands that are relative to its own position, such as "move forward 10 spaces" and "turn left 90 degrees". The pen carried by the turtle can also be controlled, by enabling it, setting its color, or setting its width. A student could understand (and predict and reason about) the turtle's motion by imagining what they would do if they were the turtle. Seymour Papert called this "body syntonic" reasoning.


A full turtle graphics system requires control flow, procedures, and recursion: many turtle drawing programs fall short. From these building blocks one can build more complex shapes like squares, triangles, circles and other composite figures. The idea of turtle graphics, for example is useful in a Lindenmayer system for generating fractals.


Turtle geometry is also sometimes used in graphics environments as an alternative to a strictly coordinate-addressed graphics system.

这个海龟绘图(Turtle Graphics)已经被各种高级语言实现了,基本上100%复制了原始Turtle Graphics的所有功能,比如python的turtle库,比如R的TurtleGraphics包。

github上发现有人用python来画小猪佩奇,我拿来玩一下,录了下面这个gif:

有兴趣的话,可以玩一下,拿R来玩小海龟也是可以的。像C,JAVA等主流语言都是支持小海龟的。这个本来就是设计给小朋友玩的,小伙伴现在玩得溜嘛,可以哄女朋友,以后就成了育儿功能了,陪小朋友玩,效果杠杠的!


往期精彩                                                                                            

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存