// グラフィック画面初期化
//
width(64)
vpriority(TPAGE,GPAGE0,GPAGE1,GPAGE2,GPAGE3)
vpage(B_TPAGE or B_GPAGE0 or B_GPAGE1 or B_GPAGE2 or B_GPAGE3,YES)
apage(GPAGE0)
tborder(4,&hffd700ff):// gold
gborder(2,&h008080ff):// teal
//
// Oh!X 1988/5 p58
// Turtle Graphic - コッホ曲線
int n
input "n(<=8)=";n
// 理論上はいくつでもいけるが、描画上はこれがほぼ限界
if n>8 then n=8
locate(0,2):print "n=";n
set(64,64)
right(90)
pencolor(rgb(255,255,255,255))
Koch(n,200*(n+3))
//
print time$
wait(5)
print time$
//hitKey()
wipe()
//
// Oh!X 1988/5 p57
// Turtle Graphic - Triangle
float turtle_x,turtle_y,turtle_arg
int turtle_color
int i ,j,k,x,y,length
x=64
for k=0 to 4: // 横個数
y=128
for j = 0 to 4: // 縦個数
tcolor(CTHWHITE)
locate(0,5):print "k,j=";k,j
set(x,y)
right(rnd()*360)
int h=rnd()*360
int s=rnd()*256
//locate(0,10):print "h=";h;"/s=";s
pencolor(hsv(h,s,255,255))
for i=1 to 20
length=5*i
forward(length)
right(120)
forward(length)
right(120)
forward(length)
right(140)
next
y=y+128
next
x=x+128
next
end
//---------
func Koch(n;int,length;float)
if n>0 then {
Koch(n-1,length/4#)
right(-45)
Koch(n-1,length/4#)
right(90)
Koch(n-1,length/4#)
right(-45)
Koch(n-1,length/4#)
} else {
forward(length)
}
endfunc
//---------
func set(x;float,y;float)
// tcolor(&hcc6633ff)
locate(0,0):print "x,y=";x,y
turtle_x=x
turtle_y=y
turtle_arg=2#*pi()
endfunc
//---------
func forward(length;float)
float x,y
x=turtle_x
y=turtle_y
turtle_x=turtle_x+cos( turtle_arg ) *length
turtle_y=turtle_y-sin( turtle_arg ) *length
gcolor(turtle_color)
line(x,y, turtle_x,turtle_y)
endfunc
//---------
func right(arg;float)
turtle_arg = turtle_arg-arg/180#*pi()
endfunc
//
func pencolor(col;int)
locate(0,1)
print "color=&h";right$("00000000"+hex$(col),8);
int r,g,b,alpha
splitRGB(col,r,g,b,alpha)
print using "/r=###/g=###/b=###";r;g;b
turtle_color=col
endfunc
//---------
func hitKey()
setFunctionKey(0,localizedString("ここを押してください","Hit This Button"),'!')
displayFunctionKey(YES,0,0)
while inkey()=0
endwhile
cls()
displayFunctionKey(NO,0,0)
endfunc
//---------
func str localizedString(js;str,es;str)
if isLocalizeJapan() then return(js)
return (es)
endfunc
//---------

Zipファイル :XBetc.zip
0 件のコメント:
コメントを投稿