| 1 | use Renard::Incunabula::Common::Setup; | ||
| 2 | package Intertangle::Taffeta::Types; | ||
| 3 | # ABSTRACT: Types for Taffeta | ||
| 4 | $Intertangle::Taffeta::Types::VERSION = '0.001'; | ||
| 5 | use Type::Library 0.008 -base, | ||
| 6 | -declare => [qw( | ||
| 7 | CairoContext | ||
| 8 | SVG | ||
| 9 | |||
| 10 | ColorLibrary | ||
| 11 | RGB24Value | ||
| 12 | RGB24Component | ||
| 13 | RGBFloatComponentValue | ||
| 14 | Color | ||
| 15 | |||
| 16 | Opacity | ||
| 17 | Dimension | ||
| 18 | )]; | ||
| 19 | use Type::Utils -all; | ||
| 20 | use Types::Standard qw(Str); | ||
| 21 | use Types::Common::Numeric qw(PositiveOrZeroInt PositiveOrZeroNum); | ||
| 22 | |||
| 23 | use Color::Library; | ||
| 24 | |||
| 25 | class_type "CairoContext", | ||
| 26 | { class => 'Cairo::Context' }; | ||
| 27 | |||
| 28 | class_type "SVG", | ||
| 29 | { class => "SVG::Element" }; | ||
| 30 | |||
| 31 | class_type "ColorLibrary", | ||
| 32 | { class => 'Color::Library::Color' }; | ||
| 33 | |||
| 34 | coerce "ColorLibrary", | ||
| 35 | from Str, via { Color::Library->color($_) }; | ||
| 36 | |||
| 37 | declare RGB24Value => | ||
| 38 | as PositiveOrZeroInt, | ||
| 39 | where { $_ <= 0xFFFFFF }; | ||
| 40 | |||
| 41 | declare RGB24Component => | ||
| 42 | as PositiveOrZeroInt, | ||
| 43 | where { $_ <= 0xFF }; | ||
| 44 | |||
| 45 | declare RGBFloatComponentValue => | ||
| 46 | as PositiveOrZeroNum, | ||
| 47 | where { $_ <= 1.0 }; | ||
| 48 | |||
| 49 | class_type "Color", | ||
| 50 | { class => 'Intertangle::Taffeta::Color' }; | ||
| 51 | |||
| 52 | declare Opacity => | ||
| 53 | as PositiveOrZeroNum, | ||
| 54 | where { $_ <= 1.0 }; | ||
| 55 | |||
| 56 | declare Dimension => | ||
| 57 | as PositiveOrZeroNum; | ||
| 58 | |||
| 59 | 1; | ||
| 60 | |||
| 61 | __END__ |