B-draw.bas
运行环境:BASIC.EXE
程序:
10 XM=619:YM=199:N=50:CLS:KEY OFF:SCREEN 2:GOSUB 120
20 CLS:FOR S=0 TO NV-1 :LINE(P(1,S),P(2,S))-(P(1,S+1),P(2,S+1)):NEXT:U=0:GOSUB 170
30 X1=X:Y1=Y
40 FOR K=1 TO N:U=(K/N)*NV:GOSUB 170
50 X2=X:Y2=Y:LINE(X1,Y1)-(X2,Y2):X1=X2:Y1=Y2:NEXT
60 INPUT"改动吗";A$:IF A$<>"Y" THEN 110
70 INPUT"控制点号";NUM
80 INPUT "控制点坐标 XC,YC";XC,YC:P(1,NUM)=XC:P(2,NUM)=YC:LOCATE 1,1:INPUT"满意吗";B$:IF B$="N" THEN 70
90 GOSUB 130
100 GOTO 20
110 END
120 INPUT"控制点个数 N= ";NV:DIM P(2,NV+2) :FOR J=0 TO NV:INPUT "控制点坐标 XC,YC ";XC,YC:P(1,J)=XC:P(2,J)=YC:NEXT
130 IF P(1,0)=P(1,NV) AND P(2,0)=P(2,NV) THEN 150
140 FOR I=1 TO 2:P(I,NV+2)=P(I,0)*2-P(I,1):P(I,NV+1)=P(I,NV)*2-P(I,NV-1):NEXT:GOTO 160
150 FOR I=1 TO 2:P(I,NV+2)=P(I,NV-1):P(I,NV+1)=P(I,1):NEXT
160 CLS:RETURN
170 X=0:Y=0:FOR J=0 TO NV+1:GOSUB 210
180 X=X+P(1,J)*BS:Y=Y+P(2,J)*BS:NEXT
190 J=-1:GOSUB 210
200 X=X+P(1,NV+2)*BS:Y=Y+P(2,NV+2)*BS:RETURN
210 BX=U-J:IF BX>=-1 AND BX<=1 THEN 240
220 IF (BX>1 AND BX<2) OR (BX<=1 AND BX>-2) THEN 250
230 BS=0:GOTO 260
240 BS=(ABS(BX))^3/2-BX^2+2/3:GOTO 260
250 BS=-(ABS(BX))^3/6+BX^2-2*ABS(BX)+4/3
260 RETURN |