langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
20
Task/Colour-bars-Display/OCaml/colour-bars-display.ocaml
Normal file
20
Task/Colour-bars-Display/OCaml/colour-bars-display.ocaml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
open Graphics
|
||||
|
||||
let round x =
|
||||
int_of_float (floor (x +. 0.5))
|
||||
|
||||
let () =
|
||||
open_graph "";
|
||||
let cols = size_x () in
|
||||
let rows = size_y () in
|
||||
let colors = [| black; red; green; blue; magenta; cyan; yellow; white |] in
|
||||
let n = Array.length colors in
|
||||
let bar_width = (float cols) /. (float n) in
|
||||
Array.iteri (fun i color ->
|
||||
let x1 = bar_width *. (float i) in
|
||||
let x2 = bar_width *. (float (succ i)) in
|
||||
set_color color;
|
||||
fill_rect (round x1) 0 (round x2) rows;
|
||||
) colors;
|
||||
ignore (read_key ());
|
||||
;;
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
Dim color(7)
|
||||
color(0) = RGB($00, $00, $00) ;black
|
||||
color(1) = RGB($FF, $00, $00) ;red
|
||||
color(2) = RGB($00, $FF, $00) ;green
|
||||
color(3) = RGB($00, $00, $FF) ;blue
|
||||
color(4) = RGB($FF, $00, $FF) ;magenta
|
||||
color(5) = RGB($00, $FF, $FF) ;cyan
|
||||
color(6) = RGB($FF, $FF, $00) ;yellow
|
||||
color(7) = RGB($FF, $FF, $FF) ;white
|
||||
|
||||
If Not InitKeyboard(): End: EndIf ;can't init keyboard
|
||||
If Not InitSprite(): End: EndIf ;can't init sprite/screen library
|
||||
If Not ExamineDesktops(): End: EndIf ;can't retrieve information about desktop
|
||||
|
||||
height = DesktopHeight(0)
|
||||
width = DesktopWidth(0)
|
||||
depth = DesktopDepth(0)
|
||||
If OpenScreen(width, height, depth, "Press ENTER to exit")
|
||||
StartDrawing(ScreenOutput())
|
||||
For c = 0 To 7
|
||||
Box((width * c) / 8, 0, width / 8, height, color(c))
|
||||
Next
|
||||
StopDrawing()
|
||||
FlipBuffers()
|
||||
|
||||
Repeat
|
||||
Delay(10)
|
||||
ExamineKeyboard()
|
||||
Until KeyboardPushed(#PB_Key_Escape) Or KeyboardPushed(#PB_Key_Return)
|
||||
CloseScreen()
|
||||
EndIf
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
DataSection
|
||||
;Black, Red, Green, Blue, Magenta, Cyan, Yellow, White
|
||||
Data.i 0, 12, 10, 9, 13, 11, 14, 15
|
||||
EndDataSection
|
||||
|
||||
Dim colors(7)
|
||||
For c = 0 To 7
|
||||
Read.i colors(c)
|
||||
Next
|
||||
|
||||
If OpenConsole()
|
||||
;The console display is 80 columns wide by 25 rows
|
||||
For r = 0 To 24
|
||||
For c = 0 To 7
|
||||
ConsoleColor(colors(c), colors(c))
|
||||
Print(Space(80 / 8))
|
||||
Next
|
||||
Next
|
||||
EnableGraphicalConsole(1)
|
||||
ConsoleLocate(0, 0)
|
||||
|
||||
ConsoleTitle("Press ENTER to exit"): Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
colors$ = "black,red,green,blue,magenta,cyan,yellow,white"
|
||||
html "<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=4><tr height=70>"
|
||||
for i = 1 to 8
|
||||
html "<td width=20 bgcolor='";word$(colors$,i,",");"'</td>"
|
||||
next i
|
||||
html "</tr></table>"
|
||||
12
Task/Colour-bars-Display/XPL0/colour-bars-display-1.xpl0
Normal file
12
Task/Colour-bars-Display/XPL0/colour-bars-display-1.xpl0
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
include c:\cxpl\codes; \intrinsic code declarations
|
||||
int W, X0, X1, Y, C;
|
||||
[SetVid($13); \320x200x8 graphics
|
||||
W:= 320/8; \width of color bar (pixels)
|
||||
for C:= 0 to 8-1 do
|
||||
[X0:= W*C; X1:= X0+W-1;
|
||||
for Y:= 0 to 200-1 do
|
||||
[Move(X0, Y); Line(X1, Y, C)];
|
||||
];
|
||||
C:= ChIn(1); \wait for keystroke
|
||||
SetVid(3); \restore normal text mode
|
||||
]
|
||||
8
Task/Colour-bars-Display/XPL0/colour-bars-display-2.xpl0
Normal file
8
Task/Colour-bars-Display/XPL0/colour-bars-display-2.xpl0
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
10 REM The ZX Spectrum display is 32 columns wide, so we have 8 columns of 4 spaces
|
||||
20 FOR r=0 TO 20: REM There are 21 rows
|
||||
30 FOR c=0 TO 7: REM We use the native colour sequence here
|
||||
40 PAPER c: REM set the background colour for the spaces to be printed
|
||||
50 PRINT " ";: REM four spaces, the semicolon prevents newline
|
||||
60 NEXT c
|
||||
70 REM at this point the cursor has wrapped, so we don't need a newline
|
||||
80 NEXT r
|
||||
Loading…
Add table
Add a link
Reference in a new issue