fix in convex hull
This commit is contained in:
parent
632b62b481
commit
edc8313bbf
@ -76,9 +76,10 @@ class ConvexHull(inkex.EffectExtension):
|
|||||||
etree.SubElement(g, inkex.addNS('path', 'svg' ), line_attribs)
|
etree.SubElement(g, inkex.addNS('path', 'svg' ), line_attribs)
|
||||||
|
|
||||||
def effect(self):
|
def effect(self):
|
||||||
global output_nodes, points
|
|
||||||
#Loop through all the selected items in Inkscape
|
if len(self.svg.selected) > 0:
|
||||||
for node in self.svg.selected.values():
|
global output_nodes, points
|
||||||
|
|
||||||
#create numpy array of nodes
|
#create numpy array of nodes
|
||||||
n_array = []
|
n_array = []
|
||||||
|
|
||||||
@ -98,22 +99,26 @@ class ConvexHull(inkex.EffectExtension):
|
|||||||
n_array.append(csp[1][0])
|
n_array.append(csp[1][0])
|
||||||
n_array.append(csp[1][1])
|
n_array.append(csp[1][1])
|
||||||
|
|
||||||
k = n.asarray(n_array)
|
k = n.asarray(n_array)
|
||||||
length = int(len(k)/2)
|
length = int(len(k)/2)
|
||||||
c = k.reshape(length,2)
|
c = k.reshape(length,2)
|
||||||
hull_pts = qhull(c)
|
hull_pts = qhull(c)
|
||||||
|
|
||||||
pdata = ''
|
pdata = ''
|
||||||
for vertex in hull_pts:
|
for vertex in hull_pts:
|
||||||
if pdata == '':
|
if pdata == '':
|
||||||
pdata = 'M%f,%f' % (vertex[0], vertex[1] )
|
pdata = 'M%f,%f' % (vertex[0], vertex[1] )
|
||||||
else:
|
else:
|
||||||
pdata += 'L %f,%f' % (vertex[0], vertex[1] )
|
pdata += 'L %f,%f' % (vertex[0], vertex[1] )
|
||||||
pdata += ' Z'
|
pdata += ' Z'
|
||||||
path = 'polygon'
|
path = 'polygon'
|
||||||
makeGroup = False
|
makeGroup = False
|
||||||
paths_clone_transform = None
|
paths_clone_transform = None
|
||||||
self.joinWithNode(path, pdata, makeGroup, paths_clone_transform )
|
self.joinWithNode(path, pdata, makeGroup, paths_clone_transform)
|
||||||
|
|
||||||
|
else:
|
||||||
|
inkex.errormsg('Please select some paths first.')
|
||||||
|
return
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
ConvexHull().run()
|
ConvexHull().run()
|
Reference in New Issue
Block a user