| 1 | use Renard::Incunabula::Common::Setup; | ||
| 2 | package Intertangle::Taffeta::Graphics::Rectangle; | ||
| 3 | # ABSTRACT: Graphics object for raster images | ||
| 4 | $Intertangle::Taffeta::Graphics::Rectangle::VERSION = '0.001'; | ||
| 5 | use Moo; | ||
| 6 | |||
| 7 | extends qw(Intertangle::Taffeta::Graphics); | ||
| 8 | |||
| 9 | use Intertangle::Taffeta::Types qw(CairoContext SVG Dimension); | ||
| 10 | |||
| 11 | has [qw(width height)] => ( | ||
| 12 | is => 'ro', | ||
| 13 | isa => Dimension, | ||
| 14 | required => 1, | ||
| 15 | ); | ||
| 16 | |||
| 17 | method _build_size() { | ||
| 18 | Intertangle::Yarn::Graphene::Size->new( | ||
| 19 | width => $self->width, | ||
| 20 | height => $self->height, | ||
| 21 | ); | ||
| 22 | } | ||
| 23 | |||
| 24 | method cairo_path( (CairoContext) $cr ) { | ||
| 25 | $cr->rectangle( | ||
| 26 | $self->origin->x, | ||
| 27 | $self->origin->y, | ||
| 28 | $self->width, | ||
| 29 | $self->height, | ||
| 30 | ); | ||
| 31 | } | ||
| 32 | |||
| 33 | method render_svg( (SVG) $svg ) { | ||
| 34 | $svg->rectangle( | ||
| 35 | x => $self->origin->x, | ||
| 36 | y => $self->origin->y, | ||
| 37 | width => $self->width, | ||
| 38 | height => $self->height, | ||
| 39 | $self->svg_style_parameter, | ||
| 40 | $self->svg_transform_parameter, | ||
| 41 | ); | ||
| 42 | } | ||
| 43 | |||
| 44 | with qw( | ||
| 45 | Intertangle::Taffeta::Graphics::Role::WithBounds | ||
| 46 | Intertangle::Taffeta::Graphics::Role::WithFill | ||
| 47 | Intertangle::Taffeta::Graphics::Role::WithTransform | ||
| 48 | Intertangle::Taffeta::Graphics::Role::WithStroke | ||
| 49 | Intertangle::Taffeta::Graphics::Role::CairoRenderable::WithCairoPath | ||
| 50 | Intertangle::Taffeta::Graphics::Role::SVGRenderable | ||
| 51 | Intertangle::Taffeta::Graphics::Role::SVGRenderable::Style | ||
| 52 | Intertangle::Taffeta::Graphics::Role::SVGRenderable::Transform | ||
| 53 | ); | ||
| 54 | |||
| 55 | 1; | ||
| 56 | |||
| 57 | __END__ |