From 020762baaeea7a0d4509fb03cf33ef92399cc600 Mon Sep 17 00:00:00 2001 From: mertz Date: Tue, 8 Jul 2003 12:41:25 +0000 Subject: Zetris now works even without openGL. It is just ugly! --- Perl/demos/Tk/demos/zinc_lib/Zetris.pl | 40 ++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'Perl/demos') diff --git a/Perl/demos/Tk/demos/zinc_lib/Zetris.pl b/Perl/demos/Tk/demos/zinc_lib/Zetris.pl index f9e239f..f99778b 100644 --- a/Perl/demos/Tk/demos/zinc_lib/Zetris.pl +++ b/Perl/demos/Tk/demos/zinc_lib/Zetris.pl @@ -30,13 +30,13 @@ # # - This TkTetris-like uses a tk widget similar to the canvas # and called "Zinc". Zinc bring to Tk widgets openGL features -# like transparency, color gradiants, scaling. -# So to use Zetris you need openGL capability. +# like transparency, color gradients, scaling. +# So to use Zetris graphic enhancement, you need openGL capability. # Zinc comes with other features like grouping and clipping. # -# - A color gradiant is used for Zetris background, +# - A color gradient is used for Zetris background, # -# - Zetris balls are filled with transparently color gradiants, +# - Zetris balls are filled with transparently color gradients, # (transparency is visible when balls fall over TkZinc logo) # # - Zetris balls have a little transparent shadow, @@ -47,10 +47,11 @@ # This feature is particularly useful for applying transformations, # # - The TkZinc logo over background isn't an image but only curves -# and color gradiants (made by ) +# and color gradients (made by ) # # - Please feel free to provide any feedback to -# +# +# - CM: Zetris now works even without openGL. It is just ugly! # #------------------------------------------------------------------------------ @@ -233,7 +234,12 @@ my $tetris = $top->Zinc(-width => $step_x*($width-2), -lightangle => 130, -render => 1, )->pack; -die "no openGL rendering on this X server" unless $tetris->cget(-render); + +# Zetris will no more die if there is no openGL render. I did some minor +# modification (transparency, item priority) to make all needed item +# visible, even without alpha-transparency + +my $render = $tetris->cget(-render); my $shadow_group = $tetris->add('group',1, -visible => 1); @@ -249,7 +255,7 @@ $tetris->add('rectangle', [0, 0,$step_x*($width-2) ,$step_y*($height-1)] , -filled => 1, -linewidth => 0, - -fillcolor => "=axial 90 |black;40|gray80;60", + -fillcolor => $render ? "=axial 90 |black;40|gray80;60" : "grey80", -visible => 1); my $group = $tetris->add('group', 1, ); @@ -259,7 +265,7 @@ my $logo = Tk::Zinc::Logo->new(-widget => $tetris, $step_y*($height-1)/2], ); -$tetris->lower($group); +$tetris->lower($group) if $render; my $score_group = $tetris->add('group',1, -visible => 1); my $new = $tetris->add('text',$score_group, @@ -268,8 +274,14 @@ my $new = $tetris->add('text',$score_group, -font => $basefont->($fontheight), -position => [$width-2,10], ); +$tetris->add('text',$score_group, + -text => "Sorry, without openGL,\nZtetris is just ugly.", + #-anchor => 'e', + -font => $basefont->($fontheight), + -position => [$width-2,100], + ) if !$render; -$tetris->lower($score_group); +$tetris->lower($score_group) if $render; my $timer = $top->after(speed(), sub { $old_win_height = $top->height; @@ -545,17 +557,16 @@ sub rectangle { my($xx, $yy); ($xx, $yy) = (($x-1)*$step_x, $y*$step_y); - my $dark_color; - $dark_color = $color_dark{$mode}; my $color = $color_bright{$mode}; # Adding new Zinc item : ball shadow my $ombre=$zinc->add( 'arc',$shadow_group,[$xx+10,$yy+10,$xx+$boxsize_x+10,$yy+$boxsize_y+10], -visible=>1, -filled=>1, - -fillcolor => "=path 50 50 |black;100 0|black;80 20|black;0 100", # color gradiant + -fillcolor => $render ? "=path 50 50 |black;100 0|black;80 20|black;0 100" : "grey90", # color gradiant -linewidth => 0, -linecolor => 'yellow', + -priority => $render ? 6 : 10, -tags => ["ombre$x-$y"]); $zinc->itemconfigure($shadow_group, -priority => 2); @@ -565,8 +576,9 @@ sub rectangle 'arc',$topgroup,[$xx,$yy,$xx+$boxsize_x,$yy+$boxsize_y], -visible=>1, -filled=>1, - -fillcolor => "=radial -20 -20 |white;90|$color;90" , + -fillcolor => $render ? "=radial -20 -20 |white;90|$color;90" : $color, -linewidth => 1, + -priority => 5, -linecolor => "$color;80", -tags => ["$x-$y"]); } -- cgit v1.1