langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
|
|
@ -0,0 +1,22 @@
|
|||
open Graphics
|
||||
|
||||
let round x = truncate (floor (x +. 0.5))
|
||||
|
||||
let () =
|
||||
open_graph "";
|
||||
let width = size_x ()
|
||||
and height = size_y () in
|
||||
let bars = [| 8; 16; 32; 64 |] in
|
||||
let n = Array.length bars in
|
||||
Array.iteri (fun i bar ->
|
||||
let part = float width /. float bar in
|
||||
let y = (height / n) * (n - i - 1) in
|
||||
for j = 0 to pred bar do
|
||||
let x = round (float j *. part) in
|
||||
let v = round (float j *. 255. /. float (bar - 1)) in
|
||||
let v = if (i mod 2) = 0 then v else 255 - v in
|
||||
set_color (rgb v v v);
|
||||
fill_rect x y (round part) (height / n)
|
||||
done
|
||||
) bars;
|
||||
ignore(read_key())
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
my $wininfo = qx[xwininfo -root];
|
||||
my ($width,$height) = ($wininfo ~~ /'Width: ' (\d+) .*? 'Height: ' (\d+)/)[];
|
||||
($width,$height) = 1280,768 unless $width;
|
||||
|
||||
my $PGM = open "greybars.pgm", :w or die "Can't create greybars.pgm: $!";
|
||||
|
||||
$PGM.print: qq:to/EOH/;
|
||||
P2
|
||||
# greybars.pgm
|
||||
$width $height
|
||||
65535
|
||||
EOH
|
||||
|
||||
my ($h1,$h2,$h3,$h4) = divvy($height,4);
|
||||
|
||||
my @nums = ((0/7,1/7...7/7) X* 65535)».floor;
|
||||
my $line = ~(@nums Zxx divvy($width,8));
|
||||
$PGM.say: $line for ^$h1;
|
||||
|
||||
@nums = ((15/15,14/15...0/15) X* 65535)».floor;
|
||||
$line = ~(@nums Zxx divvy($width,16));
|
||||
$PGM.say: $line for ^$h2;
|
||||
|
||||
@nums = ((0/31,1/31...31/31) X* 65535)».floor;
|
||||
$line = ~(@nums Zxx divvy($width,32));
|
||||
$PGM.say: $line for ^$h3;
|
||||
|
||||
@nums = ((63/63,62/63...0/63) X* 65535)».floor;
|
||||
$line = ~(@nums Zxx divvy($width,64));
|
||||
$PGM.say: $line for ^$h4;
|
||||
|
||||
$PGM.close;
|
||||
|
||||
shell "eog -f greybars.pgm";
|
||||
|
||||
sub divvy($all, $div) {
|
||||
my @marks = ((1/$div,2/$div ... 1) X* $all)».round;
|
||||
@marks Z- 0,@marks;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
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
|
||||
|
||||
Define height.f, width.f, depth
|
||||
height.f = DesktopHeight(0)
|
||||
width.f = DesktopWidth(0)
|
||||
depth = DesktopDepth(0)
|
||||
|
||||
If OpenScreen(width, height, depth, "Press ENTER to exit")
|
||||
Define vsCount, v, h, columns, columnWidth, endColor, shade
|
||||
StartDrawing(ScreenOutput())
|
||||
vsCount = 4
|
||||
For v = 0 To 3
|
||||
columns = (v + 1) * 8
|
||||
columnWidth = Round(width / columns, #PB_Round_Up)
|
||||
endColor = $FFFFFF * (v % 2) ;alternate between black and white for first and last bar
|
||||
Box(0, (height * v) / vsCount, columnWidth, height / vsCount, endColor)
|
||||
|
||||
For h = 1 To columns - 2
|
||||
If v % 2 = 0
|
||||
shade = 256 / columns * (h + 1)
|
||||
Else
|
||||
shade = 256 / columns * (columns - (h + 1))
|
||||
EndIf
|
||||
Box((width * h) / columns, (height * v) / vsCount, columnWidth, height / vsCount, RGB(shade, shade, shade))
|
||||
Next
|
||||
|
||||
Box((width * (columns - 1)) / columns, (height * v) / vsCount, columnWidth, height / vsCount, $FFFFFF - endColor)
|
||||
Next
|
||||
StopDrawing()
|
||||
FlipBuffers()
|
||||
|
||||
Repeat
|
||||
Delay(10)
|
||||
ExamineKeyboard()
|
||||
Until KeyboardPushed(#PB_Key_Escape) Or KeyboardPushed(#PB_Key_Return)
|
||||
CloseScreen()
|
||||
EndIf
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
for i = 1 to 4
|
||||
incr = int(256 / (i * 8))
|
||||
c = 256
|
||||
html "<table style='width: 200px; height: 11px;' border=0 cellpadding=0 cellspacing=0><tr>"
|
||||
for j = 1 to i * 8
|
||||
html "<td style='background-color: rgb(";c;",";c;",";c;");'></td>"
|
||||
c = c - incr
|
||||
next j
|
||||
html "</tr>"
|
||||
next i
|
||||
html "</table>"
|
||||
end
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "draw.s7i";
|
||||
include "keybd.s7i";
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var integer: barHeight is 0;
|
||||
var integer: barNumber is 0;
|
||||
var integer: colCount is 0;
|
||||
var integer: deltaX is 0;
|
||||
var integer: x is 0;
|
||||
var integer: col is 0;
|
||||
begin
|
||||
screen(640, 480);
|
||||
KEYBOARD := GRAPH_KEYBOARD;
|
||||
barHeight := height(curr_win) div 4;
|
||||
for barNumber range 0 to 3 do
|
||||
colCount := 8 << barNumber;
|
||||
deltaX := width(curr_win) div colCount;
|
||||
for x range 0 to pred(colCount) do
|
||||
if barNumber rem 2 = 0 then
|
||||
col := 65535 - 65535 div pred(colCount) * x;
|
||||
else
|
||||
col := 65535 div pred(colCount) * x;
|
||||
end if;
|
||||
rect(deltaX * x, barHeight * barNumber, deltaX, barHeight,
|
||||
color(col, col, col));
|
||||
end for;
|
||||
end for;
|
||||
ignore(getc(KEYBOARD));
|
||||
end func;
|
||||
16
Task/Greyscale-bars-Display/XPL0/greyscale-bars-display.xpl0
Normal file
16
Task/Greyscale-bars-Display/XPL0/greyscale-bars-display.xpl0
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
include c:\cxpl\codes; \intrinsic 'code' declarations
|
||||
int Q, N, W, B, C, Y;
|
||||
[SetVid($112); \640x480x24 graphics
|
||||
for Q:= 0 to 4-1 do \quarter of screen
|
||||
[N:= 8<<Q; \number of bars
|
||||
W:= 640/N; \width of bar (pixels)
|
||||
for B:= 0 to N-1 do \for each bar...
|
||||
[C:= fix(255.0/float(N-1) * float(if Q&1 then N-1-B else B));
|
||||
C:= C<<16 + C<<8 + C; \RGB color = gray
|
||||
for Y:= Q*120 to (Q+1)*120-1 do
|
||||
[Move(W*B, Y); Line(W*(B+1)-1, Y, C)];
|
||||
];
|
||||
];
|
||||
Q:= ChIn(1); \wait for keystroke
|
||||
SetVid(3); \restore normal text mode
|
||||
]
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
10 REM wind the colour down or use a black and white television to see greyscale bars
|
||||
20 REM The ZX Spectrum display is 32 columns wide, so we have 8 columns of 4 spaces
|
||||
30 FOR r=0 TO 20: REM There are 21 rows
|
||||
40 FOR c=0 TO 7: REM We use the native colour sequence here
|
||||
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