Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
48
Task/Bitmap/Modula-3/bitmap-2.mod3
Normal file
48
Task/Bitmap/Modula-3/bitmap-2.mod3
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
MODULE Bitmap;
|
||||
|
||||
PROCEDURE NewImage(height, width: UByte): T RAISES {BadImage} =
|
||||
(* To make things easier, limit image size to also
|
||||
be UByte (0 to 255), and to have equal dimensions. *)
|
||||
BEGIN
|
||||
IF height # width THEN
|
||||
RAISE BadImage;
|
||||
END;
|
||||
RETURN NEW(T, height, width);
|
||||
END NewImage;
|
||||
|
||||
PROCEDURE Fill(VAR pic: T; color: Pixel) =
|
||||
BEGIN
|
||||
FOR i := FIRST(pic^) TO LAST(pic^) DO
|
||||
FOR j := FIRST(pic[0]) TO LAST(pic[0]) DO
|
||||
pic[i,j] := color;
|
||||
END;
|
||||
END;
|
||||
END Fill;
|
||||
|
||||
PROCEDURE GetPixel(VAR pic: T; point: Point): Pixel RAISES {BadColor} =
|
||||
VAR pixel := pic[point.x, point.y];
|
||||
BEGIN
|
||||
IF pixel = White THEN
|
||||
RETURN White;
|
||||
ELSIF pixel = Black THEN
|
||||
RETURN Black;
|
||||
ELSIF pixel = Red THEN
|
||||
RETURN Red;
|
||||
ELSIF pixel = Green THEN
|
||||
RETURN Green;
|
||||
ELSIF pixel = Blue THEN
|
||||
RETURN Blue;
|
||||
ELSIF pixel = Yellow THEN
|
||||
RETURN Yellow;
|
||||
ELSE
|
||||
RAISE BadColor;
|
||||
END;
|
||||
END GetPixel;
|
||||
|
||||
PROCEDURE SetPixel(VAR pic: T; point: Point; color: Pixel) =
|
||||
BEGIN
|
||||
pic[point.x, point.y] := color;
|
||||
END SetPixel;
|
||||
|
||||
BEGIN
|
||||
END Bitmap.
|
||||
Loading…
Add table
Add a link
Reference in a new issue