|
回転角度と楕円領域の大きさとその中心座標をスライドバーで指定します。
スライドバーを動かした後、グラフィックウィンドゥ内をマウスでクリックしてください。
OPTION BASE 0
FILE GETNAME N$,"BMP,JPG,GIF,PNGファイル|*.BMP;*.JPG;*.GIF;*.PNG"
CALL PICTURELOAD(N$,XSIZE,YSIZE)
DIM M(XSIZE-1,YSIZE-1),MM(XSIZE-1,YSIZE-1)
ASK PIXEL ARRAY(0,0) M
LOCATE VALUE NOWAIT(1),RANGE 1 TO 90,AT 10:ALPHA
LOCATE VALUE NOWAIT(2),RANGE 0 TO XSIZE-1,AT XSIZE/2:X0
LOCATE VALUE NOWAIT(3),RANGE 0 TO YSIZE-1,AT YSIZE/2:Y0
LOCATE VALUE NOWAIT(4),RANGE 1 TO XSIZE/2,AT XSIZE/10:XR
LOCATE VALUE NOWAIT(5),RANGE 1 TO YSIZE/2,AT YSIZE/10:YR
DO
CLEAR
SET TEXT HEIGHT YSIZE/10
SET COLOR COLORINDEX(0,0,0)
SET TEXT BACKGROUND "OPAQUE"
SET TEXT JUSTIFY "CENTER" , "TOP"
PLOT TEXT ,AT XSIZE/2,YSIZE/2 :"処理中"
LET ALPHA=INT(ALPHA)
LET X0=INT(X0)
LET Y0=INT(Y0)
LET XR=INT(XR)
LET YR=INT(YR)
FOR Y=0 TO YSIZE-1
SET TEXT JUSTIFY "LEFT" , "TOP"
PLOT TEXT ,AT 0,0 :USING$("###.#",Y/(YSIZE-1)*100)&"%"
FOR X=0 TO XSIZE-1
IF GetKeyState(32)<0 OR GetKeyState(13)<0 OR GetKeyState(27)<0 THEN STOP
IF ((X-X0)/XR)^2+((Y-Y0)/YR)^2>1 THEN
LET RX=SQR((X-X0)^2+(Y-Y0)^2)
IF X-X0=0 THEN
IF Y-Y0>0 THEN LET TH=PI/2 ELSE LET TH=1.5*PI
ELSE
LET TH=ANGLE(X-X0,Y-Y0)
END IF
LET RR=0
LET GG=0
LET BB=0
FOR I=0 TO ALPHA-1
IF GetKeyState(32)<0 OR GetKeyState(13)<0 OR GetKeyState(27)<0 THEN STOP
LET XX=INT(RX*COS(TH+I*PI/180))+X0
LET YY=INT(RX*SIN(TH+I*PI/180))+Y0
IF XX>=0 AND XX<=XSIZE-1 AND YY>=0 AND YY<=YSIZE-1 THEN LET CC=M(XX,YY) ELSE EXIT FOR
CALL RGB(CC,R,G,B)
LET RR=RR+R
LET GG=GG+G
LET BB=BB+B
NEXT I
LET RR=INT(RR/(I+1))
LET GG=INT(GG/(I+1))
LET BB=INT(BB/(I+1))
LET MM(X,Y)=SETRGB(RR,GG,BB)
ELSE
LET CC=M(X,Y)
CALL RGB(CC,R,G,B)
LET MM(X,Y)=SETRGB(R,G,B)
END IF
NEXT X
NEXT Y
MAT PLOT CELLS , IN 0,0; XSIZE-1,YSIZE-1:MM
DO !'ウェイト。マウスでウィンドゥ内をクリックする。
IF GetKeyState(32)<0 OR GetKeyState(13)<0 OR GetKeyState(27)<0 THEN STOP
MOUSE POLL X,Y,LL,RR
LOCATE VALUE NOWAIT(1):ALPHA
LOCATE VALUE NOWAIT(2):X0
LOCATE VALUE NOWAIT(3):Y0
LOCATE VALUE NOWAIT(4):XR
LOCATE VALUE NOWAIT(5):YR
LOOP WHILE LL=0 AND RR=0
LOOP
END
EXTERNAL FUNCTION SETRGB(R,G,B)
LET R=MIN(255,MAX(R,0))
LET G=MAX(0,MIN(G,255))
LET B=MAX(0,MIN(B,255))
LET SETRGB=B*65536+G*256+R
END FUNCTION
EXTERNAL SUB RGB(X,R,G,B)
LET B=MOD(INT(X/65536),256)
LET G=MOD(INT(X/256),256)
LET R=MOD(X,256)
END SUB
EXTERNAL SUB PICTURELOAD(N$,XSIZE,YSIZE)
CLEAR
SET COLOR MODE "NATIVE"
SET POINT STYLE 1
IF N$="" THEN STOP
GLOAD N$
LET XSIZE=PIXELX(1)+1
LET YSIZE=PIXELY(1)+1
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0,XSIZE-1,YSIZE-1,0
END SUB
|
|