svg_dropshadow revision 6b15695578f07a3f72c4c9475c1a261a3021472a
#
# svg_dropshadow
#
# Creates drop shadows for all svg elements specified by --id, or
# whole file if no ids are given.
#
# Authors: Daniel Goude (goude@dtek.chalmers.se)
#
use strict;
use warnings;
use SpSVG;
# Set the script name, used when displaying --help
# Set usage string (options are handled separately).
my $usage = <<EOF;
Creates drop shadows from svg group(s)
EOF
# Set script specific options and description (used for --help)
my @opt_vals = (
{
"opt" => "color=s",
"desc" => "Shadow color (default black)",
},
{
"opt" => "opacity=s",
"desc" => "Shadow offset (0-1, default 0.5)",
},
{
"opt" => "offset=s",
"desc" => "Shadow offset, default 10",
},
);
# Read input file (from --file or STDIN)
# Apply make_shadow to selected ids, or whole file
# Dump the file (to --output or STDOUT)
# That's it!
# make_shadow takes an svg fragment and returns named fragment
# with a shadow added
sub make_shadow {
my $element = shift;
# Duplicate element
# Set shadow color
my $svg = <<EOF;
<svg:g id="fooz" style="opacity:$opacity;" transform="translate($offset,
$offset)">
$shadow
</svg:g>
$element
EOF
return $svg;
}