added transform fix into imagetracer.js
This commit is contained in:
parent
d9dfc3323b
commit
029169eb21
@ -1,60 +0,0 @@
|
|||||||
Entering TransformPaths
|
|
||||||
Shape 0 id:path1141 Stroke[1 000000] width:0.264583
|
|
||||||
Shape 1 id:path1141-8 Stroke[1 000000] width:0.264583
|
|
||||||
Shape 2 id:path1141-9 Stroke[1 000000] width:0.264583
|
|
||||||
Shape 3 id:path1141-0 Stroke[1 000000] width:0.264583
|
|
||||||
Transform paths pass 2 : checking if paths are included in other ones
|
|
||||||
End of Transform paths
|
|
||||||
---------------- Entering EnlargePaths, elapsed time: 3ms
|
|
||||||
---------------- Exit EnlargePaths, elapsed time: 3ms
|
|
||||||
|
|
||||||
|
|
||||||
---------------- Entering BreakLongerEdges, elapsed time: 3ms
|
|
||||||
---------------- Exit BreakLongerEdges, elapsed time: 3ms
|
|
||||||
|
|
||||||
|
|
||||||
-------- BuilSingleListPath : There are 4 paths in the list
|
|
||||||
Path 0 id: path1141-8_0 area 2004.46mm2 and 0 children
|
|
||||||
Path 1 id: path1141-9_0 area 2004.46mm2 and 0 children
|
|
||||||
Path 2 id: path1141_0 area 2004.46mm2 and 0 children
|
|
||||||
Path 3 id: path1141-0_0 area 2004.46mm2 and 0 children
|
|
||||||
----------- End of BuilSingleListPath ---------------------------
|
|
||||||
|
|
||||||
|
|
||||||
Time: 3.000000ms Enter Optimize with Optimizing level set to 5
|
|
||||||
----- Placing first polygon (path1141-8_0) -----------
|
|
||||||
Entering PlaceFirst...
|
|
||||||
First polygon placed with rotation 0.000000° and translation (3.280817,0.000000)
|
|
||||||
-------------------- Placing Polygon (Free rotation)1: path1141-9_0 ------------------------------
|
|
||||||
Elapsed time 0.000000ms, for last polygon 0.000000ms
|
|
||||||
Level 1: Applying best move : (-97.181078,-42.337603)/180.000000° to polygon 3 will place vertex 2 on vertex 1 of polygon 2
|
|
||||||
new hull with 5 vertices, area 8034.754228 Fixed polygon area 8017.823036
|
|
||||||
LargeConvexHull area :8034.754228 Cost= 8034.754228
|
|
||||||
CurFloating.Size=0
|
|
||||||
Level 2: Applying best move : (1.434374,-9.167470)/0.000000° to polygon 2 will place vertex 3 on vertex 0 of polygon 1
|
|
||||||
new hull with 6 vertices, area 6021.832982 Fixed polygon area 6013.367409
|
|
||||||
LargeConvexHull area :6021.832982 Cost= 8034.754228
|
|
||||||
CurFloating.Size=1
|
|
||||||
Element 1: Translation=(-97.181078,-42.337603) rot=180.000000 Hull area=8034.754228
|
|
||||||
Level 3: Applying best move : (-102.821809,-27.175084)/180.000000° to polygon 1 will place vertex 2 on vertex 1 of polygon 0
|
|
||||||
new hull with 4 vertices, area 4017.377123 Fixed polygon area 4008.911749
|
|
||||||
LargeConvexHull area :4017.377123 Cost= 8034.754228
|
|
||||||
CurFloating.Size=2
|
|
||||||
Element 1: Translation=(1.434374,-9.167470) rot=0.000000 Hull area=6021.832982
|
|
||||||
Element 2: Translation=(-97.181078,-42.337603) rot=180.000000 Hull area=8034.754228
|
|
||||||
-------------------- Placing Polygon (Free rotation)2: path1141_0 ------------------------------
|
|
||||||
Elapsed time 2.000000ms, for last polygon 2.000000ms
|
|
||||||
###### Unable to place polygon 2, aborting
|
|
||||||
-------------------- Placing Polygon (Free rotation)3: path1141-0_0 ------------------------------
|
|
||||||
Elapsed time 3.000000ms, for last polygon 1.000000ms
|
|
||||||
###### Unable to place polygon 3, aborting
|
|
||||||
Optimization finished, elapsed time 0.003000s
|
|
||||||
nbRotation: 226
|
|
||||||
nbTranslation: 226
|
|
||||||
nbPointInPoly: 622
|
|
||||||
nbIntersectPoly: 57
|
|
||||||
nbPlacementImpossible: 207
|
|
||||||
nbCheckAngles=392
|
|
||||||
CacheMiss=392
|
|
||||||
CacheHit OK=0
|
|
||||||
CacheHit KO=1272
|
|
@ -17,17 +17,11 @@ Features
|
|||||||
Author: Mario Voigt / FabLab Chemnitz
|
Author: Mario Voigt / FabLab Chemnitz
|
||||||
Mail: mario.voigt@stadtfabrikanten.org
|
Mail: mario.voigt@stadtfabrikanten.org
|
||||||
Date: 18.08.2020
|
Date: 18.08.2020
|
||||||
Last patch: 23.04.2021
|
Last patch: 24.04.2021
|
||||||
License: GNU GPL v3
|
License: GNU GPL v3
|
||||||
|
|
||||||
Used version of imagetracerjs: https://github.com/jankovicsandras/imagetracerjs/commit/4d0f429efbb936db1a43db80815007a2cb113b34
|
Used version of imagetracerjs: https://github.com/jankovicsandras/imagetracerjs/commit/4d0f429efbb936db1a43db80815007a2cb113b34
|
||||||
|
|
||||||
ToDo:
|
|
||||||
- fix resizing if one or all of the following sizes are zero:
|
|
||||||
img_w = image.get('width')
|
|
||||||
img_h = image.get('height')
|
|
||||||
img_x = image.get('x')
|
|
||||||
img_y = image.get('y')
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class Imagetracerjs (inkex.EffectExtension):
|
class Imagetracerjs (inkex.EffectExtension):
|
||||||
@ -162,15 +156,24 @@ class Imagetracerjs (inkex.EffectExtension):
|
|||||||
trace_width = viewBox.split(' ')[2]
|
trace_width = viewBox.split(' ')[2]
|
||||||
trace_height = viewBox.split(' ')[3]
|
trace_height = viewBox.split(' ')[3]
|
||||||
|
|
||||||
|
# add transformation to fit previous XY coordinates and width/height
|
||||||
img_w = image.get('width')
|
img_w = image.get('width')
|
||||||
img_h = image.get('height')
|
img_h = image.get('height')
|
||||||
img_x = image.get('x')
|
img_x = image.get('x')
|
||||||
img_y = image.get('y')
|
img_y = image.get('y')
|
||||||
|
|
||||||
if img_w is not None and img_h is not None and img_x is not None and img_y is not None:
|
if img_w is not None and img_h is not None and img_x is not None and img_y is not None:
|
||||||
transform = "matrix({:1.6f}, 0, 0, {:1.6f}, {:1.6f}, {:1.6f})"\
|
transform = "matrix({:1.6f}, 0, 0, {:1.6f}, {:1.6f}, {:1.6f})"\
|
||||||
.format(float(img_w) / float(trace_width), float(img_h) / float(trace_height), float(img_x), float(img_y))
|
.format(float(img_w) / float(trace_width), float(img_h) / float(trace_height), float(img_x), float(img_y))
|
||||||
newGroup.attrib['transform'] = transform
|
newGroup.attrib['transform'] = transform
|
||||||
|
else:
|
||||||
|
t = image.composed_transform()
|
||||||
|
img_w = t.a
|
||||||
|
img_h = t.d
|
||||||
|
img_x = t.e
|
||||||
|
img_y = t.f
|
||||||
|
transform = "matrix({:1.6f}, 0, 0, {:1.6f}, {:1.6f}, {:1.6f})"\
|
||||||
|
.format(float(img_w) / float(trace_width), float(img_h) / float(trace_height), float(img_x), float(img_y))
|
||||||
|
newGroup.attrib['transform'] = transform
|
||||||
|
|
||||||
for child in doc.getchildren():
|
for child in doc.getchildren():
|
||||||
newGroup.append(child)
|
newGroup.append(child)
|
||||||
|
Reference in New Issue
Block a user