diff options
author | ribet | 2007-10-15 08:11:48 +0000 |
---|---|---|
committer | ribet | 2007-10-15 08:11:48 +0000 |
commit | 1daf0b8f47f6e8cb9acb3cb4c5f872767dee8402 (patch) | |
tree | 12e8c54ff4c685745e19b6e19736f500a89b061e /src/MTools | |
parent | d8c4819220762f3f63780756353df537c215b06d (diff) | |
download | mtc-1daf0b8f47f6e8cb9acb3cb4c5f872767dee8402.zip mtc-1daf0b8f47f6e8cb9acb3cb4c5f872767dee8402.tar.gz mtc-1daf0b8f47f6e8cb9acb3cb4c5f872767dee8402.tar.bz2 mtc-1daf0b8f47f6e8cb9acb3cb4c5f872767dee8402.tar.xz |
Pour les rigolos qui font de l'antirecouvrement d'objets invisibles.
Diffstat (limited to 'src/MTools')
-rw-r--r-- | src/MTools/Comp/MAntiRecouvrementItem.pm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/MTools/Comp/MAntiRecouvrementItem.pm b/src/MTools/Comp/MAntiRecouvrementItem.pm index 625cefc..fa1509a 100644 --- a/src/MTools/Comp/MAntiRecouvrementItem.pm +++ b/src/MTools/Comp/MAntiRecouvrementItem.pm @@ -85,7 +85,7 @@ sub translate { my ($self, $delta_x, $delta_y) = @_; if ($self -> {__added}) { - if ((abs ($delta_x) >= $self -> mget ('width') / 2) or (abs ($delta_y) >= $self -> mget ('height') / 2)) + if ((abs ($delta_x) >= __max_of(2, $self -> mget ('width') / 2)) or (abs ($delta_y) >= __max_of(2, $self -> mget ('height') / 2))) { my ($mini_dx, $mini_dy) = (int ($delta_x / 2), int ($delta_y / 2)); $self -> translate ($mini_dx, $mini_dy); @@ -164,6 +164,16 @@ sub __update_xy { $self -> notify ('TRANSLATED', $delta_x, $delta_y); } +sub __max_of { + my (@values) = @_; + my $res = $values [0]; + foreach (@values) + { + $res = $_ if ($_ >= $res); + } + return $res; +} + sub scale { my ($self, @params) = @_; MTools::scale ($self, @params); |