generate_voronoi.py revision f1a3257bc5556c5b1f95ec2c6906f1309a390b2a
"""
Copyright (C) 2010 Alvin Penner, penner@vaxxine.com
- Voronoi Diagram algorithm and C code by Steven Fortune, 1987, http://ect.bell-labs.com/who/sjf/
- Python translation to file voronoi.py by Bill Simons, 2005, http://www.oxfish.com/
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
"""
try:
except:
inkex.errormsg(_("Failed to import the subprocess module. Please report this as a bug at : https://bugs.launchpad.net/inkscape."))
exit()
return [0, 0, 0, 0]
return [0, 0, 0, 0]
if x1 < 0:
x1 = 0
if x2 < 0:
x2 = 0
if x1 > w:
x1 = w
if x2 > w:
x2 = w
return [0, 0, 0, 0]
return [0, 0, 0, 0]
return [0, 0, 0, 0]
if y1 < 0:
y1 = 0
if y2 < 0:
y2 = 0
if y1 > h:
y1 = h
if y2 > h:
y2 = h
help="Average size of cell (px)")
help="Size of Border (px)")
dest="tab",
help="The selected UI-tab when OK was pressed")
exit()
q = {'x':0,'y':0,'width':0,'height':0} # query the bounding box of ids[0]
p = Popen('inkscape --query-%s --query-id=%s "%s"' % (query, self.options.ids[0], self.args[-1]), shell=True, stdout=PIPE, stderr=PIPE)
# generate random pattern of points
pts = []
if b > 0: # duplicate border area
if x < b:
if y < b:
if y > q['height'] - b:
if x > q['width'] - b:
if y < b:
if y > q['height'] - b:
if y < b:
if y > q['height'] - b:
elif x > -b and y > -b and x < q['width'] + b and y < q['height'] + b:
# dot = inkex.etree.SubElement(pattern, inkex.addNS('rect','svg'))
# dot.set('x', str(x-1))
# dot.set('y', str(y-1))
# dot.set('width', '2')
# dot.set('height', '2')
exit()
# plot Voronoi diagram
path = ""
[x1, y1, x2, y2] = clip_line(c.vertices[edge[1]][0], c.vertices[edge[1]][1], c.vertices[edge[2]][0], c.vertices[edge[2]][1], q['width'], q['height'])
ytemp = q['height']
else:
ytemp = 0
else:
xtemp = q['width']
[x1, y1, x2, y2] = clip_line(c.vertices[edge[1]][0], c.vertices[edge[1]][1], xtemp, ytemp, q['width'], q['height'])
ytemp = q['height']
else:
ytemp = 0
else:
xtemp = 0
[x1, y1, x2, y2] = clip_line(xtemp, ytemp, c.vertices[edge[2]][0], c.vertices[edge[2]][1], q['width'], q['height'])
# link selected object to pattern
style = {}
style = {}
if __name__ == '__main__':
e = Pattern()
e.affect()
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99