From 00c3363ca258f160b875ec254e701017be0314db Mon Sep 17 00:00:00 2001 From: kartofen Date: Tue, 9 Aug 2022 11:34:57 +0300 Subject: add readme and demo image --- README.md | 14 ++++++++++++++ build.sh | 13 +++++++++++-- demo/demo.png | Bin 0 -> 301 bytes ppmtopng.sh | 1 + src/main.c | 2 +- 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 README.md create mode 100644 demo/demo.png diff --git a/README.md b/README.md new file mode 100644 index 0000000..e20a0ff --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +### Wave function collapse + +This an implementation of very primitive tile-based wave function collapse. +It uses tiles to generate an image, similar to this: +![Demo of the program](demo/demo.png) + +It generates the tiles as ppm, then generates the image, similar to the demo image as ppm. There is a script to turn the ppm files into png using imagemagick. + +All files including the tiles are saved in the files directory + +### Build + +To build use `./build.sh` +To build and run use `./build.sh run` diff --git a/build.sh b/build.sh index 84a12e8..6c4860e 100755 --- a/build.sh +++ b/build.sh @@ -9,6 +9,12 @@ ODIR="obj" BIN="bin" VALGRND="" +RUN=0 + +function run { + RUN=1 +} + function leak { VALGRND="valgrind --leak-check=full" } @@ -37,5 +43,8 @@ gcc -o $BIN/wfc $ODIR/main.o $ODIR/ppm.o $ODIR/tiles.o $FLAGS gcc -o $BIN/gen_tiles $ODIR/gen_tiles.o $ODIR/ppm.o $FLAGS -$VALGRND $BIN/gen_tiles -$VALGRND $BIN/wfc +if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null +then + $VALGRND $BIN/gen_tiles + $VALGRND $BIN/wfc +fi diff --git a/demo/demo.png b/demo/demo.png new file mode 100644 index 0000000..82498c6 Binary files /dev/null and b/demo/demo.png differ diff --git a/ppmtopng.sh b/ppmtopng.sh index e415a5f..df33236 100755 --- a/ppmtopng.sh +++ b/ppmtopng.sh @@ -1,5 +1,6 @@ #!/bin/sh +cd ${0%/*} # go to project root set -xe for i in files/file*.ppm diff --git a/src/main.c b/src/main.c index d4c1a47..c169326 100644 --- a/src/main.c +++ b/src/main.c @@ -120,7 +120,7 @@ int main(void) { time_t seed = time(0); srand(seed); - printf("seed %ld\n", seed); + printf("The Seed is %ld\n", seed); init_tiles_board(); -- cgit v1.2.3