summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorAurelio A. Heckert (a) <auriumgmaildotcom>2010-03-01 15:43:26 +0000
committerAurelio A. Heckert (a) <auriumgmaildotcom>2010-03-01 15:43:26 +0000
commit00fa0e314afbf56034a753ed6ab41a456d37c2e0 (patch)
treee1b8d112287b89d1b7d7fd3fd78fe359a3f278f8 /share
parentRemove obsolete C macro use. (diff)
downloadinkscape-00fa0e314afbf56034a753ed6ab41a456d37c2e0.tar.gz
inkscape-00fa0e314afbf56034a753ed6ab41a456d37c2e0.zip
Starting a (useful) derivation of http://colivre.coop.br/Aurium/InkscapeAreaCuter called Slicer
webslicer-* will define cut areas and help HTML+CSS coding. (bzr r9126)
Diffstat (limited to 'share')
-rw-r--r--share/extensions/webslicer-create-group.inx31
-rwxr-xr-xshare/extensions/webslicer-create-group.py75
-rw-r--r--share/extensions/webslicer-create-rect.inx66
-rwxr-xr-xshare/extensions/webslicer-create-rect.py124
-rw-r--r--share/extensions/webslicer-export.inx21
-rwxr-xr-xshare/extensions/webslicer-export.py58
6 files changed, 375 insertions, 0 deletions
diff --git a/share/extensions/webslicer-create-group.inx b/share/extensions/webslicer-create-group.inx
new file mode 100644
index 000000000..683795213
--- /dev/null
+++ b/share/extensions/webslicer-create-group.inx
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Set a layout group</_name>
+ <id>org.inkscape.web.slicer.create-group</id>
+ <dependency type="executable" location="extensions">webslicer-create-group.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <_param name="about" type="description">Layout Group is only about to help a better code generation (if you need it). To use this, first you must to select some "Slicer rectangles".</_param>
+ <param name="html-id" type="string" _gui-text="HTML id atribute"></param>
+ <param name="html-class" type="string" _gui-text="HTML class atribute"></param>
+ <param name="width-unity" type="enum" _gui-text="Width Unity">
+ <_item value="px">Pixel (fixed)</_item>
+ <_item value="percent">Percent (relative to parent size)</_item>
+ <_item value="undefined">Undefined (relative to non-floating content size)</_item>
+ </param>
+ <param name="height-unity" type="enum" _gui-text="Height Unity">
+ <_item value="px">Pixel (fixed)</_item>
+ <_item value="percent">Percent (relative to parent size)</_item>
+ <_item value="undefined">Undefined (relative to non-floating content size)</_item>
+ </param>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Web">
+ <submenu name="Slicer"/>
+ </submenu>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">webslicer-create-group.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/webslicer-create-group.py b/share/extensions/webslicer-create-group.py
new file mode 100755
index 000000000..3c44b2cb4
--- /dev/null
+++ b/share/extensions/webslicer-create-group.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2010 Aurelio A. Heckert, aurium (a) gmail dot com
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+'''
+
+import inkex
+import gettext
+
+_ = gettext.gettext
+
+def is_empty(val):
+ if val is None:
+ return True
+ else:
+ return len(str(val)) == 0
+
+class WebSlicer_CreateGroup(inkex.Effect):
+
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ self.OptionParser.add_option("--html-id",
+ action="store", type="string",
+ dest="html_id",
+ help="")
+ self.OptionParser.add_option("--html-class",
+ action="store", type="string",
+ dest="html_class",
+ help="")
+ self.OptionParser.add_option("--width-unity",
+ action="store", type="string",
+ dest="width_unity",
+ help="")
+ self.OptionParser.add_option("--height-unity",
+ action="store", type="string",
+ dest="height_unity",
+ help="")
+
+ def effect(self):
+ if len(self.selected) == 0:
+ inkex.errormsg(_('You must to select some "Slicer rectangles".'))
+ return
+ layer = self.document.xpath(
+ '//*[@id="webslicer-layer" and @inkscape:groupmode="layer"]',
+ namespaces=inkex.NSS)[0]
+ group = inkex.etree.SubElement(layer, 'g')
+ desc = inkex.etree.SubElement(group, 'desc')
+ conf_txt = ''
+ if not is_empty(self.options.html_id):
+ conf_txt += 'html-id:' + self.options.html_class +'\n'
+ if not is_empty(self.options.html_class):
+ conf_txt += 'html-class:' + self.options.html_class +'\n'
+ conf_txt += 'width-unity:' + self.options.width_unity +'\n'
+ conf_txt += 'height-unity:' + self.options.height_unity
+ desc.text = conf_txt
+ for id,node in self.selected.iteritems():
+ group.insert( 1, node )
+
+
+if __name__ == '__main__':
+ e = WebSlicer_CreateGroup()
+ e.affect()
diff --git a/share/extensions/webslicer-create-rect.inx b/share/extensions/webslicer-create-rect.inx
new file mode 100644
index 000000000..2a41ff4d8
--- /dev/null
+++ b/share/extensions/webslicer-create-rect.inx
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Create a slicer rectangle</_name>
+ <id>org.inkscape.web.slicer.create-rect</id>
+ <dependency type="executable" location="extensions">webslicer-create-rect.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="name" type="string" _gui-text="Name"></param>
+ <param name="format" type="enum" _gui-text="Format">
+ <item value="png">PNG</item>
+ <item value="jpg">JPG</item>
+ <item value="gif">GIF</item>
+ </param>
+ <param name="dpi" type="float" min="1" max="9999" _gui-text="DPI">90</param>
+ <param name="dimension" type="string" _gui-text="Force Dimension"></param>
+ <_param name="help-dimension1" type="description">Force Dimension must be set as "&lt;width&gt;x&lt;height&gt;"</_param>
+ <_param name="help-dimension2" type="description">If had set, this will replace DPI.</_param>
+ <param name="bg-color" type="string" _gui-text="Background color"></param>
+ <param name="tab" type="notebook">
+ <page name="tabJPG" gui-text="JPG">
+ <_param name="help-jpg" type="description">JPG specific options</_param>
+ <param name="quality" type="int" min="0" max="100" _gui-text="Quality">85</param>
+ <_param name="help-quality" type="description">0 is the lowest image quality and highest compression, and 100 is the best quality but least effective compression</_param>
+ </page>
+ <page name="tabGIF" gui-text="GIF">
+ <_param name="help-gif" type="description">GIF specific options</_param>
+ <param name="gif-type" type="enum" _gui-text="Type">
+ <_item value="grayscale">Grayscale</_item>
+ <_item value="palette">Palette</_item>
+ </param>
+ <param name="palette-size" type="int" min="2" max="256" _gui-text="Palette size">256</param>
+ </page>
+ <page name="tabHTML" gui-text="HTML">
+ <param name="html-id" type="string" _gui-text="HTML id atribute"></param>
+ <param name="html-class" type="string" _gui-text="HTML class atribute"></param>
+ <_param name="help-gif" type="description">Options for HTML export</_param>
+ <param name="layout-disposition" type="enum" _gui-text="Layout disposition">
+ <_item value="bg-parent-repeat">Tiled Background (on parent group)</_item>
+ <_item value="bg-parent-repeat-x">Background — repeat horizontally (on parent group)</_item>
+ <_item value="bg-parent-repeat-y">Background — repeat vertically (on parent group)</_item>
+ <_item value="bg-parent-norepeat">Background — no repeat (on parent group)</_item>
+ <_item value="bg-div-norepeat">Positioned &lt;div&gt; width the image as Background</_item>
+ <_item value="img-pos">Positioned Image</_item>
+ <_item value="img-nonpos">Non Positioned Image</_item>
+ <_item value="img-float-left">Left Floated Image</_item>
+ <_item value="img-float-right">Right Floated Image</_item>
+ </param>
+ <param name="layout-position-anchor" type="enum" _gui-text="Position anchor">
+ <_item value="tl">Top and Left</_item>
+ <_item value="tr">Top and right</_item>
+ <_item value="bl">Bottom and Left</_item>
+ <_item value="br">Bottom and Right</_item>
+ </param>
+ </page>
+ </param>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Web">
+ <submenu name="Slicer"/>
+ </submenu>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">webslicer-create-rect.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/webslicer-create-rect.py b/share/extensions/webslicer-create-rect.py
new file mode 100755
index 000000000..2c495e7af
--- /dev/null
+++ b/share/extensions/webslicer-create-rect.py
@@ -0,0 +1,124 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2010 Aurelio A. Heckert, aurium (a) gmail dot com
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+'''
+
+import inkex
+import gettext
+
+_ = gettext.gettext
+
+def is_empty(val):
+ if val is None:
+ return True
+ else:
+ return len(str(val)) == 0
+
+class WebSlicer_CreateRect(inkex.Effect):
+
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ self.OptionParser.add_option("--name",
+ action="store", type="string",
+ dest="name",
+ help="")
+ self.OptionParser.add_option("--format",
+ action="store", type="string",
+ dest="format",
+ help="")
+ self.OptionParser.add_option("--dpi",
+ action="store", type="int",
+ dest="dpi",
+ help="")
+ self.OptionParser.add_option("--dimension",
+ action="store", type="string",
+ dest="dimension",
+ help="")
+ self.OptionParser.add_option("--bg-color",
+ action="store", type="string",
+ dest="bg_color",
+ help="")
+ self.OptionParser.add_option("--quality",
+ action="store", type="int",
+ dest="quality",
+ help="")
+ self.OptionParser.add_option("--gif-type",
+ action="store", type="string",
+ dest="gif_type",
+ help="")
+ self.OptionParser.add_option("--palette-size",
+ action="store", type="int",
+ dest="palette_size",
+ help="")
+ self.OptionParser.add_option("--html-id",
+ action="store", type="string",
+ dest="html_id",
+ help="")
+ self.OptionParser.add_option("--html-class",
+ action="store", type="string",
+ dest="html_class",
+ help="")
+ self.OptionParser.add_option("--layout-disposition",
+ action="store", type="string",
+ dest="layout_disposition",
+ help="")
+ self.OptionParser.add_option("--layout-position-anchor",
+ action="store", type="string",
+ dest="layout_position_anchor",
+ help="")
+ # inkscape param workarround
+ self.OptionParser.add_option("--tab")
+
+ def effect(self):
+ layer = self.get_slicer_layer()
+ #TODO: get selected elements to define location and size
+ rect = inkex.etree.SubElement(layer, 'rect')
+ if is_empty(self.options.name):
+ self.options.name = 'rect0001'
+ rect.set('id', self.options.name)
+ rect.set('fill', 'red')
+ rect.set('opacity', '0.5')
+ rect.set('x', '-100')
+ rect.set('y', '-100')
+ rect.set('width', '200')
+ rect.set('height', '200')
+ desc = inkex.etree.SubElement(rect, 'desc')
+ conf_txt = "format:"+ self.options.format +"\n"
+ if not is_empty(self.options.dpi):
+ conf_txt += "dpi:" + str(self.options.dpi) +"\n"
+ if not is_empty(self.options.html_id):
+ conf_txt += "html-id:" + self.options.html_id
+ desc.text = conf_txt
+
+ def get_slicer_layer(self):
+ # Test if webslicer-layer layer existis
+ layer = self.document.xpath(
+ '//*[@id="webslicer-layer" and @inkscape:groupmode="layer"]',
+ namespaces=inkex.NSS)
+ if len(layer) is 0:
+ # Create a new layer
+ layer = inkex.etree.SubElement(self.document.getroot(), 'g')
+ layer.set('id', 'webslicer-layer')
+ layer.set(inkex.addNS('label', 'inkscape'), 'Web Slicer')
+ layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer')
+ else:
+ layer = layer[0]
+ return layer
+
+if __name__ == '__main__':
+ e = WebSlicer_CreateRect()
+ e.affect()
diff --git a/share/extensions/webslicer-export.inx b/share/extensions/webslicer-export.inx
new file mode 100644
index 000000000..06863ece5
--- /dev/null
+++ b/share/extensions/webslicer-export.inx
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Export layout pieces and HTML+CSS code</_name>
+ <id>org.inkscape.web.slicer.export</id>
+ <dependency type="executable" location="extensions">webslicer-export.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <_param name="about" type="description">All sliced images, and optionaly code, will be generated as you had configured and saved to one directory.</_param>
+ <param name="dir" type="string" _gui-text="Directory path to export"></param>
+ <param name="with-code" type="boolean" _gui-text="With HTML and CSS">true</param>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Web">
+ <submenu name="Slicer"/>
+ </submenu>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">webslicer-export.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/webslicer-export.py b/share/extensions/webslicer-export.py
new file mode 100755
index 000000000..c8e4cbb0d
--- /dev/null
+++ b/share/extensions/webslicer-export.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2010 Aurelio A. Heckert, aurium (a) gmail dot com
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+'''
+
+import inkex
+import gettext
+import os.path
+import commands
+
+_ = gettext.gettext
+
+def is_empty(val):
+ if val is None:
+ return True
+ else:
+ return len(str(val)) == 0
+
+class WebSlicer_Export(inkex.Effect):
+
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ self.OptionParser.add_option("--with-code",
+ action="store", type="string",
+ dest="with_code",
+ help="")
+ self.OptionParser.add_option("--dir",
+ action="store", type="string",
+ dest="dir",
+ help="")
+
+ def effect(self):
+ if is_empty( self.options.dir ):
+ inkex.errormsg(_('You must to give a directory to export the slices.'))
+ return
+ if not os.path.exists( self.options.dir ):
+ inkex.errormsg(_('The directory "%s" does not exists.') % self.options.dir)
+ return
+ (status, output) = commands.getstatusoutput("inkscape -e ...")
+
+
+if __name__ == '__main__':
+ e = WebSlicer_Export()
+ e.affect()