Inkscape.pm revision b93ce4197e7f5026a1c8deeb79cbd00aa3f86d91
use strict;
use warnings;
=head1 NAME
Inkscape - a helper for Inkscape extensions writen in PERL
=head1 SYNOPSIS
use Inkscape;
my ($w, $h) = $inkscape->getCanvasSize;
$svg->setElAttribute {tag=>'svg',pos=>0}, 'width', $w * 2;
=head1 DESCRIPTION
This package try to do the common initial work in inkscape extensions
and provide a collection of helper methods about inkscape interaction
and SVG basic manipulation.
If you want more power to SVG manipulation, try use SVG::DOM together.
=cut
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Inkscape Package #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{
package Inkscape;
our $VERSION = "0.01";
=head2 The %args hash
The B<%args> hash gives to you all arguments provided by Inkscape.
$svg->setElAttribute 'svg', 'width', $w * $args{zoom};
The B<id> will allways be an array reference. Also if it is empty.
=cut
#use vars qw($VERSION $inkscape %args @ISA @EXPORT %EXPORT_TAGS $TODO);
#require Exporter;
#@ISA = qw(Exporter);
#my $inkscape = Inkscape->new;
#@EXPORT = qw( $inkscape );
sub import {
if ( defined $_[1] && $_[1] eq 'AUTO_LOAD' ) {
#$inkscape->getArgs(@ARGV);
if ( $#ARGV > -1 && -f $ARGV[$#ARGV] ) {
#$inkscape->getSVG($ARGV[$#ARGV]);
}
}
}
sub getArgs {
my $self = shift;
my @argv = @_;
foreach ( @argv ) {
if ( m/^--([^=]+)=(.*)$/ ) {
my $key = $1;
my $val = $2;
}
} else {
}
}
}
%args;
}
sub getSVG{
my $self = shift;
my $file = shift;
}
=head2 Inkscape Methods
The $inkscape auto defined object is a helper to use non interactive
inkscape interface. You allways need to provide an SVG file path to
the methods.
=cut
my $singleton;
sub new {
my $class = shift;
my $self = {};
#$self->{args} = ( id => [] );
}
} # end package Inkscape
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# SVG Package #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
{
package SVGHelper;
our $VERSION = "0.01";
=head2 SVGHelper Methods
The $svg auto defined object is a helper to access the SVG file provided
by the Inkscape. That is not a singleton, so if you want manipulate other
SVG files, you can instanciate a new SVGHelper.
=head3 new
Instantiates SVGHelper with a SVG file.
=cut
sub new {
my $self = {};
close SVG;
}
print "Yes! there are Hot elements!"
B<{id}> = "<some tag id>"
B<{pos}> = <number>
B<{tag}> = "<tag_name>"
=cut
sub generateSearchRegExp {
# '.*' in a value will break all. we must change '.' by '[^"]'
}
# Setting an attribute in a tag localizated it's id:
# Setting an attribute in a tag localizated it's position:
# Setting an attribute in some tags localizated by attributes:
=cut
sub setElAttribute {
my $self = shift;
}
sub convertUnit {
my $self = shift;
$_[0] =~ m/^([.0-9]*)\s*([^ ]*)/;
my $num = $1;
my $unTo = $_[1];
my $appendUnit = $_[2];
# From http://www.w3.org/TR/SVG/coords.html#Units
# "1pt" equals "1.25px" (and therefore 1.25 user units)
# "1pc" equals "15px" (and therefore 15 user units)
# "1mm" would be "3.543307px" (3.543307 user units)
# "1cm" equals "35.43307px" (and therefore 35.43307 user units)
# "1in" equals "90px" (and therefore 90 user units)
my %equivPX = (
px => 1,
pt => 1.25,
pc => 15,
mm => 3.543307,
cm => 35.43307,
in => 90
);
}
my ($w, $h) = $svg->getCanvasSize;
=cut
sub getCanvasSize {
my $self = shift;
my $unitTo = $_[0];
my ( $w, $h ) =
( $unitTo ) ?
( $1, $2 );
}
sub getElPosition {
my $self = shift;
return ( $x )? ( $x, $y ) : undef;
}
sub getElSize {
my $self = shift;
return ( $w )? ( $w, $h ) : undef;
}
} # end package SVGHelper
=head1 AUTHOR
Aurelio A. Heckert <aurium@gmail.com>
=head1 COPYRIGHT
Copyright (C) 2008 Aurelio A. Heckert <aurium@gmail.com>
This PERL module is a free software licenced under LGPL v3
=cut
1;