/[james]/archive/graphical/Blend
ViewVC logotype

Annotation of /archive/graphical/Blend

Parent Directory Parent Directory | Revision Log Revision Log


Revision 28 - (hide annotations) (download)
Fri Mar 14 14:57:29 2003 UTC (21 years, 8 months ago) by james
File size: 3105 byte(s)
Initial import.

1 james 28 REM > Blend
2    
3     ONERRORONERROROFF:MODE27:REPORT:PRINTERL:END
4    
5     DIM g%(50, 50)
6    
7     REPEAT
8    
9     MODE 28 :REM 640 x 480
10     VDU 28, 0, 0, 79, 0
11    
12     REPEAT
13     INPUT "Grid width: "w$
14     w% = VAL(w$)
15     IF w% > 50 THEN VDU7: PRINT "Maximum is 50";: g=GET: PRINT
16     IF w% < 2 THEN VDU7: PRINT "Minimum is 2";: g=GET: PRINT
17     UNTIL (w% <= 50) AND (w% > 1)
18     REPEAT
19     INPUT "Grid height: "h$
20     h% = VAL(h$)
21     IF h% > 50 THEN VDU7: PRINT "Maximum is 50";: g=GET: PRINT
22     IF h% < 2 THEN VDU7: PRINT "Minimum is 2";: g=GET: PRINT
23     UNTIL (h% <= 50) AND (h% > 1)
24    
25     OFF
26    
27     dx% = 1279 / w%
28     dy% = 920 / h%
29     IF dx% < dy% THEN d% = dx% ELSE d% = dy%
30    
31     GCOL %111111 TINT %11
32     FOR x% = 0 TO w%
33     LINE x% * d%, 0, x% * d%, h% * d%
34     NEXT
35     FOR y% = 0 TO h%
36     LINE 0, y% * d%, w% * d%, y% * d%
37     NEXT
38    
39     g%() = 0
40    
41     PRINT "Use 0-6 to choose colours and mouse to place atoms; press space to start";
42    
43     MOUSE ON
44     MOUSE RECTANGLE 0, 0, w% * d% - 1, h% * d% - 1
45    
46     MOUSE X%, Y%, Z%
47     ox% = X% / d% + 1
48     oy% = Y% / d% + 1
49     c% = 1
50     GCOL %000011 TINT %11
51    
52     REPEAT
53     MOUSE X%, Y%, Z%
54     x% = X% / d% + 1
55     y% = Y% / d% + 1
56     i$ = INKEY$(0)
57     IF (x% <> ox%) OR (y% <> oy%) THEN
58     PRINT '"Coordinates: "+STR$x%+", "+STR$y%;
59     ox% = x%
60     oy% = y%
61     ENDIF
62     CASE i$ OF
63     WHEN "1": c% = 1: GCOL %000011 TINT %11: PRINT '"Red selected";
64     WHEN "2": c% = 2: GCOL %001100 TINT %11: PRINT '"Green selected";
65     WHEN "3": c% = 3: GCOL %110000 TINT %11: PRINT '"Blue selected";
66     WHEN "4": c% = 4: GCOL %001111 TINT %11: PRINT '"Yellow selected";
67     WHEN "5": c% = 5: GCOL %110011 TINT %11: PRINT '"Magenta selected";
68     WHEN "6": c% = 6: GCOL %111100 TINT %11: PRINT '"Cyan selected";
69     WHEN "0": c% = 0: GCOL %000000 TINT %00: PRINT '"Removing atoms";
70     ENDCASE
71     IF Z% > 0 THEN
72     g%(x%, y%) = c%
73     CIRCLE FILL x% * d% - (d% / 2), y% * d% - (d% / 2), (d% / 2) - 4
74     ENDIF
75     UNTIL i$ = " "
76    
77     MOUSE OFF
78    
79     GCOL %000000 TINT %00
80     FOR x% = 1 TO w% - 1
81     LINE x% * d%, 2, x% * d%, h% * d% - 1
82     NEXT
83     FOR y% = 1 TO h% - 1
84     LINE 2, y% * d%, w% * d% - 1, y% * d%
85     NEXT
86    
87     PRINT '"Diffusing... press a key to end";
88    
89     REPEAT
90     x% = RND(w%)
91     y% = RND(h%)
92     tx% = x%
93     ty% = y%
94     IF g%(x%, y%) > 0 THEN
95     CASE RND(8) OF
96     WHEN 1: ty% += 1
97     WHEN 2: tx% += 1: ty% += 1
98     WHEN 3: tx% += 1
99     WHEN 4: tx% += 1: ty% -= 1
100     WHEN 5: ty% -= 1
101     WHEN 6: tx% -= 1: ty% -= 1
102     WHEN 7: tx% -= 1
103     WHEN 8: tx% -= 1: ty% += 1
104     ENDCASE
105     IF (tx% > 0) AND (ty% > 0) AND (tx% <= w%) AND (ty% <= h%) THEN
106     IF g%(tx%, ty%) = 0 THEN
107     g%(tx%, ty%) = g%(x%, y%)
108     g%(x%, y%) = 0
109     GCOL %000000 TINT %00
110     CIRCLE FILL x% * d% - (d% / 2), y% * d% - (d% / 2), (d% / 2) - 4
111     CASE g%(tx%, ty%) OF
112     WHEN 1: GCOL %000011 TINT %11
113     WHEN 2: GCOL %001100 TINT %11
114     WHEN 3: GCOL %110000 TINT %11
115     WHEN 4: GCOL %001111 TINT %11
116     WHEN 5: GCOL %110011 TINT %11
117     WHEN 6: GCOL %111100 TINT %11
118     ENDCASE
119     CIRCLE FILL tx% * d% - (d% / 2), ty% * d% - (d% / 2), (d% / 2) - 4
120     ENDIF
121     ENDIF
122     ENDIF
123     UNTIL INKEY(0) > -1
124    
125     PRINT '"Press a key...";
126     IF GET
127    
128     UNTIL 0

  ViewVC Help
Powered by ViewVC 1.1.26