« blib/lib/CXC/Gnuplot/V1/MultiPlot/Margins.pm
↑ Summary
blib/lib/CXC/Gnuplot/V1/Terminal/cairo.pm »
| 1 | package CXC::Gnuplot::V1::TermOptions; | ||
| 2 | |||
| 3 | 1 | ▶ | use v5.38; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Object::Pad 0.821; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 5 | use experimental 'builtin', 'declared_refs'; | ||
| 6 | |||
| 7 | our $VERSION = 'v0.29.3'; | ||
| 8 | |||
| 9 | class CXC::Gnuplot::V1::TermOptions : isa(CXC::Gnuplot::V1::Base) | ||
| 10 | does( CXC::Gnuplot::V1::Role::Clone ); | ||
| 11 | |||
| 12 | use CXC::Gnuplot::V1::Util | ||
| 13 | -lexical => 'pvalidate', | ||
| 14 | 'render_opts', 'render_set'; | ||
| 15 | use CXC::Gnuplot::V1::Types -lexical, qw( PositiveNum SetFormats signature_for ); | ||
| 16 | |||
| 17 | use builtin::compat 'blessed', 'is_bool', 'true'; | ||
| 18 | |||
| 19 | my sub croak { | ||
| 20 | require Carp; | ||
| 21 | goto \&Carp::croak; | ||
| 22 | } | ||
| 23 | |||
| 24 | #<<< no tidy | ||
| 25 | field $enhanced :param :reader = undef; | ||
| 26 | field $font :param :reader = undef; | ||
| 27 | field $fontscale :param :reader = undef; | ||
| 28 | field $linewidth :param :reader = undef; | ||
| 29 | field $dashlength :param :reader = undef; | ||
| 30 | field $pointscale :param :reader = undef; | ||
| 31 | #>>> | ||
| 32 | |||
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | |||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | ADJUST { | ||
| 55 | defined $enhanced | ||
| 56 | and !is_bool( $enhanced ) | ||
| 57 | and croak( q{invalid value for "enhanced" parameter: must be bool} ); | ||
| 58 | |||
| 59 | pvalidate( font => Font => \$font ); | ||
| 60 | pvalidate( fontscale => PositiveNum, \$fontscale ); | ||
| 61 | pvalidate( linewidth => PositiveNum, \$linewidth ); | ||
| 62 | pvalidate( dashlength => PositiveNum, \$dashlength ); | ||
| 63 | pvalidate( pointscale => PositiveNum, \$pointscale ); | ||
| 64 | } | ||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | |||
| 85 | method to_hash { | ||
| 86 | return { | ||
| 87 | ( defined $enhanced ? ( enhanced => $enhanced ) : () ), | ||
| 88 | ( defined $font ? ( font => $font ) : () ), | ||
| 89 | ( defined $fontscale ? ( fontscale => $fontscale ) : () ), | ||
| 90 | ( defined $linewidth ? ( linewidth => $linewidth ) : () ), | ||
| 91 | ( defined $dashlength ? ( dashlength => $dashlength ) : () ), | ||
| 92 | ( defined $pointscale ? ( pointscale => $pointscale ) : () ), | ||
| 93 | }; | ||
| 94 | } | ||
| 95 | |||
| 96 | my sub set_attr ( $label, $value, $set_opts = {} ) { | ||
| 97 | my \%set_opts = $set_opts; | ||
| 98 | return () unless defined $value; | ||
| 99 | return blessed( $value ) | ||
| 100 | ? $value->set( %set_opts ) | ||
| 101 | : [ set => termoption => $label => $value ]; | ||
| 102 | } | ||
| 103 | |||
| 104 | |||
| 105 | |||
| 106 | |||
| 107 | |||
| 108 | signature_for set => ( | ||
| 109 | method => 1, | ||
| 110 | named => [ | ||
| 111 | as => SetFormats, | ||
| 112 | { default => 'string' }, | ||
| 113 | ], | ||
| 114 | ); | ||
| 115 | |||
| 116 | method set ( $opt ) { | ||
| 117 | ## no critic(NamingConventions::ProhibitAmbiguousNames) | ||
| 118 | |||
| 119 | my %format = ( as => $opt->as ); | ||
| 120 | |||
| 121 | ## no critic (NamingConventions::ProhibitAmbiguousNames) | ||
| 122 | my @set; | ||
| 123 | |||
| 124 | defined $enhanced | ||
| 125 | and push @set, [ set => termoption => $enhanced ? 'enhanced' : 'noenhanced' ]; | ||
| 126 | |||
| 127 | push @set, | ||
| 128 | set_attr( fontscale => $fontscale, \%format ), | ||
| 129 | set_attr( linewidth => $linewidth, \%format ), | ||
| 130 | set_attr( dashlength => $dashlength, \%format ), | ||
| 131 | set_attr( pointscale => $pointscale, \%format ), | ||
| 132 | ; | ||
| 133 | |||
| 134 | push @set, render_opts( [qw( set termoption font )], $font ); | ||
| 135 | |||
| 136 | return render_set( \@set, $opt->as ); | ||
| 137 | } | ||
| 138 | |||
| 139 | 1; | ||
| 140 | |||
| 141 | # | ||
| 142 | # This file is part of CXC-Gnuplot | ||
| 143 | # | ||
| 144 | # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory. | ||
| 145 | # | ||
| 146 | # This is free software, licensed under: | ||
| 147 | # | ||
| 148 | # The GNU General Public License, Version 3, June 2007 | ||
| 149 | # | ||
| 150 | |||
| 151 | __END__ | ||