三角形変換

 投稿者:しばっち  投稿日:2015年 5月30日(土)22時03分50秒
  !' 三角形変換
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
!'三角形変換
!' X'=2*TAN(T/2)*X*Y/L
!' Y'=Y
!'逆変換
!' X=L*X'/(2*TAN(T/2)*Y')
!' Y=Y'
!'INPUT  PROMPT "L=":L
LET L=XSIZE-1
!'INPUT  PROMPT "角度(0 - 90)=":TH
!'LET T=RAD(TH)
LET T=2*ATN((XSIZE/2)/YSIZE)
CLEAR
FOR YS=1 TO YSIZE-1
   LET Y=YS-YSIZE/2
   FOR XS=0 TO XSIZE-1
      LET X=XS-XSIZE/2
      LET XX=L*X/(2*TAN(T/2)*(Y+YSIZE/2))
      LET YY=Y
      IF XX>=-XSIZE/2 AND XX<=XSIZE/2-1 AND YY>=-YSIZE/2 AND YY<=YSIZE/2-1 THEN
         LET C=M(INT(XX+XSIZE/2),INT(YY+YSIZE/2))
         CALL RGB(C,R,G,B)
         CALL PSET(X+XSIZE/2,Y+YSIZE/2,R,G,B)
      END IF
   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
 

三角形変換

 投稿者:しばっち  投稿日:2015年 5月30日(土)22時08分5秒
  !'三角形変換
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 MODE=0
SELECT CASE MODE
CASE 0
   LET X1=XSIZE/2
   LET Y1=0
   LET X2=0
   LET Y2=YSIZE-1
   LET X3=XSIZE-1
   LET Y3=YSIZE-1
CASE 1
   LET X1=XSIZE/2
   LET Y1=YSIZE-1
   LET X2=0
   LET Y2=0
   LET X3=XSIZE-1
   LET Y3=0
END SELECT
FOR Y=0 TO YSIZE-1
   FOR X=0 TO XSIZE-1
      LET XA=(X2-X1)/(Y2-Y1)*(Y-Y1)+X1
      LET XB=(X3-X1)/(Y3-Y1)*(Y-Y1)+X1
      LET XX=XA+(XB-XA)/XSIZE*X
      LET YY=Y
      LET C=M(X,Y)
      CALL RGB(C,R,G,B)
      CALL PSET(XX,YY,R,G,B)
   NEXT X
NEXT Y
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

 

戻る