Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | #$Id: Circle.pm,v 1.1 2003/04/29 18:19:54 malay Exp $ |
2 | # Perl module for Pastel::Geometry::Circle | |
3 | # Author: Malay < curiouser@ccmb.res.in > | |
4 | # Copyright (c) 2003 by Malay. All rights reserved. | |
5 | # You may distribute this module under the same terms as perl itself | |
6 | ||
7 | =head1 NAME | |
8 | ||
9 | Pastel::Geometry::Circle - DESCRIPTION of Object | |
10 | ||
11 | =head1 SYNOPSIS | |
12 | ||
13 | Give standard usage here | |
14 | ||
15 | =head1 DESCRIPTION | |
16 | ||
17 | Describe the object here | |
18 | ||
19 | =cut | |
20 | ||
21 | package Pastel::Geometry::Circle; | |
22 | @ISA = qw(Pastel::Geometry::Ellipse); | |
23 | ||
24 | use Pastel::Mixin::Mixin; | |
25 | use strict; | |
26 | ||
27 | =head1 CONSTRUCTOR | |
28 | ||
29 | =cut | |
30 | ||
31 | sub new { | |
32 | my ( $class, @args ) = @_; | |
33 | $class = ref($class) || $class; | |
34 | my ( $x, $y, $d ) = | |
35 | Pastel::Mixin::Mixin->_rearrange( [ "X", "Y", "DIA" ], @args ); | |
36 | #print STDERR "circle:", " $x "," $y "," $d ", "\n"; | |
37 | my $self = $class->SUPER::new( $x, $y, $d, $d ); | |
38 | bless $self, $class; | |
39 | #$self->_init(@args); | |
40 | ||
41 | #print "****", $self->{_mac_header}, "\n"; | |
42 | return $self; | |
43 | } | |
44 | ||
45 | sub _init { | |
46 | my ( $self, @args ) = @_; | |
47 | #print STDERR "Circle init callled\n@args\n"; | |
48 | $self->SUPER::_init(@args); | |
49 | ||
50 | } | |
51 | ||
52 | =head1 METHODS | |
53 | ||
54 | =head2 get_center() | |
55 | ||
56 | Describe your function here | |
57 | ||
58 | Usage : | |
59 | Args : | |
60 | Returns : | |
61 | ||
62 | =cut | |
63 | ||
64 | ||
65 | sub get_center { | |
66 | my $self = shift; | |
67 | my $x = $self->get_x() + ($self->get_width() / 2); | |
68 | my $y = $self->get_y() + ($self->get_height()/ 2); | |
69 | return Pastel::Geometry::Point->new(-x=>$x, -y=>$y); | |
70 | ||
71 | } | |
72 | ||
73 | =head2 get_radius() | |
74 | ||
75 | Describe your function here | |
76 | ||
77 | Usage : | |
78 | Args : | |
79 | Returns : | |
80 | ||
81 | =cut | |
82 | ||
83 | ||
84 | sub get_radius { | |
85 | my $self = shift; | |
86 | if ($self->get_width() == $self->get_height()){ | |
87 | ||
88 | return $self->get_width() / 2; | |
89 | } | |
90 | } | |
91 | ||
92 | =head2 _draw() | |
93 | ||
94 | Describe your function here | |
95 | ||
96 | Usage : | |
97 | Args : | |
98 | Returns : | |
99 | ||
100 | =cut | |
101 | ||
102 | sub _draw{ | |
103 | my ($self,$g) = @_; | |
104 | my $style = $self->get_style($g); | |
105 | my $s = "<circle cx=\"".$self->get_center()->get_x()."\" cy=\""; | |
106 | $s .= $self->get_center()->get_y()."\" r=\""; | |
107 | $s .= $self->get_radius(). "\" style=\"$style\" />"; | |
108 | return $s; | |
109 | } | |
110 | ||
111 | ||
112 | =head1 SEE ALSO | |
113 | ||
114 | ||
115 | =head1 COPYRIGHTS | |
116 | ||
117 | Copyright (c) 2003 by Malay <curiouser@ccmb.res.in>. All rights reserved. | |
118 | ||
119 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | |
120 | ||
121 | =cut | |
122 | ||
123 | 1; |