円形変換

 投稿者:しばっち  投稿日:2015年 5月30日(土)22時08分48秒
  !' 方程式 x^n+y^n=r^n を使用して円形変換します(n=2の時)
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
LET N=1.5 !' N=2で円形変換
IF XSIZE>YSIZE THEN
   LET R=YSIZE/2
   FOR YS=0 TO YSIZE-1
      LET Y=YS-YSIZE/2
      LET R1=(R^N-ABS(Y)^N)^(1/N)
      FOR XS=0 TO XSIZE-1
         LET XX=-R1+XS*R1/R*YSIZE/XSIZE
         LET YY=Y
         LET C=M(XS,YS)
         CALL RGB(C,RR,GG,BB)
         CALL PSET(XX+XSIZE/2,YY+YSIZE/2,RR,GG,BB)
      NEXT XS
   NEXT YS
ELSE
   LET R=XSIZE/2
   FOR XS=0 TO XSIZE-1
      LET X=XS-XSIZE/2
      LET R1=(R^N-ABS(X)^N)^(1/N)
      FOR YS=0 TO YSIZE-1
         LET YY=-R1+YS*R1/R*XSIZE/YSIZE
         LET XX=X
         LET C=M(XS,YS)
         CALL RGB(C,RR,GG,BB)
         CALL PSET(XX+XSIZE/2,YY+YSIZE/2,RR,GG,BB)
      NEXT  YS
   NEXT  XS
END IF
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

 

戻る