REM Conic Conic Anamorphosis
REM Paste the transformed  picture pasted on the cone,
REM and view it from the direction of the axis.
! LET alpha=1/2*PI              ! virtical angle of a cone 
LET alpha=1/3*PI              ! virtical angle of a cone
SET COLOR MODE "NATIVE"
GLOAD "zenkouji.jpg"
ASK PIXEL SIZE (1,0;0,1)a,b
DIM c(a,b)
ASK PIXEL ARRAY (0,1) c
! c(1,1) left top end, c(a,b) right bottom end
CLEAR
SET bitmap SIZE 801, 801
SET WINDOW -400,400,-400,400
SET POINT STYLE 1
FOR y=-400 TO 400
   FOR x=-400 TO 400
      LET r=SQR(x^2+y^2)*SIN(alpha/2)
      IF r<>0 THEN LET t=ANGLE(x,y)/SIN(alpha/2)
      IF ABS(t)<=PI THEN
         LET i=ROUND(1/2 + a/2 + r*COS(t), 0)  ! left 1, right a 
         LET j=ROUND(1/2 + b/2 - r*SIN(t), 0)  ! top 1Cbottom b
         IF 1<=i AND i<=a AND 1<=j AND j<=b THEN
            SET POINT COLOR c(i,j)            
            PLOT POINTS:x,y
         END IF
      END IF 
   NEXT x
NEXT y
END
 
 
