| 1 | use 5.14.0; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use CairoX::Sweet::Standard; | ||
| 5 | |||
| 6 | our $VERSION = '0.0108'; # VERSION | ||
| 7 | # PODNAME: CairoX::Sweet::Core::CurveTo | ||
| 8 | |||
| 9 | class CairoX::Sweet::Core::CurveTo with CairoX::Sweet::Role::PathCommand using Moose { | ||
| 10 | |||
| 11 | use CairoX::Sweet::Core::Point; | ||
| 12 | |||
| 13 | has points => ( | ||
| 14 | is => 'ro', | ||
| 15 | isa => ArrayRef[Point], | ||
| 16 | traits => ['Array'], | ||
| 17 | required => 1, | ||
| 18 | handles => { | ||
| 19 | all_points => 'elements', | ||
| 20 | get_point => 'get', | ||
| 21 | } | ||
| 22 | ); | ||
| 23 | has is_relative => ( | ||
| 24 | is => 'ro', | ||
| 25 | isa => Bool, | ||
| 26 | required => 1, | ||
| 27 | ); | ||
| 28 | |||
| 29 | around BUILDARGS($orig: $self, Num $x1, Num $y1, Num $x2, Num $y2, Num $x3, Num $y3, Bool :$is_relative = 0) { | ||
| 30 | $self->$orig(is_relative => $is_relative, points => [ | ||
| 31 | CairoX::Sweet::Core::Point->new(x => $x1, y => $y1), | ||
| 32 | CairoX::Sweet::Core::Point->new(x => $x2, y => $y2), | ||
| 33 | CairoX::Sweet::Core::Point->new(x => $x3, y => $y3) | ||
| 34 | ]); | ||
| 35 | } | ||
| 36 | method out { | ||
| 37 | return map { $_->out } $self->all_points; | ||
| 38 | } | ||
| 39 | method method { | ||
| 40 | return $self->is_relative ? 'rel_curve_to' : 'curve_to'; | ||
| 41 | } | ||
| 42 | method location { | ||
| 43 | return $self->get_point(-1); | ||
| 44 | } | ||
| 45 | method move_location(:$x = 0, :$y = 0) { | ||
| 46 | foreach my $point ($self->all_points) { | ||
| 47 | $point->move(x => $x, y => $y); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | 1; | ||
| 53 | |||
| 54 | __END__ | ||
| 55 | |||
| 56 | =pod | ||
| 57 | |||
| 58 | =encoding UTF-8 | ||
| 59 | |||
| 60 | =head1 NAME | ||
| 61 | |||
| 62 | CairoX::Sweet::Core::CurveTo | ||
| 63 | |||
| 64 | =head1 VERSION | ||
| 65 | |||
| 66 | Version 0.0108, released 2015-03-21. | ||
| 67 | |||
| 68 | =head1 SOURCE | ||
| 69 | |||
| 70 | L<https://github.com/Csson/p5-CairoX-Sweet> | ||
| 71 | |||
| 72 | =head1 HOMEPAGE | ||
| 73 | |||
| 74 | L<https://metacpan.org/release/CairoX-Sweet> | ||
| 75 | |||
| 76 | =head1 AUTHOR | ||
| 77 | |||
| 78 | Erik Carlsson <info@code301.com> | ||
| 79 | |||
| 80 | =head1 COPYRIGHT AND LICENSE | ||
| 81 | |||
| 82 | This software is copyright (c) 2015 by Erik Carlsson <info@code301.com>. | ||
| 83 | |||
| 84 | This is free software; you can redistribute it and/or modify it under | ||
| 85 | the same terms as the Perl 5 programming language system itself. | ||
| 86 | |||
| 87 | =cut |