波形変換

 投稿者:しばっち  投稿日:2015年 5月30日(土)22時04分35秒
  !' 波形変換
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
INPUT  PROMPT "A (1 - 10)=":A
INPUT  PROMPT "B (1 - 5)=":B
!' 波形変換
!' X'=X+A*SIN(B*Y)
!' Y'=Y+A*SIN(B*X)
!' 波形変換
!' X'=X+A*SIN(B*Y)
!' Y'=Y
!' 逆変換
!' X=X'-A*SIN(B*Y')
!' Y=Y'
LET MODE=0
CLEAR
SELECT CASE MODE
CASE 0
   FOR Y=0 TO YSIZE-1
      LET XX=MAX(XX,XSIZE-1+INT(A*SIN(B*Y*PI/180)))
   NEXT Y
   FOR X=0 TO XSIZE-1
      LET YY=MAX(YY,YSIZE-1+INT(A*SIN(B*X*PI/180)))
   NEXT X
   CALL GINIT(INT(XX),INT(YY))
   FOR Y=0 TO YSIZE-1 STEP .5
      FOR X=0 TO XSIZE-1 STEP .5
         LET XA=X+A*SIN(B*Y*PI/180)
         LET YA=Y+A*SIN(B*X*PI/180)
         LET C=M(X,Y)
         CALL RGB(C,RR,GG,BB)
         CALL PSET(XA,YA,RR,GG,BB)
      NEXT X
   NEXT Y
CASE 1
   FOR Y=0 TO YSIZE-1
      FOR X=0 TO XSIZE-1
         LET XA=X
         LET YA=Y-A*SIN(B*X*PI/180)
         IF XA>=0 AND XA<=XSIZE-1 AND YA>=0 AND YA<=YSIZE-1 THEN
            LET C=M(XA,INT(YA))
            CALL RGB(C,RR,GG,BB)
            CALL PSET(X,Y,RR,GG,BB)
         END IF
      NEXT X
   NEXT Y
CASE 2
   FOR Y=0 TO YSIZE-1
      FOR X=0 TO XSIZE-1
         LET XA=X-A*SIN(B*Y*PI/180)
         LET YA=Y
         IF XA>=0 AND XA<=XSIZE-1 AND YA>=0 AND YA<=YSIZE-1 THEN
            LET C=M(INT(XA),YA)
            CALL RGB(C,RR,GG,BB)
            CALL PSET(X,Y,RR,GG,BB)
         END IF
      NEXT X
   NEXT Y
END SELECT
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
 

戻る