From c5866f304210618979d03c561b1e3f6f83200bce Mon Sep 17 00:00:00 2001 From: ribet Date: Wed, 21 Mar 2007 10:19:39 +0000 Subject: Import initial --- src/MTools/GUI/MTexture.pm | 75 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/MTools/GUI/MTexture.pm (limited to 'src/MTools/GUI/MTexture.pm') diff --git a/src/MTools/GUI/MTexture.pm b/src/MTools/GUI/MTexture.pm new file mode 100644 index 0000000..f3dff9e --- /dev/null +++ b/src/MTools/GUI/MTexture.pm @@ -0,0 +1,75 @@ +package MTools::GUI::MTexture; +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU LGPL Libray General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, +# or refer to http://www.gnu.org/copyleft/lgpl.html +# +################################################################## + +# Permet d'appliquer un texture a un objet +# Parametres : +# * parent : pere de l'objet. +# * target : group zinc destine a contenir les images de texture +# * image_name : nom de l'image texture + +use strict; + +use MTools; +use MTools::MGroup; +use MTools::GUI::MImage; + +use vars qw / @ISA /; + + +BEGIN +{ + @ISA = qw /MTools::MGroup/; +} + +sub new { + my ($class, $parent, $target, $image_name) = @_; + my $self = new MTools::MGroup ($parent); + bless $self, $class; + + chggroup ($target, $self); + + my $image = new MTools::GUI::MImage ($self, $image_name); + + my @bb = bbox ($image); + my $img_w = $bb [2] - $bb [0]; + my $img_h = $bb [3] - $bb [1]; + + my @bb = bbox ($target); + my $w = $bb [2] - $bb [0]; + my $h = $bb [3] - $bb [1]; + + mdelete ($image); + + for (my $x = 0; $x < $w; $x += $img_w) + { + for (my $y = 0; $y < $h; $y += $img_h) + { + $image = new MTools::GUI::MImage ($self, $image_name); + $image -> translate ($x + $bb [0], $y + $bb [1]); + } + } + + my $clip = $zinc -> clone ($target); + mconfigure ($clip, -visible => 0); + new MTools::GUI::MClip ($self, $clip); + return $self; +} + + + +1; -- cgit v1.1