From fc3fdd59a1b8cceb1eb3e64ac41c6621301772ff Mon Sep 17 00:00:00 2001 From: sanine Date: Wed, 26 Jan 2022 14:43:06 -0600 Subject: move tectonics.c -> main.c --- experimental/tectonics/Makefile | 4 +- experimental/tectonics/main.c | 84 ++++++++++++++++++++++++++++++++++++++ experimental/tectonics/tectonics.c | 84 -------------------------------------- experimental/tectonics/world.c | 11 +++-- 4 files changed, 91 insertions(+), 92 deletions(-) create mode 100644 experimental/tectonics/main.c delete mode 100644 experimental/tectonics/tectonics.c (limited to 'experimental') diff --git a/experimental/tectonics/Makefile b/experimental/tectonics/Makefile index a0245f3..13f48fc 100644 --- a/experimental/tectonics/Makefile +++ b/experimental/tectonics/Makefile @@ -5,8 +5,8 @@ DEPS=tectonics.h %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) -all: world.o util.o tectonics.o quadtree.o drawing.o logging.o - $(CC) -o tectonics world.o util.o tectonics.o logging.o quadtree.o drawing.o $(CFLAGS) +all: world.o util.o main.o quadtree.o drawing.o logging.o + $(CC) -o tectonics world.o util.o main.o logging.o quadtree.o drawing.o $(CFLAGS) test: all quadtree.o quadtree.test.o tests.o $(CC) -o tests world.o util.o quadtree.o quadtree.test.o tests.o $(CFLAGS) diff --git a/experimental/tectonics/main.c b/experimental/tectonics/main.c new file mode 100644 index 0000000..93b32fb --- /dev/null +++ b/experimental/tectonics/main.c @@ -0,0 +1,84 @@ +#include + +#include "tectonics.h" +#include "drawing.h" +#include "logging.h" + +#define X_RES 1024 +#define Y_RES X_RES + + +int parse_options(char **output_file, int argc, char **argv); + + +int main(int argc, char **argv) +{ + char *output_file; + if (parse_options(&output_file, argc, argv)) + return 1; + + cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, X_RES, Y_RES); + cairo_t *cr = cairo_create(surface); + + struct world_t world; + create_world(&world, 100000); + if (world.points == NULL) + return 1; + draw_world(cr, &world); + free_world(&world); + + cairo_destroy(cr); + cairo_surface_write_to_png(surface, "output.png"); + cairo_surface_destroy(surface); + return 0; +} + + +#include +#include + +static void print_usage(const char *progname) +{ + printf("Usage: %s [-c config_file] [-v[v[v]]] [-q[q[q]]] [-h] [-s script]\n" + " -v Increase output verbosity (-vvv displays every log message)\n" + " -q Decrease output verbosity (-qqq suppresses even fatal errors)\n" + " -c Specify configuration file to read (default 'config.lua')\n" + " -s Override the built-in Lua script\n" + " -h Print this help message and exit\n", + progname); +} + +int parse_options(char **output_file, int argc, char **argv) +{ + int log_level = WARN; + *output_file = "output.png"; + + int opt; + while ((opt = getopt(argc, argv, "qvo:h")) != -1) { + switch (opt) { + case 'q': + log_level -= 1; + break; + + case 'v': + log_level += 1; + break; + + case 'o': + *output_file = optarg; + + case 'h': + print_usage(argv[0]); + return 2; + + default: + print_usage(argv[0]); + return 1; + } + } + + // ew, globals (sorry) + global_log_level = log_level; + + return 0; +} diff --git a/experimental/tectonics/tectonics.c b/experimental/tectonics/tectonics.c deleted file mode 100644 index 0a81b45..0000000 --- a/experimental/tectonics/tectonics.c +++ /dev/null @@ -1,84 +0,0 @@ -#include - -#include "tectonics.h" -#include "drawing.h" -#include "logging.h" - -#define X_RES 1024 -#define Y_RES X_RES - - -int parse_options(char **output_file, int argc, char **argv); - - -int main(int argc, char **argv) -{ - char *output_file; - if (parse_options(&output_file, argc, argv)) - return 1; - - cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, X_RES, Y_RES); - cairo_t *cr = cairo_create(surface); - - struct world_t world; - create_world(&world, 10000); - if (world.points == NULL) - return 1; - draw_world(cr, &world); - free_world(&world); - - cairo_destroy(cr); - cairo_surface_write_to_png(surface, "output.png"); - cairo_surface_destroy(surface); - return 0; -} - - -#include -#include - -static void print_usage(const char *progname) -{ - printf("Usage: %s [-c config_file] [-v[v[v]]] [-q[q[q]]] [-h] [-s script]\n" - " -v Increase output verbosity (-vvv displays every log message)\n" - " -q Decrease output verbosity (-qqq suppresses even fatal errors)\n" - " -c Specify configuration file to read (default 'config.lua')\n" - " -s Override the built-in Lua script\n" - " -h Print this help message and exit\n", - progname); -} - -int parse_options(char **output_file, int argc, char **argv) -{ - int log_level = WARN; - *output_file = "output.png"; - - int opt; - while ((opt = getopt(argc, argv, "qvo:h")) != -1) { - switch (opt) { - case 'q': - log_level -= 1; - break; - - case 'v': - log_level += 1; - break; - - case 'o': - *output_file = optarg; - - case 'h': - print_usage(argv[0]); - return 2; - - default: - print_usage(argv[0]); - return 1; - } - } - - // ew, globals (sorry) - global_log_level = log_level; - - return 0; -} diff --git a/experimental/tectonics/world.c b/experimental/tectonics/world.c index f5b6efb..dc042ee 100644 --- a/experimental/tectonics/world.c +++ b/experimental/tectonics/world.c @@ -53,7 +53,6 @@ static void relax_points(struct world_t *world, int iterations) // approximate centroids for (int i=0; ipoints + i; pt->x = rand01(); pt->y = rand01(); - - //quadtree_insert(&(world->tree), world->points, i); } rebuild_tree(world); - for (int i=0; i<15; i++) - relax_points(world, 10*world->n_points); + for (int i=0; i<1; i++) { + log_msg(INFO, "relaxing points - iteration %d", i+1); + relax_points(world, 50*world->n_points); + } } -- cgit v1.2.1