… | |
… | |
59 | |
59 | |
60 | =over 4 |
60 | =over 4 |
61 | |
61 | |
62 | =cut |
62 | =cut |
63 | |
63 | |
64 | our $VERSION = '1.0'; |
64 | our $VERSION = '1.01'; |
65 | |
65 | |
66 | no warnings; |
66 | no warnings; |
67 | use strict; |
67 | use strict; |
68 | |
68 | |
69 | use Scalar::Util; |
69 | use Scalar::Util; |
… | |
… | |
313 | delete $self->{backgroundpm}; |
313 | delete $self->{backgroundpm}; |
314 | delete $self->{backgroundpb}; |
314 | delete $self->{backgroundpb}; |
315 | |
315 | |
316 | my $pixmap = new Gtk2::Gdk::Pixmap $self->window, $w, $h, -1; |
316 | my $pixmap = new Gtk2::Gdk::Pixmap $self->window, $w, $h, -1; |
317 | |
317 | |
318 | #my $gridcolour = 0x88444400; # black is traditional, but only with overlapping stones |
|
|
319 | my $gridcolour = 0x44444400; # black is traditional, but only with overlapping stones |
318 | my $gridcolour = 0x44444400; # black is traditional, but only with overlapping stones |
320 | my $labelcolour = 0x88444400; |
319 | my $labelcolour = 0x88444400; |
321 | |
320 | |
322 | # we leave enough space for the shadows.. I like smaller stones, and we |
|
|
323 | # do no need to do the nifty recursive screen updates that cgoban2 does |
|
|
324 | my $borderw = int ($w / ($size + 1) * 0.5); |
321 | my $borderw = int $w / ($size + 1) * 0.5; |
325 | my $borderh = $borderw; |
322 | my $borderh = $borderw; |
326 | my $w2 = $w - $borderw * 2; |
323 | my $w2 = $w - $borderw * 2; |
327 | my $h2 = $h - $borderh * 2; |
324 | my $h2 = $h - $borderh * 2; |
328 | my $edge = ceil ($w2 / ($size + 1)); |
325 | my $edge = ceil $w2 / ($size + 1); |
329 | my $ofs = $edge * 0.5; |
326 | my $ofs = $edge * 0.5; |
330 | |
327 | |
331 | # we need a certain minimum size, and just fudge some formula here |
328 | # we need a certain minimum size, and just fudge some formula here |
332 | return if $w < $size * 5 + 2 + $borderw |
329 | return if $w < $size * 5 + 2 + $borderw |
333 | || $h < $size * 6 + 2 + $borderh; |
330 | || $h < $size * 6 + 2 + $borderh; |
… | |
… | |
344 | $board_img->copy_area (0, 0, $w, $h, $pixbuf, 0, 0); |
341 | $board_img->copy_area (0, 0, $w, $h, $pixbuf, 0, 0); |
345 | } else { |
342 | } else { |
346 | $pixbuf = scale_pixbuf $board_img, $w, $h, 'bilinear', 0; # nearest for extra speed |
343 | $pixbuf = scale_pixbuf $board_img, $w, $h, 'bilinear', 0; # nearest for extra speed |
347 | } |
344 | } |
348 | |
345 | |
349 | my $linew = int ($w / 40 / $size); |
346 | my $linew = int $w / 40 / $size; |
350 | |
347 | |
351 | # ornamental border... we have time to waste :/ |
348 | # ornamental border... we have time to waste :/ |
352 | pixbuf_rect $pixbuf, 0xffcc7700, 0, 0, $w-1, $linew, 255; |
349 | pixbuf_rect $pixbuf, 0xffcc7700, 0, 0, $w-1, $linew, 255; |
353 | pixbuf_rect $pixbuf, 0xffcc7700, 0, 0, $linew, $h-1, 255; |
350 | pixbuf_rect $pixbuf, 0xffcc7700, 0, 0, $linew, $h-1, 255; |
354 | pixbuf_rect $pixbuf, 0xffcc7700, $w-$linew-1, 0, $w-1, $h-1, 255; |
351 | pixbuf_rect $pixbuf, 0xffcc7700, $w-$linew-1, 0, $w-1, $h-1, 255; |