summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-05-10 08:42:06 +0000
committerOlivier Blin <oblin@mandriva.org>2005-05-10 08:42:06 +0000
commit90a06c043cf17b05881f4e9e8726f3fb5858d98a (patch)
tree95bc170f83bcde8c106bae45cd0f8ffdd93c635e /perl-install
parent53fc42dd19e14154042e1fbe82ea0d5fc5a5e2f1 (diff)
downloaddrakx-90a06c043cf17b05881f4e9e8726f3fb5858d98a.tar
drakx-90a06c043cf17b05881f4e9e8726f3fb5858d98a.tar.gz
drakx-90a06c043cf17b05881f4e9e8726f3fb5858d98a.tar.bz2
drakx-90a06c043cf17b05881f4e9e8726f3fb5858d98a.tar.xz
drakx-90a06c043cf17b05881f4e9e8726f3fb5858d98a.zip
move rectangle2xywh(), distance(), farthest() and nearest() from draksplash2 to bootsplash module, create xywh2rectangle()
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/bootsplash.pm55
-rw-r--r--perl-install/standalone/draksplash246
2 files changed, 56 insertions, 45 deletions
diff --git a/perl-install/bootsplash.pm b/perl-install/bootsplash.pm
index 86d78e4fc..3b46b4a66 100644
--- a/perl-install/bootsplash.pm
+++ b/perl-install/bootsplash.pm
@@ -2,6 +2,11 @@ package bootsplash;
use common;
use Xconfig::resolution_and_depth;
+use vars qw(@ISA %EXPORT_TAGS);
+
+@ISA = qw(Exporter);
+%EXPORT_TAGS = (drawing => [qw(rectangle2xywh xywh2rectangle distance farthest nearest)]);
+@EXPORT_OK = map { @$_ } values %EXPORT_TAGS;
my $themes_dir = "$::prefix/usr/share/bootsplash/themes";
my $themes_config_dir = "$::prefix/etc/bootsplash/themes";
@@ -148,4 +153,54 @@ LOGO_CONSOLE=$conf->{LOGO_CONSOLE}
));
}
+sub rectangle2xywh {
+ my ($rect) = @_;
+
+ my $x = min($rect->[0]{X} , $rect->[1]{X});
+ my $y = min($rect->[0]{Y} , $rect->[1]{Y});
+ my $w = abs($rect->[0]{X} - $rect->[1]{X});
+ my $h = abs($rect->[0]{Y} - $rect->[1]{Y});
+ ($x, $y, $w, $h);
+}
+
+sub xywh2rectangle {
+ my ($x, $y, $w, $h) = @_;
+ [ { X => $x, Y => $y }, { X => $x+$w, Y => $y+$w } ];
+}
+
+sub distance {
+ my ($p1, $p2) = @_;
+ sqr($p1->{X} - $p2->{X}) + sqr($p1->{Y} - $p2->{Y});
+}
+
+sub farthest {
+ my ($point, @others) = @_;
+ my $i = 0;
+ my $dist = 0;
+ my $farthest;
+ foreach (@others) {
+ my $d = distance($point, $_);
+ if ($d >= $dist) {
+ $dist = $d;
+ $farthest = $_;
+ }
+ }
+ $farthest;
+}
+
+sub nearest {
+ my ($point, @others) = @_;
+ my $i = 0;
+ my $dist;
+ my $nearest;
+ foreach (@others) {
+ my $d = distance($point, $_);
+ if (! defined $dist || $d < $dist) {
+ $dist = $d;
+ $nearest = $_;
+ }
+ }
+ $nearest;
+}
+
1;
diff --git a/perl-install/standalone/draksplash2 b/perl-install/standalone/draksplash2
index 38bb464d3..b7358e7ba 100644
--- a/perl-install/standalone/draksplash2
+++ b/perl-install/standalone/draksplash2
@@ -10,6 +10,7 @@ use ugtk2 qw(:all);
use Gtk2::Gdk::Keysyms;
use MDK::Common;
use Image::Magick;
+use bootsplash qw(:drawing);
my $kernel_size = 1500; #- in KiB
@@ -160,51 +161,6 @@ sub color_index2gc {
$gc;
}
-sub rectangle2xywh {
- my ($rect) = @_;
-
- my $x = min($rect->[0]{X} , $rect->[1]{X});
- my $y = min($rect->[0]{Y} , $rect->[1]{Y});
- my $w = abs($rect->[0]{X} - $rect->[1]{X});
- my $h = abs($rect->[0]{Y} - $rect->[1]{Y});
- ($x, $y, $w, $h);
-}
-
-sub distance {
- my ($p1, $p2) = @_;
- sqr($p1->{X} - $p2->{X}) + sqr($p1->{Y} - $p2->{Y});
-}
-
-sub farthest {
- my ($point, @others) = @_;
- my $i = 0;
- my $dist = 0;
- my $farthest;
- foreach (@others) {
- my $d = distance($point, $_);
- if ($d >= $dist) {
- $dist = $d;
- $farthest = $_;
- }
- }
- $farthest;
-}
-
-sub nearest {
- my ($point, @others) = @_;
- my $i = 0;
- my $dist;
- my $nearest;
- foreach (@others) {
- my $d = distance($point, $_);
- if (! defined $dist || $d < $dist) {
- $dist = $d;
- $nearest = $_;
- }
- }
- $nearest;
-}
-
sub create_popup() {
my %l = my @l = (
'Progress bar position' => sub { $current_rect = $progress_rect },