SVG-SpriteMaker

 view release on metacpan or  search on metacpan

lib/SVG/SpriteMaker.pm  view on Meta::CPAN

			$nid .= '_' while $ids{$nid};
			$svg->getElementByID($oid)->attr(id => $nid);
			for my $elem (@all_elems) {
				my %attribs = %{$elem->getAttributes};
				for my $key (keys %attribs) {
					if ($attribs{$key} =~ /#$oid\b/) {
						$attribs{$key} =~ s/#$oid\b/#$nid/g;
						$elem->attr($key => $attribs{$key});
					}
				}
				if ($elem->cdata =~ /#$oid\b/) {
					$elem->cdata($elem->cdata =~ s/#$oid\b/#$nid/gr);
				}
			}
		}

		$view->getParent->insertAfter($svg, $view);
	}

	# Keep a reference to the documents to prevent garbage collection
	$sprite->{'--images'} = \@images;
	$sprite->getFirstChild->attr(viewBox => "0 0 $x $mh");

lib/SVG/SpriteMaker.pm  view on Meta::CPAN


  sub {
    my $base = scalar fileparse $_[0], qr/\..*/s;
    "$prefix-$base"
  };

where I<$prefix> is the value of the first argument.

If an ID is shared between two or more input files, this module will
try to rename each occurence except for the first one. This operation
might have false positives (attributes/cdatas that are mistakenly
identified to contain the ID-to-be-renamed) and false negatives
(attributes/cdatas that actually contain the ID-to-be-renamed but this
is missed by the module), and as such SVG::SpriteMaker will warn if
duplicate IDs are detected. You can suppress this warning by setting
the C<SVG_SPRITEMAKER_NO_DUPLICATE_WARNINGS> environment variable to a
true value.

=head1 SEE ALSO

L<svg-spritemaker>, L<https://css-tricks.com/svg-fragment-identifiers-work/>

=head1 AUTHOR

svg-spritemaker  view on Meta::CPAN

=item B<-p> I<prefix>, B<--prefix>=I<prefix>

Sets the prefix for the fragment identifiers. Default is C<sprite>
(which results in identifiers C<sprite-a>, C<sprite-b> for the first
example in the SYNOPSIS).

=back

If an ID is shared between two or more input files, this program will
try to rename each occurence except for the first one. This operation
might have false positives (attributes/cdatas that are mistakenly
identified to contain the ID-to-be-renamed) and false negatives
(attributes/cdatas that actually contain the ID-to-be-renamed but this
is missed by the module), and as such svg-spritemaker will warn if
duplicate IDs are detected. You can suppress this warning by setting
the C<SVG_SPRITEMAKER_NO_DUPLICATE_WARNINGS> environment variable to a
true value.

=head1 SEE ALSO

L<SVG::SpriteMaker>, L<https://css-tricks.com/svg-fragment-identifiers-work/>

=head1 AUTHOR



( run in 0.250 second using v1.01-cache-2.11-cpan-454fe037f31 )