ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/bin/kgsueme
(Generate patch)

Comparing kgsueme/bin/kgsueme (file contents):
Revision 1.19 by pcg, Fri May 30 10:54:26 2003 UTC vs.
Revision 1.24 by pcg, Fri May 30 11:59:28 2003 UTC

80 80
81 my $state = -r $staterc ? Storable::retrieve($staterc) : {}; 81 my $state = -r $staterc ? Storable::retrieve($staterc) : {};
82 my @widgets; 82 my @widgets;
83 83
84 $config = $state->{config} ||= {}; 84 $config = $state->{config} ||= {};
85
86 $config{speed} = 1;#d# optimize for speed or memory?
87 $config{conserve_memory} = 0;
85 88
86 # grr... more gtk+ brokenness 89 # grr... more gtk+ brokenness
87 my %get = ( 90 my %get = (
88 hpane_position => sub { ($_[0]->children)[0]->allocation->[2] }, 91 hpane_position => sub { ($_[0]->children)[0]->allocation->[2] },
89 vpane_position => sub { ($_[0]->children)[0]->allocation->[3] }, 92 vpane_position => sub { ($_[0]->children)[0]->allocation->[3] },
643 646
644# create a stack of stones 647# create a stack of stones
645sub create_stack { 648sub create_stack {
646 my ($self, $mark, $size, $rand) = @_; 649 my ($self, $mark, $size, $rand) = @_;
647 650
651 my $shadow = $size * 0.06;
652
648 my $c = \$self->{stack}{$mark}; 653 my $c = \$self->{stack}{$mark};
649 unless ($$c) { 654 unless ($$c) {
650 for my $stone ($mark & (MARK_W | MARK_GRAY_W) ? @::white_img : @::black_img) { 655 for my $stone ($mark & (MARK_W | MARK_GRAY_W) ? @::white_img : @::black_img) {
651 my $base = new_pixbuf $size, $size, 1, 1; 656 my $base = new_pixbuf $size + $shadow, $size + $shadow, 1, 1;
657
658 # zeroeth the shadow
659 if ($mark & (MARK_B | MARK_W)) {
660 $::black_img[0]->composite (
661 $base, $shadow, $shadow, $size, $size, $shadow-0.5, $shadow-0.5,
662 $size / $stone->get_width, $size / $stone->get_height,
663 $::config{speed} ? INTERP_NEAREST : INTERP_TILES, 128
664 );
665 }
652 666
653 # first the big stones 667 # first the big stones
654 for ([MARK_B, 255], 668 for ([MARK_B, 255],
655 [MARK_W, 255], 669 [MARK_W, 255],
656 [MARK_GRAY_B, 128], 670 [MARK_GRAY_B, 128],
658 my ($mask, $alpha) = @$_; 672 my ($mask, $alpha) = @$_;
659 if ($mark & $mask) { 673 if ($mark & $mask) {
660 $stone->composite ( 674 $stone->composite (
661 $base, 0, 0, $size, $size, -0.5, -0.5, 675 $base, 0, 0, $size, $size, -0.5, -0.5,
662 $size / $stone->get_width, $size / $stone->get_height, 676 $size / $stone->get_width, $size / $stone->get_height,
663 INTERP_HYPER, $alpha 677 $::config{speed} ? INTERP_NEAREST : INTERP_HYPER, $alpha
664 ); 678 );
665 } 679 }
666 } 680 }
667 681
668 # then the samll stones 682 # then the samll stones
671 my ($mask, $img) = @$_; 685 my ($mask, $img) = @$_;
672 if ($mark & $mask) { 686 if ($mark & $mask) {
673 $img->composite ( 687 $img->composite (
674 $base, ($size / 4) x2, (int ($size / 2 + 0.5)) x2, ($size / 4 - 0.5) x 2, 688 $base, ($size / 4) x2, (int ($size / 2 + 0.5)) x2, ($size / 4 - 0.5) x 2,
675 $size / $img->get_width / 2, $size / $img->get_height / 2, 689 $size / $img->get_width / 2, $size / $img->get_height / 2,
676 INTERP_HYPER, 192 690 $::config{speed} ? INTERP_NEAREST : INTERP_HYPER, 192
677 ); 691 );
678 } 692 }
679 } 693 }
680 694
681 # and lastly any markers (labels NYI) 695 # and lastly any markers (labels NYI)
687 my ($mask, $img) = @$_; 701 my ($mask, $img) = @$_;
688 if ($mark & $mask) { 702 if ($mark & $mask) {
689 $img->composite ( 703 $img->composite (
690 $base, 0, 0, $size, $size, -0.5, -0.5, 704 $base, 0, 0, $size, $size, -0.5, -0.5,
691 $size / $img->get_width, $size / $img->get_height, 705 $size / $img->get_width, $size / $img->get_height,
692 INTERP_HYPER, 255 706 $::config{speed} ? INTERP_NEAREST : INTERP_HYPER, 255
693 ); 707 );
694 } 708 }
695 } 709 }
696 710
697 push @$$c, $base; 711 push @$$c, $base;
713 $x -= $w * $s * 0.5; 727 $x -= $w * $s * 0.5;
714 $y -= $height * 0.5; 728 $y -= $height * 0.5;
715 729
716 $c->composite ($pixbuf, 730 $c->composite ($pixbuf,
717 $x, $y, $w*$s+0.5, $height+0.5, $x-0.5, $y-0.5, $s, $s, 731 $x, $y, $w*$s+0.5, $height+0.5, $x-0.5, $y-0.5, $s, $s,
718 INTERP_BILINEAR, 192); 732 $::config{speed} ? INTERP_NEAREST : INTERP_BILINEAR, 192);
719 733
720 } else { 734 } else {
721 warn "unable to render character '$text'"; 735 warn "unable to render character '$text'";
722 } 736 }
723} 737}
749 763
750 my $size = $self->{size}; 764 my $size = $self->{size};
751 765
752 my $border = int ($s / $size); 766 my $border = int ($s / $size);
753 my $s2 = $s - $border * 2; 767 my $s2 = $s - $border * 2;
754 my $edge = int ($s2 / $size) | 1; 768 my $edge = int ($s2 / $size * 0.97);
755 my $ofs = int ($edge / 2); 769 my $ofs = int ($edge / 2);
756 770
757 my @k = map int ($s2 * $_ / $size - $ofs + $border + 0.5), 0 .. $size; 771 my @k = map int ($s2 * $_ / $size - $ofs + $border + 0.5), 0 .. $size;
758 772
759 unless ($self->{background}) {
760 my $pixbuf; 773 my $pixbuf;
761 774
775 if ($self->{background}) {
776 $pixbuf = $self->{background}->copy;
777 } else {
762 my ($bw, $bh) = ($::board_img->get_width, $::board_img->get_height); 778 my ($bw, $bh) = ($::board_img->get_width, $::board_img->get_height);
763 779
764 if ($s < $bw && $s < $bh) { 780 if ($s < $bw && $s < $bh) {
765 $pixbuf = new_pixbuf $s, $s, 1, 0; 781 $pixbuf = new_pixbuf $s, $s, $::config{conserve_memory} ? 0 : 1, 0;
766 $::board_img->copy_area (0, 0, $s, $s, $pixbuf, 0, 0); 782 $::board_img->copy_area (0, 0, $s, $s, $pixbuf, 0, 0);
767 } else { 783 } else {
768 $pixbuf = scale_pixbuf $::board_img, $s, $s, INTERP_TILES; 784 $pixbuf = scale_pixbuf $::board_img, $s, $s, $::config{speed} ? INTERP_NEAREST : INTERP_TILES;
769 } 785 }
770 786
771 my $linew = int ($s / 300); 787 my $linew = int ($s / 500);
772 788
773 my $a = "A"; 789 my $a = "A";
774 for my $i (1 .. $size) { 790 for my $i (1 .. $size) {
775 pixbuf_rect $pixbuf, $k[$i] - $linew, $k[1] - $linew, $k[$i] + $linew, $k[$size] + $linew; 791 pixbuf_rect $pixbuf, $k[$i] - $linew, $k[1] - $linew, $k[$i] + $linew, $k[$size] + $linew;
776 pixbuf_rect $pixbuf, $k[1] - $linew, $k[$i] - $linew, $k[$size] + $linew, $k[$i] + $linew; 792 pixbuf_rect $pixbuf, $k[1] - $linew, $k[$i] - $linew, $k[$size] + $linew, $k[$i] + $linew;
782 798
783 $a++; 799 $a++;
784 $a++ if $a eq "I"; # not correct, instead of AA AB, we should get HH JJ KK... 800 $a++ if $a eq "I"; # not correct, instead of AA AB, we should get HH JJ KK...
785 } 801 }
786 802
803 unless ($::config->{conserve_memory}) {
787 $self->{background} = $pixbuf; 804 $self->{background} = $pixbuf;
805 $pixbuf = $pixbuf->copy;
806 }
788 } 807 }
789 808
790 my $pixbuf = $self->{pixbuf} = $self->{background}->copy; 809 $self->{pixbuf} = $pixbuf;
791 810
792 # hoshi-points(!)#d# 811 # hoshi-points(!)#d#
793 # caching of empty board gfx(!)#d# 812 # caching of empty board gfx(!)#d#
794 813
795 for my $x (1 .. $size) { 814 for my $x (1 .. $size) {
798 817
799 if ($mark) { 818 if ($mark) {
800 my ($dx, $dy) = ($k[$x] - $ofs, $k[$y] - $ofs); 819 my ($dx, $dy) = ($k[$x] - $ofs, $k[$y] - $ofs);
801 my $pb = $self->create_stack($mark, $edge, $x * 17 + $y * 11 ); 820 my $pb = $self->create_stack($mark, $edge, $x * 17 + $y * 11 );
802 821
803 $pb->composite ($pixbuf, $dx, $dy, $edge, $edge, $dx, $dy, 1, 1, INTERP_NEAREST, 255); 822 $pb->composite ($pixbuf, $dx, $dy, $pb->get_width, $pb->get_height,
823 $dx, $dy, 1, 1, $::config{speed} ? INTERP_NEAREST : INTERP_NEAREST, 255);
804 824
805 #my ($pm, $bm) = $self->create_stack($gc, $mark, $edge, $x * 17 + $y * 11 ); 825 #my ($pm, $bm) = $self->create_stack($gc, $mark, $edge, $x * 17 + $y * 11 );
806 826
807 #$gc->set_clip_mask ($bm); 827 #$gc->set_clip_mask ($bm);
808 #$gc->set_clip_origin ($dx, $dy); 828 #$gc->set_clip_origin ($dx, $dy);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines