X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=flatland.git;a=blobdiff_plain;f=flatland.cc;h=6e6b747648d0c624b259b45bc55043a558fd6797;hp=92a5ebbf6c7699775ff5a8461159485fd68ca653;hb=85e284b40ef2175f672298b64bf79424da8ebc19;hpb=26abc735ca75a78974c7ced091035e8c27ca1c00 diff --git a/flatland.cc b/flatland.cc index 92a5ebb..6e6b747 100644 --- a/flatland.cc +++ b/flatland.cc @@ -39,20 +39,6 @@ using namespace std; #include "universe.h" #include "canvas_cairo.h" -FILE *safe_fopen(const char *name, const char *mode) { - FILE *file = fopen(name, mode); - if(!file) { - cerr << "Cannot open " << name << endl; - exit(1); - } - return file; -} - -void print_help(const char *command) { - cerr << command << " [--dir ] [--seed ]]" << endl; - exit(1); -} - ////////////////////////////////////////////////////////////////////// void draw_universe_on_canvas(CanvasCairo *canvas, scalar_t scaling, @@ -103,8 +89,6 @@ extern "C" void fl_generate_sequences(int nb_sequences, int random_grasp = 1; int random_shape_size = 0; int nb_shapes = 10; - // char data_dir[1024] = "/tmp/"; - // int show_grabbing_point = 0; int skip = -1; for(int n = 0; n < nb_sequences; n++) { @@ -222,22 +206,22 @@ extern "C" void fl_generate_sequences(int nb_sequences, scalar_t xf = grabbed_polygon->absolute_x(grab_relative_x, grab_relative_y); scalar_t yf = grabbed_polygon->absolute_y(grab_relative_x, grab_relative_y); grabbed_polygon->apply_force(dt, xf, yf, 0.0, -1.0); - universe->update(dt); + universe->update(dt, 1.0 / scaling); } } } for(int t = 0; t < nb_images_per_sequence; t++) { - memcpy(output + (n * nb_images_per_sequence + t) * 3 * width * height, - canvases[t]->_data, - 3 * width * height); + unsigned char *src = canvases[t]->_data; + unsigned char *dst = output + (n * nb_images_per_sequence + t) * width * height * 3; + for(int d = 0; d < 3; d++) { + for(int y = 0; y < height; y++) { + for(int x = 0; x < width; x++) { + dst[x + width * (y + height * d)] = src[d + 4 * (x + width * y)]; + } + } + } } - - // char buffer[1024]; - // sprintf(buffer, "%s/%03d/dyn_%06d.png", data_dir, n / 1000, n); - // FILE *file = safe_fopen(buffer, "w"); - // main_canvas.write_png(file); - // fclose(file); } for(int t = 0; t < 2 * nb_saved_frames; t++) {