+ Red: $cr vs $red
+Green: $cg vs $green
+ Blue: $cb vs $blue
+Alpha: $ca vs $alpha
+END_DIAG
+ return;
+ }
+
+ return 1;
+}
+
+sub is_fcolor1($$$;$) {
+ my ($color, $grey, $comment_or_diff, $comment_or_undef) = @_;
+ my ($comment, $mindiff);
+ if (defined $comment_or_undef) {
+ ( $mindiff, $comment ) = ( $comment_or_diff, $comment_or_undef )
+ }
+ else {
+ ( $mindiff, $comment ) = ( 0.001, $comment_or_diff )
+ }
+
+ my $builder = Test::Builder->new;
+
+ unless (defined $color) {
+ $builder->ok(0, $comment);
+ $builder->diag("color is undef");
+ return;
+ }
+ unless ($color->can('rgba')) {
+ $builder->ok(0, $comment);
+ $builder->diag("color is not a color object");
+ return;
+ }
+
+ my ($cgrey) = $color->rgba;
+ unless ($builder->ok(abs($cgrey - $grey) <= $mindiff, $comment)) {
+ print <<END_DIAG;
+Color mismatch:
+ Gray: $cgrey vs $grey
+END_DIAG
+ return;
+ }
+
+ return 1;
+}
+
+sub is_fcolor3($$$$$;$) {
+ my ($color, $red, $green, $blue, $comment_or_diff, $comment_or_undef) = @_;
+ my ($comment, $mindiff);
+ if (defined $comment_or_undef) {
+ ( $mindiff, $comment ) = ( $comment_or_diff, $comment_or_undef )
+ }
+ else {
+ ( $mindiff, $comment ) = ( 0.001, $comment_or_diff )
+ }
+
+ my $builder = Test::Builder->new;
+
+ unless (defined $color) {
+ $builder->ok(0, $comment);
+ $builder->diag("color is undef");
+ return;
+ }
+ unless ($color->can('rgba')) {
+ $builder->ok(0, $comment);
+ $builder->diag("color is not a color object");
+ return;
+ }
+
+ my ($cr, $cg, $cb) = $color->rgba;
+ unless ($builder->ok(abs($cr - $red) <= $mindiff
+ && abs($cg - $green) <= $mindiff
+ && abs($cb - $blue) <= $mindiff, $comment)) {
+ $builder->diag(<<END_DIAG);
+Color mismatch:
+ Red: $cr vs $red
+Green: $cg vs $green
+ Blue: $cb vs $blue