こちらは一旦ビットマップ上に図形を作画して完成後に実画面に表示します。
こうすることで、わずか40秒で描画します(iPad3)。
また、他のビットマップ関数のテストも兼ねています。
参考文献:Oh!X 1988 3月号 X68000BASIC入門 中森章
// 自己平方根フラクタル図形描画
// ビットマップ利用型
// fdirect=NO
// +タイル貼り付け
// +ビットマップ関数テスト
// for X-BASIC for iOS v2.0
width(64)
//
vpriority(TPAGE,GPAGE0,GPAGE1,GPAGE2,GPAGE3)
vpage(B_TPAGE+B_GPAGE0+B_GPAGE1+B_GPAGE2+B_GPAGE3,YES)
apage(GPAGE0)
//
int wx=512,wy=512
if YES then {://------------------------------------
bitmapOpen(wx,wy)
drawFractal(wx,wy,0)
bitmapImgLoad(128,128,wx,wy):// ここのwx,wyはfloat変換される
bitmapClose()
//
hitKey()
wipe()
wx=128
wy=128
dim int getAry(128*128)
//int size1
//int youso=sizeofArray(getAry,size1)
//print "要素数=";youso;"/1要素サイズ=";size1
bitmapOpen(wx,wy)
drawFractal(wx,wy,5)
bitmapTileImgLoad(128.0,128.0,512.0,512.0)
bitmapGet(0,0,64,64,getAry)
bitmapClose()
//
hitKey()
wipe()
wx=512:wy=512
bitmapOpen(wx,wy)
int i,sx,sy,ex,ey,col,h,s
for i=0 to 10
h=rnd()*360
s=rnd()*256
col=hsv(h,s,255,255)
//
sx=rand() mod wx
ex=rand() mod wx
sy=rand() mod wy
ey=rand() mod wy
bitmapLine(sx,sy,ex,ey,col)
//
sx=rand() mod wx
ex=rand() mod wx
sy=rand() mod wy
ey=rand() mod wy
bitmapBox(sx,sy,ex,ey,col)
//
sx=rand() mod wx
ex=rand() mod wx
sy=rand() mod wy
ey=rand() mod wy
bitmapFill(sx,sy,ex,ey,col)
//
sx=rand() mod wx
sy=rand() mod wy
ex=rand() mod 100+1:// 半径
locate(0,i):print "x,y,r=";sx,sy,ex
bitmapCircle(sx,sy,ex,col)
bitmapPaint(sx,sy,col)
next
bitmapPut(200,200,200+64,200+64,getAry)
bitmapImgLoad(128,128,wx,wy):// ここのwx,wyはfloat変換される
bitmapClose()
//
hitKey()
}://------------------------------------
if YES then {://------------------------------------
// bitmapImageFile()のテスト
// 存在する画像ファイル名を記述すること
wipe()
wx=512:wy=512
bitmapOpen(wx,wy)
//
bitmapImageFile("IMG1.JPG",10,10,256,256)
bitmapImgLoad(128,128,wx,wy):// ここのwx,wyはfloat変換される
hitKey()
//
bitmapImageFile("IMG2.PIC")
bitmapImgLoad(128,128,wx,wy):// ここのwx,wyはfloat変換される
hitKey()
//
bitmapImageFile("GAROU.CUT")
bitmapImgLoad(128,128,wx,wy):// ここのwx,wyはfloat変換される
//
bitmapClose()
}://------------------------------------
//
end
//---------
func drawFractal(wx;int,wy;int,ty;int)
locate(0,ty+0):print "wx*wy=";wx;"*";wy
locate(0,ty+1):print "start=";time$
//
int MAXREP=50
int MAXDOT=wx
int MAXCOL=255
float remin=-0.5#
float remax= 0.5#
float immin=-0.5#
float immax= 0.5#
float recon=-0.04#
float imcon=-0.695#
int rep,ix,iy
float x,y,re,im,dx,dy
//
dx=(remax-remin)/MAXDOT
dy=(immax-immin)/MAXDOT
//
for iy=0 to MAXDOT-1
locate(0,ty+2):print "line=";iy
for ix=0 to MAXDOT-1
x=remin+ix*dx
y=immin+iy*dy
for rep=0 to MAXREP
re=x*x-y*y+recon
im=2#*x*y+imcon
if ((re*re+im*im)>4#) then break
x=re:y=im
next
int c=(rep mod MAXCOL)*4
bitmapPset(ix,iy,c,c,c,255)
//gcolor(c,c,c,255)
//pset(ix,iy)
next
next
locate(0,ty+2):print "end=";time$
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 件のコメント:
コメントを投稿