summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurélio A. Heckert (a) <auriumgmaildotcom>2010-04-26 04:45:48 +0000
committerAurélio A. Heckert (a) <auriumgmaildotcom>2010-04-26 04:45:48 +0000
commitb1db6a5c2ff1bc56d11afff0f1688a09af5b89e2 (patch)
tree4150b1ecf033176c8c83a1c82f1783c64569b9cb
parentadd 'area' calculation to Measure extension (diff)
downloadinkscape-b1db6a5c2ff1bc56d11afff0f1688a09af5b89e2.tar.gz
inkscape-b1db6a5c2ff1bc56d11afff0f1688a09af5b89e2.zip
webslicer is starting to export image pieces
(bzr r9375)
-rw-r--r--share/extensions/webslicer_create_group.inx1
-rw-r--r--share/extensions/webslicer_create_group.py17
-rw-r--r--share/extensions/webslicer_create_rect.inx7
-rwxr-xr-xshare/extensions/webslicer_create_rect.py24
-rw-r--r--share/extensions/webslicer_effect.py9
-rwxr-xr-xshare/extensions/webslicer_export.py23
6 files changed, 54 insertions, 27 deletions
diff --git a/share/extensions/webslicer_create_group.inx b/share/extensions/webslicer_create_group.inx
index 68f63ce72..e4bf4e310 100644
--- a/share/extensions/webslicer_create_group.inx
+++ b/share/extensions/webslicer_create_group.inx
@@ -18,6 +18,7 @@
<_item value="percent">Percent (relative to parent size)</_item>
<_item value="undefined">Undefined (relative to non-floating content size)</_item>
</param>
+ <param name="bg-color" type="string" _gui-text="Background color:"></param>
<effect needs-live-preview="false">
<object-type>all</object-type>
<effects-menu>
diff --git a/share/extensions/webslicer_create_group.py b/share/extensions/webslicer_create_group.py
index 666649bfb..c6f9e653e 100644
--- a/share/extensions/webslicer_create_group.py
+++ b/share/extensions/webslicer_create_group.py
@@ -43,6 +43,10 @@ class WebSlicer_CreateGroup(WebSlicer_Effect):
action="store", type="string",
dest="height_unity",
help="")
+ self.OptionParser.add_option("--bg-color",
+ action="store", type="string",
+ dest="bg_color",
+ help="")
def get_base_elements(self):
@@ -72,14 +76,11 @@ class WebSlicer_CreateGroup(WebSlicer_Effect):
g_parent = self.getParentNode(node)
group = inkex.etree.SubElement(g_parent, 'g')
desc = inkex.etree.SubElement(group, 'desc')
- conf_txt = ''
- if not is_empty(self.options.html_id):
- conf_txt += 'html-id:' + self.options.html_id +'\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
+ desc.text = self.get_conf_text_from_list(
+ [ 'html_id', 'html_class',
+ 'width_unity', 'height_unity',
+ 'bg_color' ] )
+
for id,node in self.selected.iteritems():
group.insert( 1, node )
diff --git a/share/extensions/webslicer_create_rect.inx b/share/extensions/webslicer_create_rect.inx
index 7490953c5..651dda668 100644
--- a/share/extensions/webslicer_create_rect.inx
+++ b/share/extensions/webslicer_create_rect.inx
@@ -35,11 +35,11 @@
<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-el-norepeat">Positioned html block element with the image as Background</_item>
<_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; with 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>
@@ -47,8 +47,13 @@
</param>
<param name="layout-position-anchor" type="enum" _gui-text="Position anchor:">
<_item value="tl">Top and Left</_item>
+ <_item value="tc">Top and Center</_item>
<_item value="tr">Top and right</_item>
+ <_item value="ml">Middle and Left</_item>
+ <_item value="mc">Middle and Center</_item>
+ <_item value="mr">Middle and Right</_item>
<_item value="bl">Bottom and Left</_item>
+ <_item value="bc">Bottom and Center</_item>
<_item value="br">Bottom and Right</_item>
</param>
</page>
diff --git a/share/extensions/webslicer_create_rect.py b/share/extensions/webslicer_create_rect.py
index 5fd961a13..9e916532f 100755
--- a/share/extensions/webslicer_create_rect.py
+++ b/share/extensions/webslicer_create_rect.py
@@ -121,30 +121,20 @@ class WebSlicer_CreateRect(WebSlicer_Effect):
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 = "\n".join( self.get_full_conf_list() )
+ desc.text = self.get_conf_text_from_list( self.get_conf_list() )
-
- def get_conf_from_list(self, conf_atts):
- conf_list = []
- for att in conf_atts:
- if not is_empty(getattr(self.options, att)):
- conf_list.append( att +':'+ str(getattr(self.options, att)) )
- return conf_list
-
-
- def get_full_conf_list(self):
- conf_list = [ 'format:'+self.options.format ]
+ def get_conf_list(self):
+ conf_list = [ 'format' ]
if self.options.format == 'gif':
- conf_list.extend( self.get_conf_from_list([ 'gif_type', 'palette_size' ]) )
+ conf_list.extend( [ 'gif_type', 'palette_size' ] )
if self.options.format == 'jpg':
- conf_list.extend( self.get_conf_from_list([ 'quality' ]) )
- conf_general_atts = [
+ conf_list.extend( [ 'quality' ] )
+ conf_list.extend( [
'dpi', 'dimension',
'bg_color', 'html_id', 'html_class',
'layout_disposition', 'layout_position_anchor'
- ]
- conf_list.extend( self.get_conf_from_list(conf_general_atts) )
+ ] )
return conf_list
diff --git a/share/extensions/webslicer_effect.py b/share/extensions/webslicer_effect.py
index 37bea447b..d91d0ce85 100644
--- a/share/extensions/webslicer_effect.py
+++ b/share/extensions/webslicer_effect.py
@@ -50,3 +50,12 @@ class WebSlicer_Effect(inkex.Effect):
layer = layer[0]
return layer
+ def get_conf_text_from_list(self, conf_atts):
+ conf_list = []
+ for att in conf_atts:
+ if not is_empty(getattr(self.options, att)):
+ conf_list.append(
+ att.replace('_','-') +': '+ str(getattr(self.options, att))
+ )
+ return "\n".join( conf_list )
+
diff --git a/share/extensions/webslicer_export.py b/share/extensions/webslicer_export.py
index 3a1a38135..02d049364 100755
--- a/share/extensions/webslicer_export.py
+++ b/share/extensions/webslicer_export.py
@@ -21,6 +21,7 @@ from webslicer_effect import *
import inkex
import gettext
import os.path
+import tempfile
import commands
_ = gettext.gettext
@@ -76,13 +77,27 @@ class WebSlicer_Export(WebSlicer_Effect):
inkex.errormsg( _('Can\'t create code files.') )
inkex.errormsg( _('Error: %s') % e )
return {'error':'Can\'t create code files.'}
+ # Create the temporary SVG with invisible Slicer layer to export image pieces
+ self.create_the_temporary_svg()
# Start what we really want!
self.export_chids_of( self.get_slicer_layer() )
# Close the HTML and CSS files:
if self.options.with_code:
self.html.close()
self.css.close()
+ # Delete the temporary SVG with invisible Slicer layer
+ self.delete_the_temporary_svg()
+ def create_the_temporary_svg(self):
+ (ref, self.tmp_svg) = tempfile.mkstemp('.svg')
+ layer = self.get_slicer_layer()
+ current_style = layer.attrib['style']
+ layer.attrib['style'] = 'display:none'
+ self.document.write( self.tmp_svg );
+ layer.attrib['style'] = current_style
+
+ def delete_the_temporary_svg(self):
+ os.remove( self.tmp_svg )
def get_el_conf(self, el):
desc = el.find('{http://www.w3.org/2000/svg}desc')
@@ -129,7 +144,13 @@ class WebSlicer_Export(WebSlicer_Effect):
def export_img(self, el, conf):
- (status, output) = commands.getstatusoutput("inkscape -e ...")
+ (status, output) = commands.getstatusoutput(
+ "inkscape -i '%s' -e '%s' '%s'" % (
+ el.attrib['id'],
+ os.path.join( self.options.dir, el.attrib['id']+'.png' ),
+ self.tmp_svg
+ )
+ )
#inkex.errormsg( status )
#inkex.errormsg( output )