| 1 | package PDF::Make::Builder::Shape::Line; | ||||||||||||||||||||
| 2 | 53 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 53 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 53 | ▶ | use Object::Proto; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 53 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 53 | Object::Proto::define('PDF::Make::Builder::Shape::Line', | |||||||||||||||||||
| 8 | 'fill_colour:Str:default(#000)', | ||||||||||||||||||||
| 9 | 'x:Num', 'y:Num', | ||||||||||||||||||||
| 10 | 'ex:Num', 'ey:Num', | ||||||||||||||||||||
| 11 | 'type:Str:default(solid)', | ||||||||||||||||||||
| 12 | 'dash:ArrayRef', | ||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||
| 14 | 53 | Object::Proto::import_accessors('PDF::Make::Builder::Shape::Line'); | |||||||||||||||||||
| 15 | } | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 8 | ▶ | sub add { | ||||||||||||||||||
|
Subroutine
add: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||
| 18 | 8 | my ($self, $builder) = @_; | |||||||||||||||||||
| 19 | 8 | my $page = $builder->page; | |||||||||||||||||||
| 20 | 8 | my $canvas = $page->canvas; | |||||||||||||||||||
| 21 | 8 | my $font = $builder->font; | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 8 | ▶ | my $lx = $self->x // $page->content_x; | ||||||||||||||||||
|
Condition66%2/3
$self->x // $page->content_x
MC/DC0%0/2
$self->x // $page->content_x
$self->x
$page->content_x
Truth table66%2/3
A // B
A= $self->xB= $page->content_x
| |||||||||||||||||||||
| 24 | 8 | ▶ | my $lex = ex($self) // ($page->content_x + $page->width); | ||||||||||||||||||
|
Condition100%2/2
<custom op object_func_get> // $page->content_x + $page->width
MC/DC100%1/1
<custom op object_func_get> // $page->content_x + $page->width
<custom op object_func_get>
Truth table100%2/2
A
A= <custom op object_func_get>
| |||||||||||||||||||||
| 25 | 8 | my $ly = $self->y; | |||||||||||||||||||
| 26 | 8 | my $ley = ey($self); | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 8 | ▶ | if (!defined $ly) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | 6 | $ly = $page->cursor_y; | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | 8 | ▶ | $ley = defined $ley ? $ley : $ly; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 8 | my ($r, $g, $b) = $font->hex_to_rgb(fill_colour $self); | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 8 | $canvas->q->w(1)->RG($r, $g, $b); | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 8 | my $tp = type $self; | |||||||||||||||||||
| 38 | 8 | my $d = dash $self; | |||||||||||||||||||
| 39 | 8 | ▶ | if ($d) { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 40 | 0 | $canvas->d($d, 0); | |||||||||||||||||||
| 41 | } elsif ($tp eq 'dashed') { | ||||||||||||||||||||
| 42 | 1 | $canvas->d([6, 3], 0); | |||||||||||||||||||
| 43 | } elsif ($tp eq 'dots') { | ||||||||||||||||||||
| 44 | 1 | $canvas->J(1)->d([0, 4], 0); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 8 | $canvas->m($lx, $ly)->l($lex, $ley)->S->Q; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | # Advance cursor | ||||||||||||||||||||
| 50 | 8 | $page->advance_y(2); | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 8 | return $self; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 53 | 1; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||