2020年即将到来,如何既有科技感又有艺术性地来迎接新的一年呢?
思来想去,不如用代码来画新年窗花吧!
先来个简单一些的给大家瞧瞧~


怎么样,是不是很有趣呢?接下来就叫你如何利用Scratch转出花!
// 基础篇 //
首先,你可以信手涂鸦几个造型,再旋转着敲图章,窗花就画好了。
同样的造型,旋转不同角度重复敲不同次数的章,效果也会不一样。
那么,问题来了:
这么简单,玩着不过瘾啊~
别急!接着往下看~
翻出南瓜博士的“代码艺术课”私家珍藏,找到“对称图案”这章中的一个程序,稍作改动就成为剪窗花游戏。
美滋滋的玩了好久后,问题又来了:
怎样才能超越 LOGO 式的画画,更多地发挥孩子们的创造力呢?
这个问题……干脆,自己先来玩一玩吧。
// 进阶篇 //
尽可能降低代码的逻辑要求,甚至不用画线功能,看看光靠敲图章,能敲出怎样的创意来。
蒙德里安?草间弥生?如果不使用复杂逻辑,我们该如何创作出有艺术味道的画呢?也许只能画画波洛克?

试着学学草间弥生:
用点点装饰圣诞树:

还可以用来给甜甜圈添加糖粒:

但还能玩什么呢?
试试修拉吧:用圣诞树点彩的方式来给窗花涂色!

// 创造力Plus //
只要把造型设成一个小点,在画布上随机移动,遇到不是白色的地方盖章,就可以了呢,代码比给圣诞树装彩灯更简单。

实验一:
通过颜色特效代码,可以让造型变成各种彩点。所以在下图背景上运行代码,就可以得到一朵五彩窗花。

(重要技巧:按住 shift 键的同时点击绿旗,可以进入加速模式。)

实验二:
继续玩,改一下颜色特效的随机数范围,就是冰蓝的雪花了。
实验三:
换个颜色范围,就是烈焰般的色彩,更适合用婀娜女郎做背景图。

实验四:
还是更喜欢冰蓝的雪花,可以从网上找些雪花剪影,最初的窗花代码也可以派上用场了,还是省略了变量的极简版:
即使乱涂几根线条,效果也不错哦!
比如,搞笑的卡通上下眼,怎么都想象不出它能演变成那么正常的一幅窗花。
实验五:
现在程序是:按 a 键画黑色窗花剪影,按空格点彩上色。
添加一个求距离的公式,染出彩虹色的花!
除了公式,还有有个简单的方法——添加一个在 (0,0) 位置的“原点”角色,然后复杂的公式就变成如下易理解的代码:

继续玩,把圆点变成细斜线后图画的风格都变了。

之前是“碰到白色不成立就敲图章”,彩点都严格画在黑色轮廓之内。将判断条件换成“碰到黑色就敲图章”,彩点会跑到轮廓之外,画出来的是毛毛的感觉。

画的彩点多了把黑色全部盖住成了一个个圆环,不够有趣,再添加一个亮度的随机值:

旋转的花纹玩过瘾了,换成平移,来个拉花式的窗花。

把颜色设为 x 坐标,就出现了彩虹拉花。

按 y 坐标来设颜色,会是另一种趣味:

直接拿 Scratch 自带的造型也可以作画:


试试拖动蝴蝶角色到处飞,你会发现点彩跟着蝴蝶动,然后满屏都是彩点!
那么,干脆让彩点遇到角色就敲图章吧!为了提升效率,把一个彩点变成一堆彩点也不错。

用代码画画是 LOGO 的标志性玩法,用来教数学再好不过。而色彩选择,又用到了一点点逻辑思考。
现在学 Scratch 的以低龄孩子为主,如果换做孩子们来写色彩相关的代码,会给我们带来怎样的惊喜呢?
元旦的钟声就要敲响
科技学堂想对大家说
2
0
2
0

图片 | 科技学堂 刘欣
前方或许崎岖,但前方的希望便是动力。
新的一年,一起加油,勇攀高峰!
HAPPY
新 年 快 乐
声明:转载此文是出于传递更多信息之目的。若有来源标注错误或侵犯了您的合法权益,请作者持权属证明与本网联系,我们将及时更正、删除,谢谢。