网上看到一个元旦快乐的例子,有感创作,也参考了里面一些技巧。效果如下:
在前面介绍了地球仪的作法,这里重要的是汉字点阵,以及让它曲面化。
为了汉字点阵,在网上找了很多小软件,最后才找到一个比较适用的。界面、名称如下:
接下来要用GGB来读取这些数据,把这堆数据复制进GGB(新建文本,本文命名为t1)
新建一个按钮,添加单击js脚本:
var str, str1, str2, str3
var j, k
var ran1, ran2
str = ggb.getValueString('t1')
str2 = ""
for (i = 0; i < str.length - 1; i++) {
str3 = str[i]
if (str3 != ",") {
switch (str3) {
case "0":
str3 = "0000";
break;
case "1":
str3 = "0001";
break;
case "2":
str3 = "0010";
break;
case "3":
str3 = "0011";
break;
case "4":
str3 = "0100";
break;
case "5":
str3 = "0101";
break;
case "6":
str3 = "0110";
break;
case "7":
str3 = "0111";
break;
case "8":
str3 = "1000";
break;
case "9":
str3 = "1001";
break;
case "A":
str3 = "1010";
break;
case "B":
str3 = "1011";
break;
case "C":
str3 = "1100";
break;
case "D":
str3 = "1101";
break;
case "E":
str3 = "1110";
break;
case "F":
str3 = "1111";
break;
}
str2 = str2 + str3
}
}
ran1 = Math.floor((Math.random() * 1000) + 1)
ran2 = Math.floor((Math.random() * 1000) + 1)
str1 = "=Slider[-100,100,1,1,100,false,true,false,false]"
ggb.evalCommand("a" + ran1 + str1)
ggb.evalCommand("a" + ran2 + str1)
str1 = "{"
for (i = 0; i < 576; i++) {
if (str2[i] == "1") {
j = (i + 1) % 24
k = 24 - Math.floor((i + 1) / 24)
str1 = str1 + "(" + j + "," + k + "),"
}
}
str1 = str1.slice(0, str1.length - 1)
str1 = str1 + "}"
str1 = "Translate[" + str1 + ",(a" + ran1 + ",a" + ran2 + ")]"
ggb.evalCommand(str1)
没有用进制转化的函数,直接用选择语句来处理数据。添加两个滑动条来控制各个字的位置。(每次数字点阵都生成在相同位置,用滑动条移开。)
下面这个命令是参考别人写的,把汉字点阵曲面化(类似圆柱侧面)
位似(旋转(映射(旋转((0, 20, 8 - x(S)), 2.5(y(S))°, z轴), S, 扁平列表(l6)), α, (0, 0, 1)), d)
再加上地球仪,全部就搞定了。