PLOT TEXT

 投稿者:SECOND  投稿日:2009年12月14日(月)21時35分26秒
  ! PLOT TEXT 文字の、鏡像テスト。
!
!-------------------
LET N=1  !0,1,2, 通常の万華鏡は2にする。
LET NN=2^N
SET TEXT JUSTIFY "center","half"
SET TEXT BACKGROUND "OPAQUE"
ASK PIXEL SIZE (0,0;1,1) xx,yy
LET xx=xx/2
LET yy=yy/2
SET WINDOW -xx/NN,xx/NN, -yy/NN,yy/NN

LET φ=0
LET stp=-PI/180*6
DO
   LET t=INT(TIME)
   IF t0<>t THEN
      LET t0=t
      IF 2*PI<=ABS(φ) THEN LET stp=-stp
      LET φ=REMAINDER(φ, 2*PI) +stp
      !-----
      SET DRAW mode hidden
      CLEAR
      SET TEXT font "Century",12*NN
      DRAW D4(N) WITH SHIFT(-300/2,-300/2/SQR(3))*ROTATE(φ*(-1)^N)*SCALE(1,(-1)^N)
      SET TEXT font "Century",12
      PLOT TEXT,AT (xx-80)/NN,(yy-10)/NN:"Right Click to Stop"
      DRAW center WITH SHIFT(-300/2/NN,-300/2/SQR(3)/NN)*ROTATE(φ)
      SET DRAW mode explicit
   END IF
   WAIT DELAY 0 ! 省電力効果
   MOUSE POLL mx,my,mlb,mrb
LOOP UNTIL mrb>=1 ! 右クリックで停止

PICTURE center
   SET LINE COLOR 2
   SET LINE width 2
   PLOT LINES:0,0; 300/NN,0; 300/2/NN,300*SQR(3)/2/NN; 0,0
   SET LINE width 1
   SET LINE COLOR 1
END PICTURE

!------
PICTURE D4(k)
   IF 0< k THEN
      DRAW D4(k-1) WITH SCALE(1/2,1/2)*SHIFT(300/4,SQR(3)*300/4) ! 内側の上
      DRAW D4(k-1) WITH SCALE(1/2,-1/2)*SHIFT(300/4,SQR(3)*300/4) ! 内側の中
      DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(-PI*2/3)*SHIFT(300/4,SQR(3)*300/4) !内側の左
      DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(PI*2/3)*SHIFT(300,0) ! 内側の右
   ELSE
      DRAW A_Clock WITH ROTATE(-φ)*SHIFT(300/2,300/2/SQR(3))
      PLOT LINES:0,0; 300,0; 300/2,300*SQR(3)/2; 0,0 ! 外側の基準三角形
   END IF
END PICTURE

!------
PICTURE A_Clock
   SET AREA COLOR 1
   FOR i=1 TO 60
      LET a=-PI/30*(i-15)
      IF MOD(i,5)=0 THEN
         PLOT TEXT,AT 60*COS(a)+.5, 60*SIN(a) :STR$(i/5)           !数字
         ! CALL Plot_7segment( 60*COS(a) ,60*SIN(a) ,5.5 ,STR$(i/5)) !数字(代替)
      END IF
      DRAW disk WITH SCALE(1-.5*SGN(MOD(i,5)))*SHIFT(72*COS(a),72*SIN(a)) !分目盛り
   NEXT i
   !---
   DRAW hand(1) WITH SCALE(2.5, 0.75)*ROTATE(-t*PI/21600) !時針
   DRAW hand(1) WITH ROTATE(-t*PI/1800)                   !分針
   DRAW hand(1) WITH SCALE(0, 1.1)*ROTATE(-t*PI/30)       !秒針
   DRAW disk WITH SHIFT(0,0)*SCALE(4)                     !中心の飾り
END PICTURE

PICTURE hand(c)
   SET AREA COLOR c
   PLOT AREA: -1,-15; 1,-15; 1,60; -1,60    !3針共用、0時位置の針
END PICTURE

!--------------------------------------------------------------------------
SUB Plot_7segment(x,y,s,i$) !文字列中心(x,y) 文字の横幅(s) 数字の文字列(i$)
   LET w=LEN(i$)
   LET s1=s      ! y軸↑:s1=s  y軸↓:s1=-s
   LET s2=s/2
   LET x=x-(w-1)*s2*1.6
   FOR p=1 TO w
      SELECT CASE VAL(i$(p:p))
      CASE 0
         PLOT LINES:x-s2,y+s;x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s
      CASE 1
         PLOT LINES:x,y-s;x,y+s
      CASE 2
         PLOT LINES:x-s2,y+s1;x+s2,y+s1;x+s2,y;x-s2,y;x-s2,y-s1;x+s2,y-s1
      CASE 3
         PLOT LINES:x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s
         PLOT LINES:x-s2,y;x+s2,y
      CASE 4
         PLOT LINES:x-s2,y+s1;x-s2,y;x+s2,y
         PLOT LINES:x+s2,y+s1;x+s2,y-s1
      CASE 5
         PLOT LINES:x+s2,y+s1;x-s2,y+s1;x-s2,y;x+s2,y;x+s2,y-s1;x-s2,y-s1
      CASE 6
         PLOT LINES:x+s2,y+s1;x-s2,y+s1;x-s2,y-s1;x+s2,y-s1;x+s2,y;x-s2,y
      CASE 7
         PLOT LINES:x-s2,y+s1;x+s2,y+s1;x+s2,y-s1
      CASE 8
         PLOT LINES:x-s2,y;x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s;x-s2,y;x+s2,y
      CASE 9
         PLOT LINES:x+s2,y;x-s2,y;x-s2,y+s1;x+s2,y+s1;x+s2,y-s1;x-s2,y-s1
      CASE ELSE
      END SELECT
      LET x=x+s*1.6
   NEXT p
END SUB

END
 

戻る