RosettaCodeData/Task/Bitmap/SequenceL/bitmap.sequencel

39 lines
921 B
Plaintext

RGB ::= (R: int(0), G: int(0), B: int(0));
newBitmap: int * int -> RGB(2);
newBitmap(width, height)[y, x] :=
(R: 0, G: 0, B: 0)
foreach y within 1 ... height,
x within 1 ... width;
fill: RGB(2) * RGB -> RGB(2);
fill(bitmap(2), color)[y, x] :=
color
foreach y within 1 ... size(bitmap),
x within 1 ... size(bitmap[y]);
setColorAt: RGB(2) * int * int * RGB -> RGB(2);
setColorAt(bitmap(2), x, y, color)[Y, X] :=
color when Y = y and X = x
else
bitmap[Y, X];
getColorAt: RGB(2) * int * int -> RGB;
getColorAt(bitmap(2), x, y) := bitmap[y, x];
lightGreen := (R: 51, G: 255, B: 51);
lightRed := (R: 255, G: 51, B: 51);
main(args(2)) :=
let
width := 1920;
height := 1200;
cleanImage := newBitmap(width, height);
filledGreen := fill(cleanImage, lightGreen);
redCenter := setColorAt(filledGreen, width / 2, height / 2, lightRed);
in
getColorAt(redCenter, width / 2, height / 2);