扇形変換

 投稿者:しばっち  投稿日:2015年 5月30日(土)22時05分48秒
  !'扇形変換
FILE GETNAME F$,"BMP,JPG,GIF,PNGファイル|*.BMP;*.JPG;*.GIF;*.PNG"
CALL PICTURELOAD(F$,XSIZE,YSIZE)
DIM M(0 TO XSIZE-1,0 TO YSIZE-1)
ASK PIXEL ARRAY (0,0) M
CLEAR
!'INPUT  PROMPT "角度(0 - 180)=":T
FOR T=180 TO 0 STEP -1 !'最大角度探索
   LET TH=(XSIZE-1-XS)/(XSIZE-1)*T-(180-(180-T)/2)
   LET R=YSIZE-YS
   LET XX=R*COS(RAD(TH))
   IF XX+XSIZE/2>=0 AND XX+XSIZE/2<XSIZE THEN EXIT FOR
NEXT T
FOR YS=0 TO YSIZE-1 STEP .5
   FOR XS=0 TO XSIZE-1 STEP .5
      LET TH=(XSIZE-1-XS)/(XSIZE-1)*T-(180-(180-T)/2)
      LET R=YSIZE-YS
      LET XX=R*COS(RAD(TH))
      LET YY=R*SIN(RAD(TH))
      LET C=M(XS,YS)
      CALL RGB(C,RR,GG,BB)
      CALL PSET(XX+XSIZE/2,YY+YSIZE,RR,GG,BB)
   NEXT XS
NEXT YS
END

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 GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET COLOR MODE "NATIVE"
CLEAR
SET POINT STYLE 1
SET WINDOW 0,XSIZE-1,YSIZE-1,0
END SUB

EXTERNAL SUB PSET(X,Y,R,G,B)
SET COLOR COLORINDEX(R/255,G/255,B/255)
PLOT POINTS:X,Y
END SUB

EXTERNAL SUB PICTURELOAD(N$,XSIZE,YSIZE)
SET COLOR MODE "NATIVE"
CLEAR
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

 

戻る