| 1 | package Image::WMF; | ||||||||||
| 2 | # Copyright 2002/3 Tony Cox. See accompanying README file for | ||||||||||
| 3 | # usage information | ||||||||||
| 4 | |||||||||||
| 5 | 1 | require 5.00323; | |||||||||
| 6 | 1 | require Exporter; | |||||||||
| 7 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Image::WMF::Constants; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Image::WMF::Colour; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Image::WMF::Font; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Image::WMF::Rectangle; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use Image::WMF::Polygon; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use Image::WMF::Image; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT $AUTOLOAD); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | $VERSION = "1.03"; | |||||||||
| 16 | |||||||||||
| 17 | 1 | @ISA = qw(Exporter); | |||||||||
| 18 | # Items to export into callers namespace by default. Note: do not export | ||||||||||
| 19 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||
| 20 | # Do not simply export all your public functions/methods/constants. | ||||||||||
| 21 | 1 | @EXPORT = qw( | |||||||||
| 22 | gdBrushed | ||||||||||
| 23 | gdDashSize | ||||||||||
| 24 | gdMaxColors | ||||||||||
| 25 | gdStyled | ||||||||||
| 26 | gdStyledBrushed | ||||||||||
| 27 | gdTiled | ||||||||||
| 28 | gdTransparent | ||||||||||
| 29 | gdTinyFont | ||||||||||
| 30 | gdSmallFont | ||||||||||
| 31 | gdMediumBoldFont | ||||||||||
| 32 | gdLargeFont | ||||||||||
| 33 | gdGiantFont | ||||||||||
| 34 | ); | ||||||||||
| 35 | |||||||||||
| 36 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 37 | 1 | my ($class,$x,$y,$resolution) = @_; | |||||||||
| 38 | |||||||||||
| 39 | # A twip (meaning "twentieth of a point") is the logical unit of measurement | ||||||||||
| 40 | # used in Windows Metafiles. A twip is equal to 1/1440 of an inch. Thus 720 twips | ||||||||||
| 41 | # equal 1/2 inch, while 32,768 twips is 22.75 inches. | ||||||||||
| 42 | # The metafile header contains the number of twips per inch used to represent the | ||||||||||
| 43 | # image. Normally, there are 1440 twips per inch; however, this number may be changed | ||||||||||
| 44 | # to scale the image. | ||||||||||
| 45 | # A value of 720 indicates that the image is double its normal size, or scaled | ||||||||||
| 46 | # to a factor of 2:1. A value of 360 indicates a scale of 4:1, while a value of 2880 | ||||||||||
| 47 | # indicates that the image is scaled down in size by a factor of two. A value of 1440 | ||||||||||
| 48 | # indicates a 1:1 scale ratio. | ||||||||||
| 49 | |||||||||||
| 50 | 1 | ▶ | unless (defined $resolution){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | #$resolution = 1440; # Default WMF resolution for 1:1 scaling | ||||||||||
| 52 | 1 | $resolution = 96; # ~72dpi | |||||||||
| 53 | } | ||||||||||
| 54 | 1 | $y *= 4; | |||||||||
| 55 | 1 | $x *= 4; | |||||||||
| 56 | |||||||||||
| 57 | 1 | my $obj = bless { | |||||||||
| 58 | _filename => undef, | ||||||||||
| 59 | _wmf => undef, | ||||||||||
| 60 | _x => undef, | ||||||||||
| 61 | _y => undef, | ||||||||||
| 62 | _bgcolour => undef, | ||||||||||
| 63 | _trans => 0, | ||||||||||
| 64 | _ncolours => 0, | ||||||||||
| 65 | _resolution => undef, | ||||||||||
| 66 | }, $class; | ||||||||||
| 67 | |||||||||||
| 68 | 1 | $obj->_initialise($x,$y,$resolution); | |||||||||
| 69 | 1 | return $obj; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 1 | ▶ | sub _initialise { | ||||||||
|
Subroutine
_initialise: called CC=1 SCAR=0.0
| |||||||||||
| 73 | 1 | my ($self,$x,$y,$resolution) = @_; | |||||||||
| 74 | 1 | $self->{'_x'} = $x; | |||||||||
| 75 | 1 | $self->{'_y'} = $y; | |||||||||
| 76 | 1 | $self->{'_resolution'} = $resolution; | |||||||||
| 77 | 1 | $self->{'_bgcolour'} = new Image::WMF::Colour(255,255,255); | |||||||||
| 78 | 1 | $self->{'_wmf'} = new Image::WMF::Image(); | |||||||||
| 79 | 1 | $self->{'_wmf'}->setROP2($R2_COPYPEN); | |||||||||
| 80 | 1 | $self->{'_wmf'}->setWindowExt($x,$y); | |||||||||
| 81 | 1 | $self->{'_wmf'}->setMapMode($MM_ANISOTROPIC); | |||||||||
| 82 | 1 | $self->{'_wmf'}->setWindowOrg(0,0); | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | 1 | ▶ | sub string { | ||||||||
|
Subroutine
string: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 86 | 1 | my ($self,$font,$x,$y,$string,$c) = @_; | |||||||||
| 87 | # we have been passed a font object so | ||||||||||
| 88 | # need to make a GDI object and handle from it | ||||||||||
| 89 | 1 | ▶ | if ($font->isa("Image::WMF::Font")){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | my $hFont = $self->{'_wmf'}->createFontIndirect( | ||||||||||
| 91 | $font->{'_height'}, | ||||||||||
| 92 | $font->{'_width'}, | ||||||||||
| 93 | $font->{'_esc'}, | ||||||||||
| 94 | $font->{'_ori'}, | ||||||||||
| 95 | $font->{'_weigth'}, | ||||||||||
| 96 | $font->{'_italic'}, | ||||||||||
| 97 | $font->{'_underline'}, | ||||||||||
| 98 | $font->{'_strikeout'}, | ||||||||||
| 99 | $self->{'_wmf'}->toByte($font->{'_charset'}), | ||||||||||
| 100 | $self->{'_wmf'}->toByte($font->{'_outprecision'}), | ||||||||||
| 101 | $self->{'_wmf'}->toByte($font->{'_clipprecision'}), | ||||||||||
| 102 | $self->{'_wmf'}->toByte($font->{'_quality'}), | ||||||||||
| 103 | $self->{'_wmf'}->toByte($font->{'_pitchandfamily'}), | ||||||||||
| 104 | 1 | $font->{'_facename'}, | |||||||||
| 105 | ); | ||||||||||
| 106 | 1 | $self->{'_wmf'}->setTextColour($c); | |||||||||
| 107 | 1 | $self->{'_wmf'}->setBKMode($TRANSPARENT); | |||||||||
| 108 | 1 | $self->{'_wmf'}->setTextAlign($TA_TOP); | |||||||||
| 109 | 1 | $self->{'_wmf'}->selectObject($hFont); | |||||||||
| 110 | 1 | $self->{'_wmf'}->textOut($x,$y,$string); | |||||||||
| 111 | 1 | $self->{'_wmf'}->deleteObject($hFont); | |||||||||
| 112 | 1 | return(1); | |||||||||
| 113 | } else { | ||||||||||
| 114 | 0 | die "Error: string function requires a valid Font object! (got: $font)\n"; | |||||||||
| 115 | } | ||||||||||
| 116 | } | ||||||||||
| 117 | |||||||||||
| 118 | 0 | ▶ | sub filledString { | ||||||||
|
Subroutine
filledString: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 119 | 0 | my ($self,$font,$x,$y,$string,$c,$c2) = @_; | |||||||||
| 120 | # we have been passed a font object so | ||||||||||
| 121 | # need to make a GDI object and handle from it | ||||||||||
| 122 | 0 | ▶ | if ($font->isa("Font")){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 123 | my $hFont = $self->{'_wmf'}->createFontIndirect( | ||||||||||
| 124 | $font->{'_height'}, | ||||||||||
| 125 | $font->{'_width'}, | ||||||||||
| 126 | $font->{'_esc'}, | ||||||||||
| 127 | $font->{'_ori'}, | ||||||||||
| 128 | $font->{'_weigth'}, | ||||||||||
| 129 | $font->{'_italic'}, | ||||||||||
| 130 | $font->{'_underline'}, | ||||||||||
| 131 | $font->{'_strikeout'}, | ||||||||||
| 132 | $self->{'_wmf'}->toByte($font->{'_charset'}), | ||||||||||
| 133 | $self->{'_wmf'}->toByte($font->{'_outprecision'}), | ||||||||||
| 134 | $self->{'_wmf'}->toByte($font->{'_clipprecision'}), | ||||||||||
| 135 | $self->{'_wmf'}->toByte($font->{'_quality'}), | ||||||||||
| 136 | $self->{'_wmf'}->toByte($font->{'_pitchandfamily'}), | ||||||||||
| 137 | 0 | $font->{'_facename'}, | |||||||||
| 138 | ); | ||||||||||
| 139 | 0 | $self->{'_wmf'}->setTextColour($c); | |||||||||
| 140 | 0 | $self->{'_wmf'}->setBKColour($c2); | |||||||||
| 141 | 0 | $self->{'_wmf'}->setBKMode($OPAQUE); | |||||||||
| 142 | 0 | my $hBrush = $self->{'_wmf'}->createBrushIndirect($BS_SOLID,$c2,0); | |||||||||
| 143 | 0 | $self->{'_wmf'}->selectObject($hBrush); | |||||||||
| 144 | 0 | $self->{'_wmf'}->setTextAlign($TA_TOP); | |||||||||
| 145 | 0 | $self->{'_wmf'}->selectObject($hFont); | |||||||||
| 146 | 0 | $self->{'_wmf'}->textOut($x,$y,$string); | |||||||||
| 147 | 0 | $self->{'_wmf'}->deleteObject($hBrush); | |||||||||
| 148 | 0 | $self->{'_wmf'}->deleteObject($hFont); | |||||||||
| 149 | 0 | return(1); | |||||||||
| 150 | } else { | ||||||||||
| 151 | 0 | die "Error: string function requires a valid Font object!\n"; | |||||||||
| 152 | } | ||||||||||
| 153 | } | ||||||||||
| 154 | |||||||||||
| 155 | 0 | ▶ | sub gdTinyFont { | ||||||||
|
Subroutine
gdTinyFont: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 156 | 0 | my $font = new Image::WMF::Font(-6,0,0,0,$FW_BOLD,0,0,0, | |||||||||
| 157 | unpack("C*", 0), | ||||||||||
| 158 | unpack("C*", 0), | ||||||||||
| 159 | unpack("C*", 0), | ||||||||||
| 160 | unpack("C*", 0), | ||||||||||
| 161 | unpack("C*", $FF_SWISS), | ||||||||||
| 162 | "Arial"); | ||||||||||
| 163 | 0 | return($font); | |||||||||
| 164 | } | ||||||||||
| 165 | |||||||||||
| 166 | 1 | ▶ | sub gdSmallFont { | ||||||||
|
Subroutine
gdSmallFont: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 167 | 1 | my $font = new Image::WMF::Font(-7,0,0,0,$FW_BOLD,0,0,0, | |||||||||
| 168 | unpack("C*", 0), | ||||||||||
| 169 | unpack("C*", 0), | ||||||||||
| 170 | unpack("C*", 0), | ||||||||||
| 171 | unpack("C*", 0), | ||||||||||
| 172 | unpack("C*", $FF_SWISS), | ||||||||||
| 173 | "Arial"); | ||||||||||
| 174 | 1 | return($font); | |||||||||
| 175 | } | ||||||||||
| 176 | |||||||||||
| 177 | 0 | ▶ | sub gdMediumBoldFont { | ||||||||
|
Subroutine
gdMediumBoldFont: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 178 | 0 | my $font = new Image::WMF::Font(-14,0,0,0,$FW_BOLD,0,0,0, | |||||||||
| 179 | unpack("C*", 0), | ||||||||||
| 180 | unpack("C*", 0), | ||||||||||
| 181 | unpack("C*", 0), | ||||||||||
| 182 | unpack("C*", 0), | ||||||||||
| 183 | unpack("C*", $FF_SWISS), | ||||||||||
| 184 | "Arial"); | ||||||||||
| 185 | 0 | return($font); | |||||||||
| 186 | } | ||||||||||
| 187 | |||||||||||
| 188 | 0 | ▶ | sub gdLargeFont { | ||||||||
|
Subroutine
gdLargeFont: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 189 | 0 | my $font = new Image::WMF::Font(-15,0,0,0,$FW_BOLD,0,0,0, | |||||||||
| 190 | unpack("C*", 0), | ||||||||||
| 191 | unpack("C*", 0), | ||||||||||
| 192 | unpack("C*", 0), | ||||||||||
| 193 | unpack("C*", 0), | ||||||||||
| 194 | unpack("C*", $FF_SWISS), | ||||||||||
| 195 | "Arial"); | ||||||||||
| 196 | 0 | return($font); | |||||||||
| 197 | } | ||||||||||
| 198 | |||||||||||
| 199 | 0 | ▶ | sub gdGiantFont { | ||||||||
|
Subroutine
gdGiantFont: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 200 | 0 | my $font = new Image::WMF::Font(-17,0,0,0,$FW_NORMAL,0,0,0, | |||||||||
| 201 | unpack("C*", 0), | ||||||||||
| 202 | unpack("C*", 0), | ||||||||||
| 203 | unpack("C*", 0), | ||||||||||
| 204 | unpack("C*", 0), | ||||||||||
| 205 | unpack("C*", $FF_SWISS), | ||||||||||
| 206 | "Arial"); | ||||||||||
| 207 | 0 | return($font); | |||||||||
| 208 | } | ||||||||||
| 209 | |||||||||||
| 210 | 0 | ▶ | sub getBounds { | ||||||||
|
Subroutine
getBounds: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 211 | 0 | my ($self) = @_; | |||||||||
| 212 | 0 | return($self->{'_x'},$self->{'_y'}); | |||||||||
| 213 | } | ||||||||||
| 214 | |||||||||||
| 215 | 0 | ▶ | sub fill { | ||||||||
|
Subroutine
fill: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 216 | 0 | my ($self,$x,$y,$c) = @_; | |||||||||
| 217 | 0 | my $hBrush = $self->{'_wmf'}->createBrushIndirect($BS_SOLID,$c,0); | |||||||||
| 218 | 0 | $self->{'_wmf'}->selectObject($hBrush); | |||||||||
| 219 | 0 | $self->{'_wmf'}->floodFill($x, $y, $c); | |||||||||
| 220 | 0 | $self->{'_wmf'}->deleteObject($hBrush); | |||||||||
| 221 | 0 | return(1); | |||||||||
| 222 | } | ||||||||||
| 223 | |||||||||||
| 224 | 0 | ▶ | sub fillToBorder { | ||||||||
|
Subroutine
fillToBorder: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 225 | 0 | my ($self,$x,$y,$c) = @_; | |||||||||
| 226 | # print STDERR "The fillToBorder method is not implemented yet\n"; | ||||||||||
| 227 | # The GDI funtion number for extFloodFill seems to have problems | ||||||||||
| 228 | # Although published, it is not supported on NT4. | ||||||||||
| 229 | 0 | return(1); | |||||||||
| 230 | 0 | my $hBrush = $self->{'_wmf'}->createBrushIndirect($BS_SOLID,$c,0); | |||||||||
| 231 | 0 | $self->{'_wmf'}->selectObject($hBrush); | |||||||||
| 232 | 0 | $self->{'_wmf'}->extFloodFill($x, $y, $c,$FLOODFILLSURFACE); | |||||||||
| 233 | 0 | $self->{'_wmf'}->deleteObject($hBrush); | |||||||||
| 234 | 0 | return(1); | |||||||||
| 235 | } | ||||||||||
| 236 | |||||||||||
| 237 | 0 | ▶ | sub polygon { | ||||||||
|
Subroutine
polygon: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 238 | 0 | my ($self,$poly,$c) = @_; | |||||||||
| 239 | 0 | my $hPen = $self->{'_wmf'}->createPenIndirect($PS_SOLID,0,$c); | |||||||||
| 240 | 0 | $self->{'_wmf'}->selectObject($hPen); | |||||||||
| 241 | 0 | my $hBrush = $self->{'_wmf'}->createBrushIndirect($BS_HOLLOW,$c,0); | |||||||||
| 242 | 0 | $self->{'_wmf'}->selectObject($hBrush); | |||||||||
| 243 | 0 | my $x_vertices = $poly->_xvertices(); | |||||||||
| 244 | 0 | my $y_vertices = $poly->_yvertices(); | |||||||||
| 245 | 0 | ▶ | if ($poly->length() >= 3){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 246 | 0 | $self->{'_wmf'}->polygon($x_vertices,$y_vertices,$poly->length()); | |||||||||
| 247 | } else { | ||||||||||
| 248 | 0 | die("Cannot create polygon with fewer than 3 vertices!"); | |||||||||
| 249 | } | ||||||||||
| 250 | 0 | $self->{'_wmf'}->deleteObject($hPen); | |||||||||
| 251 | 0 | $self->{'_wmf'}->deleteObject($hBrush); | |||||||||
| 252 | 0 | return(1); | |||||||||
| 253 | } | ||||||||||
| 254 | |||||||||||
| 255 | 1 | ▶ | sub filledPolygon { | ||||||||
|
Subroutine
filledPolygon: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 256 | 1 | my ($self,$poly,$c) = @_; | |||||||||
| 257 | 1 | my $hPen = $self->{'_wmf'}->createPenIndirect($PS_SOLID,0,$c); | |||||||||
| 258 | 1 | $self->{'_wmf'}->selectObject($hPen); | |||||||||
| 259 | 1 | my $hBrush = $self->{'_wmf'}->createBrushIndirect($BS_SOLID,$c,0); | |||||||||
| 260 | 1 | $self->{'_wmf'}->selectObject($hBrush); | |||||||||
| 261 | 1 | my $x_vertices = $poly->_xvertices(); | |||||||||
| 262 | 1 | my $y_vertices = $poly->_yvertices(); | |||||||||
| 263 | 1 | ▶ | if ($poly->length() >= 3){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 264 | 1 | $self->{'_wmf'}->polygon($x_vertices,$y_vertices,$poly->length()); | |||||||||
| 265 | } else { | ||||||||||
| 266 | 0 | die("Cannot create polygon with fewer than 3 vertices!"); | |||||||||
| 267 | } | ||||||||||
| 268 | 1 | $self->{'_wmf'}->deleteObject($hPen); | |||||||||
| 269 | 1 | $self->{'_wmf'}->deleteObject($hBrush); | |||||||||
| 270 | 1 | return(1); | |||||||||
| 271 | } | ||||||||||
| 272 | |||||||||||
| 273 | 0 | ▶ | sub line { | ||||||||
|
Subroutine
line: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 274 | 0 | my ($self,$x1,$y1,$x2,$y2,$c) = @_; | |||||||||
| 275 | 0 | my $hPen = $self->{'_wmf'}->createPenIndirect($PS_SOLID,0,$c); | |||||||||
| 276 | 0 | $self->{'_wmf'}->selectObject($hPen); | |||||||||
| 277 | 0 | $self->{'_wmf'}->moveTo($x1,$y1); | |||||||||
| 278 | 0 | $self->{'_wmf'}->lineTo($x2,$y2); | |||||||||
| 279 | 0 | $self->{'_wmf'}->deleteObject($hPen); | |||||||||
| 280 | 0 | return(1); | |||||||||
| 281 | } | ||||||||||
| 282 | |||||||||||
| 283 | 0 | ▶ | sub dashedLine { | ||||||||
|
Subroutine
dashedLine: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 284 | 0 | my ($self,$x1,$y1,$x2,$y2,$c) = @_; | |||||||||
| 285 | 0 | my $hPen = $self->{'_wmf'}->createPenIndirect($PS_DOT,0,$c); | |||||||||
| 286 | 0 | $self->{'_wmf'}->selectObject($hPen); | |||||||||
| 287 | 0 | $self->{'_wmf'}->moveTo($x1,$y1); | |||||||||
| 288 | 0 | $self->{'_wmf'}->lineTo($x2,$y2); | |||||||||
| 289 | 0 | $self->{'_wmf'}->deleteObject($hPen); | |||||||||
| 290 | 0 | return(1); | |||||||||
| 291 | } | ||||||||||
| 292 | |||||||||||
| 293 | 0 | ▶ | sub setPixel { | ||||||||
|
Subroutine
setPixel: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 294 | 0 | my ($self,$x,$y,$c) = @_; | |||||||||
| 295 | 0 | my $hPen = $self->{'_wmf'}->createPenIndirect($PS_SOLID,0,$c); | |||||||||
| 296 | 0 | $self->{'_wmf'}->selectObject($hPen); | |||||||||
| 297 | 0 | $self->{'_wmf'}->setPixel($x,$y,$c); | |||||||||
| 298 | 0 | $self->{'_wmf'}->deleteObject($hPen); | |||||||||
| 299 | 0 | return(1); | |||||||||
| 300 | } | ||||||||||
| 301 | |||||||||||
| 302 | 0 | ▶ | sub arc { | ||||||||
|
Subroutine
arc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 303 | 0 | my ($self,$x,$y,$x2,$y2,$ax1,$ay1,$ax2,$ay2,$c) = @_; | |||||||||
| 304 | 0 | my $hPen = $self->{'_wmf'}->createPenIndirect($PS_SOLID,0,$c); | |||||||||
| 305 | 0 | $self->{'_wmf'}->selectObject($hPen); | |||||||||
| 306 | 0 | $self->{'_wmf'}->arc($x,$y,$x2,$y2,$ax1,$ay1,$ax2,$ay2,$c); | |||||||||
| 307 | 0 | $self->{'_wmf'}->deleteObject($hPen); | |||||||||
| 308 | 0 | return(1); | |||||||||
| 309 | } | ||||||||||
| 310 | |||||||||||
| 311 | 0 | ▶ | sub rectangle { | ||||||||
|
Subroutine
rectangle: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 312 | 0 | my ($self,$x1,$y1,$x2,$y2,$c) = @_; | |||||||||
| 313 | #print STDERR "Rectangle: $x1,$y1,$x2,$y2\n"; # DEBUG ONLY | ||||||||||
| 314 | 0 | ▶ | if ($x2 - $x1 < 2){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 315 | 0 | $x2 += 1; | |||||||||
| 316 | } | ||||||||||
| 317 | 0 | ▶ | if ($y2 - $y1 < 2){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 318 | 0 | $y2 += 1; | |||||||||
| 319 | } | ||||||||||
| 320 | 0 | my $hPen = $self->{'_wmf'}->createPenIndirect($PS_SOLID,0,$c); | |||||||||
| 321 | 0 | $self->{'_wmf'}->selectObject($hPen); | |||||||||
| 322 | 0 | my $hBrush = $self->{'_wmf'}->createBrushIndirect($BS_HOLLOW,$c,0); | |||||||||
| 323 | 0 | $self->{'_wmf'}->selectObject($hBrush); | |||||||||
| 324 | 0 | $self->{'_wmf'}->rectangle($x1,$y1,$x2,$y2); | |||||||||
| 325 | 0 | $self->{'_wmf'}->deleteObject($hPen); | |||||||||
| 326 | 0 | $self->{'_wmf'}->deleteObject($hBrush); | |||||||||
| 327 | 0 | return(1); | |||||||||
| 328 | } | ||||||||||
| 329 | |||||||||||
| 330 | 1 | ▶ | sub filledRectangle { | ||||||||
|
Subroutine
filledRectangle: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||
| 331 | 1 | my ($self,$x1,$y1,$x2,$y2,$c) = @_; | |||||||||
| 332 | #print STDERR "Filled Rectangle: $x1,$y1,$x2,$y2\n"; # DEBUG ONLY | ||||||||||
| 333 | 1 | ▶ | if ($x2 - $x1 < 2){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 334 | 0 | $x2 += 1; | |||||||||
| 335 | } | ||||||||||
| 336 | 1 | ▶ | if ($y2 - $y1 < 2){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 337 | 0 | $y2 += 1; | |||||||||
| 338 | } | ||||||||||
| 339 | 1 | my $hPen = $self->{'_wmf'}->createPenIndirect($PS_SOLID,0,$c); | |||||||||
| 340 | 1 | $self->{'_wmf'}->selectObject($hPen); | |||||||||
| 341 | 1 | my $hBrush = $self->{'_wmf'}->createBrushIndirect($BS_SOLID,$c,0); | |||||||||
| 342 | #my $hBrush = $self->{'_wmf'}->createBrushIndirect($BS_HOLLOW,$c,0); # DEBUG ONLY | ||||||||||
| 343 | 1 | $self->{'_wmf'}->selectObject($hBrush); | |||||||||
| 344 | 1 | $self->{'_wmf'}->rectangle($x1,$y1,$x2,$y2); | |||||||||
| 345 | 1 | $self->{'_wmf'}->deleteObject($hPen); | |||||||||
| 346 | 1 | $self->{'_wmf'}->deleteObject($hBrush); | |||||||||
| 347 | 1 | return(1); | |||||||||
| 348 | } | ||||||||||
| 349 | |||||||||||
| 350 | 3 | ▶ | sub colorAllocate { | ||||||||
|
Subroutine
colorAllocate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 351 | 3 | my ($self,$r,$g,$b) = @_; | |||||||||
| 352 | 3 | my $colour = new Image::WMF::Colour($r,$g,$b); | |||||||||
| 353 | 3 | $self->{'_ncolours'}++; | |||||||||
| 354 | 3 | return($colour); | |||||||||
| 355 | } | ||||||||||
| 356 | |||||||||||
| 357 | 1 | ▶ | sub colorExact { | ||||||||
|
Subroutine
colorExact: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 358 | 1 | my ($self,$r,$g,$b) = @_; | |||||||||
| 359 | 1 | return($self->colorAllocate($r,$g,$b)); | |||||||||
| 360 | } | ||||||||||
| 361 | |||||||||||
| 362 | 0 | ▶ | sub colorDeallocate { | ||||||||
|
Subroutine
colorDeallocate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 363 | 0 | my ($self,$c) = @_; | |||||||||
| 364 | 0 | $c = undef; | |||||||||
| 365 | } | ||||||||||
| 366 | |||||||||||
| 367 | 0 | ▶ | sub colorsTotal { | ||||||||
|
Subroutine
colorsTotal: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 368 | 0 | my ($self) = @_; | |||||||||
| 369 | 0 | return($self->{'_ncolours'}); | |||||||||
| 370 | } | ||||||||||
| 371 | |||||||||||
| 372 | 0 | ▶ | sub rgb { | ||||||||
|
Subroutine
rgb: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 373 | 0 | my ($self, $c) = @_; | |||||||||
| 374 | 0 | my $r = $c->red(); | |||||||||
| 375 | 0 | my $g = $c->green(); | |||||||||
| 376 | 0 | my $b = $c->blue(); | |||||||||
| 377 | 0 | return($r,$g,$b); | |||||||||
| 378 | } | ||||||||||
| 379 | |||||||||||
| 380 | 1 | ▶ | sub wmf { | ||||||||
|
Subroutine
wmf: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 381 | 1 | my ($self, $resolution) = @_; | |||||||||
| 382 | 1 | $self->{'_wmf'}->deleteObjects(); # clean up undeleted GDI handles | |||||||||
| 383 | 1 | $self->{'_wmf'}->metaRecord(0,0); | |||||||||
| 384 | 1 | return($self->{'_wmf'}->wmf($self->{'_x'},$self->{'_y'},$self->{'_resolution'})); | |||||||||
| 385 | } | ||||||||||
| 386 | |||||||||||
| 387 | 1 | 1; | |||||||||
| 388 | |||||||||||
| 389 | |||||||||||
| 390 | __END__ | ||||||||||