<* WOFF + *> (* Compile optie: toon geen vervelende warnings *) MODULE permutatie; FROM IO IMPORT RdChar, WrChar, WrStr, RdStr, WrLn, RdLn, RdCard, WrCard, RdInt, WrInt, RdReal, WrReal, WrFixReal, RdBool, WrBool, RdKey, KeyPressed; FROM RealMath IMPORT sqrt, exp, sin, cos, tan, arcsin, arccos, arctan, power, round; FROM Lib IMPORT Delay; (* Wait n milliseconds *) FROM Graph IMPORT Init,OutText,TextCoords,SetTextColor,SetTextPosition, Line, Ellipse, Rectangle, Circle, Disc, _clrBLACK, _clrBLUE, _clrGREEN, _clrCYAN, _clrRED, _clrMAGENTA; FROM Graph IMPORT _clrBROWN, _clrWHITE, _clrGRAY, _clrLIGHTBLUE, _clrLIGHTGREEN, _clrLIGHTCYAN, _clrLIGHTRED, _clrLIGHTMAGENTA, _clrLIGHTYELLOW, _clrBRIGHTWHITE; (* zie O:/TW/Win32App/Xds/Def/Ts/Graph.def *) CONST SCREEN_SIZE = 600; (* constants *) grootte= 20; kleur=6; VAR o: CHAR; x,y : ARRAY [1..8] OF CARDINAL; s : ARRAY [1..6] OF CARDINAL; i,j,k, color, cursor: CARDINAL; (* variable-declarations *) c : TextCoords; PROCEDURE vierkant(x0,y0,grootte,kleur:CARDINAL); VAR x: CARDINAL; BEGIN x:= grootte/2; Rectangle (x0-x,y0-x,x0+x,y0+x,kleur,TRUE) ; END vierkant; PROCEDURE Ster(x0,y0,grootte,kleur:CARDINAL); VAR x:CARDINAL; BEGIN x:= grootte/2 ; Line (x0-x,y0-x,x0+x,y0+x,kleur+1) ; Line (x0,y0-x,x0,y0+x,kleur+1) ; Line (x0-x,y0+x,x0+x,y0-x,kleur+1) ; Line (x0-x,y0,x0+x,y0,kleur+1) ; END Ster; BEGIN WrLn; x[1] := 201; y[1] := 60; x[2] := 401; y[2] := 60; x[3] := 542; y[3] := 201; x[4] := 542; y[4] := 401; x[5] := 401; y[5] := 542; x[6] := 201; y[6] := 542; x[7] := 60; y[7] := 401; x[8] := 60; y[8] := 201; s[1] := 0; s[2] := 1; s[3] := 6; s[4] :=12; s[5] := 8; s[6] := 9; IF NOT Init(1, 1 , SCREEN_SIZE, SCREEN_SIZE) THEN WrStr("Sorry, graphics doesn't work");WrLn; RETURN; END; FOR i:= 0 TO 20 DO Ellipse ( 300,300,250+i,200+i,4,FALSE) ; Delay(20); END; (* ATTENTION: this procedure is different under XDS 2.32: SetTextPosition(20, 20); leave the output 'cursor' *) OutText("Jantje is having fun"); (* write the text *) color := SetTextColor (14); (* you receive the old value of the text color *) (*c :=*) SetTextPosition(0, 2); (* you receive the old value of the cursor *) OutText("where are your manners !"); (*c :=*) SetTextPosition(0, 5); (* you receive the old value of the cursor *) OutText("created by Lendert G."); FOR i:= 1 TO 8 DO ; vierkant(x[i],y[i],grootte,kleur); END; FOR i:= 0 TO 50 DO Ellipse ( 350,200,25+i,20+i,4,FALSE); Delay(20); END; FOR i:= 0 TO 50 DO Ellipse ( 250,200,25+i,20+i,4,FALSE); Delay(20); END; FOR i:= 0 TO 20 DO Disc(300,300,30+i,4); Delay(20); END; FOR i:= 0 TO 15 DO Ellipse ( 300,450,100+i,20+i,4,FALSE); Delay(20); END; REPEAT FOR j:= 0 TO 50 DO Rectangle(275+j,475,325+j,560,4,TRUE); Disc(300+j,550,25,4); Delay(20); Rectangle(225+j,475,275+j,560,0,TRUE); Disc(250+j,550,25,0); FOR i:= 0 TO 20 DO Ellipse ( 300,300,250+i,200+i,4,FALSE) ; END; FOR i:= 0 TO 15 DO Ellipse ( 300,450,100+i,20+i,4,FALSE); END; END; FOR j:= 0 TO 100 DO Rectangle(325-j,475,375-j,560,4,TRUE); Disc(350-j,550,25,4); Delay(20); Rectangle(375-j,475,425-j,560,0,TRUE); Disc(400-j,550,25,0); FOR i:= 0 TO 20 DO Ellipse ( 300,300,250+i,200+i,4,FALSE) ; END; FOR i:= 0 TO 15 DO Ellipse ( 300,450,100+i,20+i,4,FALSE); END; END; FOR j:= 0 TO 50 DO Rectangle(225+j,475,275+j,560,4,TRUE); Disc(250+j,550,25,4); Delay(20); Rectangle(175+j,475,225+j,560,0,TRUE); Disc(200+j,550,25,0); FOR i:= 0 TO 20 DO Ellipse ( 300,300,250+i,200+i,4,FALSE) ; END; FOR i:= 0 TO 15 DO Ellipse ( 300,450,100+i,20+i,4,FALSE); END; END; FOR k:= 1 TO 6 DO FOR i:= 1 TO 8 DO FOR j:= 1 TO 8 DO Ster((x[i]+x[j])/2,(y[i]+y[j])/2,grootte,kleur); Delay(50); Ster((x[i]+x[j])/2,(y[i]+y[j])/2,grootte,s[k]); END; END; END; UNTIL KeyPressed(); (* Show graphics until user presses a key *) WrStr("Press any key to finish the program"); o := RdKey(); WrLn; RdLn; END permutatie. (*Je krijgt 8 punten gedefinieerd in 2 arrays, 1 array voor de x-waarden en 1 voor de y-waarden: x[1] := 201; y[1] := 60; x[2] := 401; y[2] := 60; x[3] := 542; y[3] := 201; x[4] := 542; y[4] := 401; x[5] := 401; y[5] := 542; x[6] := 201; y[6] := 542; x[7] := 60; y[7] := 401; x[8] := 60; y[8] := 201; Gebruik een grafisch scherm van 600 op 600 groot. Teken 8 vierkantje van grootte 8 op de gegeven punten. Teken een sterretje op de middelpunten van elk koppel punten. Je moet dus alle permutaties uitvoeren tussen de 8 punten. Gebruik de procedures gemaakt in S5.*)