Sharp logo

MZ-800 course Chapter 7 
7. Graphical applications


7.2 Funny applications with colours

By making use of all available colours, you can get some very nice effects
and you do not even need the extra ICs. You do need a good colour monitor
or T.V. to see the effects.

Composite colours

The next program uses the 16 colours of the SHARP. By placing the lines of two different colours next to each other, controlled by PAL 1 and PAL 2, you will see a composite colour. At the top you can see which two colours are mixed.

10 INIT "CRT:M1":B=0
20 CURSOR 1,0:PRINT "PAL 1,0   PAL 2,0"
30 FOR T=0 TO 15
40 FOR Q=B TO 15
50 PAL 1,Q:PAL 2,T
60 CURSOR 7,0:PRINT Q;" ":CURSOR 19,0:PRINT T;" "
70 CURSOR 25,0:PRINT [1]CHR$(200);:PRINT " + ";:PRINT [2]CHR$(200);
80 FOR A=8 TO 320 STEP 2:LINE [2]A,8,A,199:LINE [A]A+1,8,A+1,199
90 NEXT A:WAIT 1000:BOX [0]8,8,320,199,0:BEEP:NEXT Q :B=B+1:NEXT T
100 CLS:END

Random boxes

10 INIT "CRT:M1":R=4
20 FOR A=1 TO 250
30 B=INT(RND(1)*R)
40 E=INT(RND(1)*320):F=INT(RND(1)*200)
50 C=INT(RND(1)*320):D=INT(RND(1)*200)
60 BOX [B]E,F,C,D,B
70 NEXT A
80 GET A$:IF A$="" THEN 80
90 CLS:END

If you have the extra ICs in your computer, you can make the effect even nicer by substituting line 10 with:

10 INIT "CRT:M2":R=16

Random circles

The next program is like the last one, but now we place random circles with a random size on the screen.

10 INIT "CRT:M1":R=4
20 FOR A=1 TO 100
30 B=INT(RND(1)*R)
40 E=INT(RND(1)*320)
50 F=INT(RND(1)*200)
60 C=INT(RND(1)*100)
70 CIRCLE [B]E,F,C
80 PAINT [B]E,F,B
90 NEXT A
100 GET A$:IF A$="" THEN 100
110 CLS:END

Again you can change line 10 to:

10 INIT "CRT:M2":R=16

Random line patterns

Since we are in a random mood, next will follow another program that chooses random colours, but the line pattern will remain the same each time. It looks like we use many colours, despite the fact that we only use three of them.

10 INIT "CRT:M1":Z=3
20 XM=319:YM=199
30 XC=XM/2:YC=YM/2
40 FOR X=0 TO XM
50 C=INT(RND(1)*Z)+1
60 COLOR C,0
70 LINE XC,YC,X,0
80 NEXT X
90 FOR Y=0 TO YM
100 C=INT(RND(1)*Z)+1
110 COLOR C,0
120 LINEXC,YC,XM,Y
130 NEXT Y
140 FOR X=XM TO 0 STEP -1
150 C=INT(RND(1)*Z)+1
160 COLOR C,0
170 LINE XC,YC,X,YM
180 NEXT X
190 FOR Y=YM TO 0 STEP -1
200 C=INT(RND(1)*Z)+1
210 COLOR X,0
220 LINE XC,YC,0,Y
230 NEXT Y
240 GET A$:IF A$="" THEN 240
250 CLS:END

And again you can obtain a better effect with the extra ICs:

10 INIT "CRT:M2":Z=15

All 256 colour combinations together

This program uses all 16 colours. You will need the extra ICs to run this program.

10 INIT "CRT:M2" :E=0 :F=0
20 FOR A=0 TO 127 STEP 8
30 FOR B=97 TO 224 STEP 8
40 FOR C=B TO B+7 STEP 2
50 LINE [E]C,A,C,A+7
60 LINE [F]C+1,A,C+1,A+7
70 NEXT C
80 E=E+1:IF E=60 THEN E=0:F=F+1
90 NEXT B,A
100 GET A$:IF A$="" THEN 100
110 CLS:END

Optical illusion

You will again need the extra ICs. You do not need to have a colour screen, because there are only two colours in use.

10 INIT "CRT:M2":C=1:PAL 3,7
20 SYMBOL 103,90,"Optical illusion",1,1
30 SYMBOL 128,99,"Which row",1,1
40 SYMBOL 140,107,"revolves",1,1
50 SYMBOL 144,116,"which",1,1
60 SYMBOL 132,125,"way?",1,1
70 CIRCLE 160,100,99
80 CIRCLE 160,100,58
90 FOR A=0 TO 2*pSTEP p/24
100 X=SIN(A)*89+160
110 X1=SIN(2*p-A+p/48)*79+160
120 X2=SIN(A)*69+160
130 Y=COS(A)*89+100
140 Y1=COS(2*p-A+p/48)*79+100
150 Y2=COS(A)*69+100
160 CIRCLE [C]X,Y,4:PAINT [C]X,Y,C
170 CIRCLE [C]X1,Y1,4:PAINT [C]X1,Y1,C
180 CIRCLE [C]X2,Y2,4:PAINT [C]X2,Y2,C
190 C=C+1:IF C=4 THEN C=1
200 NEXT A
210 C=1:FOR A=0 TO 200 STEP 3
220 BOX [C]0,A,30,A+2,C
230 BOX [C]31,200-A,60,200-A-2,C
240 BOX [C]260,200-A,290,200-A+2,C
250 BOX [C]291,A,320,A+2,C
260 C=C+1:IF C=4 THEN C=1
270 NEXT A
280 FOR A=1 TO 100
290 PAL 1,0:PAL 2,0:PAL 3,7:WAIT A*3
300 PAL 1,7:PAL 2,0:PAL 3,0:WAIT A*3
310 PAL 1,0:PAL 2,7:PAL 3,0:WAIT A*3
320 NEXT A
330 PAL 1,1:PAL 2,2:PAL 3,7
340 GET A$:IF A$="" THEN 340
350 CLS:END 

To the middle

10 INIT "CRT:M1":PAL 3,15:PAL 0,8
20 A=0:B=2:C=1
30 BOX [0]-1,A,320,A+B,C
40 BOX [0]-1,200-A,320,200-A-B,C
50 A=A+B:B=B+.5
60 C=C+1:IF C=4 THEN C=1
70 IF A<90 THEN 30
80 BOX [0]1,A+1,318,199-A,C
90 SYMBOL [0]80,A+5,"NEPTUNES PRODUCTIONS",1,1
100 FOR T=1 TO 50
110 WAIT 150:PAL 1,15:PAL 2,1:PAL 3,2
120 WAIT 150:PAL 1,2:PAL 2,15:PAL 3,1
130 WAIT 150:PAL 1,1:PAL 2,2:PAL 3,15
140 NEXT T
150 SYMBOL 80,A+5,"NEPTUNES PRODUCTIONS",1,1
160 GET A$:IF A$="" THEN 160
170 CLS:END

Kaleidoscope

10 INIT "CRT:M2"
20 A=15:B=12:C=0
30 FOR X=0 TO B-1
40 FOR Y=X TO B-1
50 Z=0
60 Z=C+X+Y:IF Z>31 THEN Z=Z-32
70 IF Z>15 THEN Z=Z-16
80 CURSOR A+X,Y+B:PRINT [Z]CHR$(200)
90 CURSOR A+X,-Y+B:PRINT [Z]CHR$(200)
100 CURSOR A-X,Y+B:PRINT [Z]CHR$(200)
110 CURSOR A-X,-Y+B:PRINT [Z]CHR$(200)
120 CURSOR A+Y,X+B:PRINT [Z]CHR$(200)
130 CURSOR A+Y,-X+B:PRINT [Z]CHR$(200)
140 CURSOR A-Y,X+B:PRINT [Z]CHR$(200)
150 CURSOR A-Y,-X+B:PRINT [Z]CHR$(200)
160 NEXT Y,X
170 C=C+1:IF C=16 THEN C=0
180 GOTO 30

This program keeps running until you press SHIFT/BREAK.
This was the last program of this part of Chapter 7. Of course, there are many more possibilities to with colours, but that we leave that creativity to you. These programs give you a nice insight into the possibilities on the subject of colours.

Previous page
Next page
Contents


Go to the top of this page Home

last updated February 4, 2008
Arjan Habing, Mark de Rover, Jeroen F. J. Laros, sharpmz@sharpmz.org