commit dd0a2d572e7c3441fec503f1d5f108d6362d137b
parent b75c1afdd390b95d383ec0441419f34e530d260e
Author: aabacchus <ben@bvnf.space>
Date: Mon, 27 Sep 2021 07:02:59 +0100
manpages and videos
Diffstat:
M | .gitignore | | | 1 | + |
M | Makefile | | | 5 | ++++- |
A | cgol.1 | | | 52 | ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | cgol.3 | | | 41 | +++++++++++++++++++++++++++++++++++++++++ |
4 files changed, 98 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
@@ -1,4 +1,5 @@
*.o
+*.webm
cgol
config.mk
images/
diff --git a/Makefile b/Makefile
@@ -24,7 +24,10 @@ $(OBJS): $(OBJS:.o=.c) cgol.h
images:
mkdir -p images
+out.webm: images
+ ffmpeg -r 15 -i images/%04d.png $@
+
clean:
- rm -fr $(OBJS) cgol images/ config.mk
+ rm -fr $(OBJS) cgol images/
.PHONY: clean
diff --git a/cgol.1 b/cgol.1
@@ -0,0 +1,52 @@
+.Dd September 27, 2021
+.Dt CGOL 1
+.Os "ben's space"
+.Sh NAME
+.Nm cgol
+.Nd generate images of the game of life
+.Sh SYNOPSIS
+.Nm
+.Sh DESCRIPTION
+.Nm
+generates frames of the progression of the game of life as images,
+placed into the
+.Pa images/
+directory.
+.Nm
+begins with a
+.Xr randomize 3 Ns d grid of cells,
+which are
+.Xr evolve 3 Ns d according to the following rules:
+.Bl -dash -offset indent
+.It
+A
+.Qq dead
+cell with exactly 3 neighbours becomes
+.Qq alive .
+.It
+A
+.Qq living
+cell remains living only if it has 2 or 3 neighbours.
+.It
+All other cells remain or become dead.
+.Ed
+According to these rules, the random initial state can give rise to
+some interesting behaviours.
+.Ss Creating a video from the images
+Using a tool such as
+.Xr ffmpeg 1 ,
+the following command would create a video
+.Pa out.webm
+at
+.Ar 15
+frames per second
+from the images stored in
+.Pa images/ :
+.Bd -offset indent
+ffmpeg
+.Fl r Ar 15
+.Fl i Ar images/%04d.png
+.Ar out.webm
+.Ed
+.Sh AUTHORS
+.An phoebos Aq Mt ben@bvnf.space
diff --git a/cgol.3 b/cgol.3
@@ -0,0 +1,41 @@
+.Dd September 27, 2021
+.Dt CGOL 3
+.Os "ben's space"
+.Sh NAME
+.Nm alive ,
+.Nm evolve ,
+.Nm neighbours ,
+.Nm png ,
+.Nm randomize
+.Nd play the game of life
+.Sh SYNOPSIS
+.In cairo/cairo.h
+.In stdio.h
+.In stdlib.h
+.In time.h
+.Fd #define WHATS_OUTSIDE 0
+.Ft int
+.Fn alive "int x" "int y" "short *cells" "int nx" "int ny"
+.Ft int
+.Fn evolve "short *cells" "int nx" "int ny"
+.Ft int
+.Fn neighbours "int x" "int y" "short *cells" "int nx" "int ny"
+.Ft int
+.Fn png "struct imgdata *img" "short *cells" "char *fname"
+.Ft void
+.Fn randomize "short *cells" "int nx" "int ny"
+.Sh DESCRIPTION
+.Bd -literal
+struct rgb {
+ double r, g, b;
+};
+.Ed
+.Bd -literal
+struct imgdata {
+ double width, height;
+ int ny, nx; /* number of columns and rows */
+ struct gdb a, i, b; /* RGB for active, inactive, background pixels */
+};
+.Ed
+.Sh AUTHORS
+.An phoebos Aq Mt ben@bvnf.space