]> git.cworth.org Git - dvonn/commitdiff
Fix vertical spacing of the board
authorCarl Worth <cworth@cworth.org>
Wed, 4 Mar 2009 23:52:59 +0000 (15:52 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 4 Mar 2009 23:52:59 +0000 (15:52 -0800)
Previously we were using unit spacing for both X and Y, but the
correct answer is to include a sqrt(0.5) factor in the Y axis.

dvonn.c

diff --git a/dvonn.c b/dvonn.c
index 1744770fc8e93404a80ee03e4e8593770593a22d..43de664e9e362d9aa56d57ef9847d470a7f9e963 100644 (file)
--- a/dvonn.c
+++ b/dvonn.c
@@ -166,13 +166,13 @@ on_expose_event_draw (GtkWidget           *widget,
        layout->height = widget->allocation.height;
 
        x_size = layout->width;
-       if (x_size > layout->height * BOARD_X_SIZE / BOARD_Y_SIZE)
-           x_size = layout->height * BOARD_X_SIZE / BOARD_Y_SIZE;
+       if (x_size > layout->height * BOARD_X_SIZE / (1 + M_SQRT1_2 * (BOARD_Y_SIZE-1)))
+           x_size = layout->height * BOARD_X_SIZE / (1 + M_SQRT1_2 * (BOARD_Y_SIZE-1));
 
        /* Size must be a multiple of the integer cell_size */
        layout->cell_size = x_size / BOARD_X_SIZE;
        x_size = layout->cell_size * BOARD_X_SIZE;
-       y_size = layout->cell_size * BOARD_Y_SIZE;
+       y_size = layout->cell_size * (1 + M_SQRT1_2 * (BOARD_Y_SIZE-1));
 
        layout->x_offset = (layout->width - x_size) / 2;
        layout->y_offset = (layout->height - y_size) / 2;
@@ -196,7 +196,8 @@ on_expose_event_draw (GtkWidget             *widget,
 
            cairo_save (cr);
            cairo_translate(cr,
-                           x + (y - DVONN_BOARD_Y_SIZE/2) / 2.0, y);
+                           x + (y - DVONN_BOARD_Y_SIZE/2) / 2.0,
+                           M_SQRT1_2 * y);
            ring_path (cr);
            cairo_set_source_rgba (cr, 0.0, 0.0, 0.2, 0.1);
            cairo_fill (cr);
@@ -257,7 +258,7 @@ loa_game_create_view (loa_game_t *game)
 
     view_init (view, game, window);
 
-    gtk_window_set_default_size (GTK_WINDOW (window), 561, 255);
+    gtk_window_set_default_size (GTK_WINDOW (window), 780, 251);
 
     g_signal_connect (window, "delete-event",
                      G_CALLBACK (on_delete_event_quit), NULL);