| 1 | use Renard::Incunabula::Common::Setup; | ||
| 2 | package Intertangle::Taffeta::Graphics::Role::CairoRenderable::WithCairoPath; | ||
| 3 | # ABSTRACT: A role to help draw a Cairo path with styles/transformations | ||
| 4 | $Intertangle::Taffeta::Graphics::Role::CairoRenderable::WithCairoPath::VERSION = '0.001'; | ||
| 5 | use Moo::Role; | ||
| 6 | use Intertangle::Taffeta::Types qw(CairoContext); | ||
| 7 | |||
| 8 | method cairo_path( (CairoContext) $cr ) { | ||
| 9 | ... | ||
| 10 | } | ||
| 11 | |||
| 12 | |||
| 13 | method render_cairo( (CairoContext) $cr ) { | ||
| 14 | $cr->save; | ||
| 15 | |||
| 16 | $cr->set_matrix( | ||
| 17 | $self->transform->cairo_matrix | ||
| 18 | ); | ||
| 19 | |||
| 20 | if( $self->has_fill && ! $self->fill->is_fill_none ) { | ||
| 21 | $cr->set_source_rgba( | ||
| 22 | $self->fill->color->rgb_float_triple, | ||
| 23 | $self->fill->opacity); | ||
| 24 | |||
| 25 | $self->cairo_path( $cr ); | ||
| 26 | $cr->fill; | ||
| 27 | } | ||
| 28 | if( $self->has_stroke && ! $self->stroke->is_stroke_none ) { | ||
| 29 | $cr->set_line_width( $self->stroke->width ); | ||
| 30 | $cr->set_source_rgba( | ||
| 31 | $self->stroke->color->rgb_float_triple, | ||
| 32 | $self->stroke->opacity); | ||
| 33 | |||
| 34 | $self->cairo_path( $cr ); | ||
| 35 | $cr->stroke; | ||
| 36 | } | ||
| 37 | |||
| 38 | $cr->restore; | ||
| 39 | } | ||
| 40 | |||
| 41 | with qw( | ||
| 42 | Intertangle::Taffeta::Graphics::Role::CairoRenderable | ||
| 43 | ); | ||
| 44 | |||
| 45 | 1; | ||
| 46 | |||
| 47 | __END__ |