X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=main.c;h=39cb5ad1158a64535661f33fb6221138f74ca51d;hb=ac886f983a984a951187fae89c530858013ef118;hp=2423b4f05069ab9c557a691e110984a5a8aeff2b;hpb=4e16902eb4a956c7ea79cb4d7f7e56419ea29012;p=akamaru diff --git a/main.c b/main.c index 2423b4f..39cb5ad 100644 --- a/main.c +++ b/main.c @@ -261,6 +261,53 @@ model_init_wobbly (Model *model) } } +static void +model_init_dock (Model *model) +{ + const int num_objects = 8; + const int num_spacers = (num_objects - 1) * (num_objects - 2) / 2; + const int num_springs = num_objects - 1; + const int distance = 30; + double x, y; + int i, j; + Object *object; + Spring *spring; + Spacer *spacer; + + memset (model, 0, sizeof *model); + model->objects = g_new (Object, num_objects); + model->num_objects = num_objects; + model->springs = g_new (Spring, num_springs); + model->num_springs = num_springs; + model->spacers = g_new (Spacer, num_spacers); + model->num_spacers = num_spacers; + model->k = 0.1; + + model_init_polygons (model); + model->polygons = g_new (Polygon, 1); + polygon_init_rectangle (&model->polygons[0], -400, 300, 1400, 350); + model->num_polygons = 1; + + + object = model->objects; + spring = model->springs; + spacer = model->spacers; + for (i = 0; i < num_objects; i++, object++) { + x = 200 + i * distance / 3; + y = 40; + object_init (object, x, y, 1); + if (i == 0) + continue; + spring_init (spring++, + &model->objects[0], + &model->objects[i], + distance); + for (j = 1; j < num_objects - i; j++) { + spacer_init (spacer++, object, object + j, distance); + } + } +} + typedef struct _Color Color; struct _Color { double red, green, blue; @@ -554,7 +601,8 @@ create_model_store (void) { "Curtain", model_init_curtain }, { "Grid", model_init_grid }, { "Molecule", model_init_molecule }, - { "Wobbly", model_init_wobbly } + { "Wobbly", model_init_wobbly }, + { "Dock", model_init_dock } }; GtkTreeIter iter;