UF中独缺这谢氏地毯,今用前面外迭代法,造一个。
代码如下:
Sierpinski正方形地毯** {
init:
z = #pixel
bool bail = false
loop:
x = real(z)
y = imag(z)
if abs(x) <0.4&&abs(y) <0.4
bail = true
elseif y>0.4&& abs(x) <0.4
z = 3*z - 1i*2.4
elseif y<-0.4&& abs(x) <0.4
z = 3*z + 1i*2.4
elseif x>0.4&& abs(y) <0.4
z = 3*z -2.4
elseif x<-0.4&& abs(y) <0.4
z = 3*z +2.4
elseif x<-0.4&& y>0.4
z = 3*z +2.4-1i*2.4
elseif x>0.4&& y>0.4
z = 3*z -2.4-1i*2.4
elseif x<-0.4&& y<-0.4
z = 3*z +2.4+1i*2.4
elseif x>0.4&& y<-0.4
z = 3*z -2.4+1i*2.4
endif
bailout:
bail == false
default:
title = "Sierpinski正方形地毯"
helpfile = "sam-help/various.htm"
helptopic = "sierp2"
center = (0,0.0)
} |