tracespace / gerber-to-svg

gerber-to-svg development moved to tracespace/tracespace
https://github.com/tracespace/tracespace
MIT License
81 stars 17 forks source link

Possibility to rotate svg? #28

Closed lindskogaren closed 8 years ago

lindskogaren commented 8 years ago

Hi,

Thank you for this excellent tool. I'm trying to figure out a way to rotate the gerber file 90, 180 or 270 degrees but I can't seem to figure out a way to do it. Is there any way to specify a rotation as an input parameter?

I'm using D3 to draw the svg-files in the following manner: scope.dsvg.append('svg') .html($sce.trustAsHtml(gerberToSvg(svgObj)));

However, when using this approach the normal translation/rotation attributes do not work:

scope.dsvg.append('svg') .html($sce.trustAsHtml(gerberToSvg(svgObj))) .attr("rotate("+rotation+")"); //Does not have any effect

I know that this is probably not an issue with this library, but I wasn't sure where else to put it.

Thank you for sharing your excellent work!

mcous commented 8 years ago

Hey, glad you like the tool! Unfortunately, there is no way to specify rotation as a parameter to the conversion function. Additionally, the solution here isn't going to be very pretty (code-wise) because we're already using a translate + scale transform to flip the image (because Gerber y-coordinates are flipped from SVG y-coordinates).

I've never used d3, but I think I have some tips that could help you figure this out:

I also found this d3 transform library (maybe it can help): https://github.com/trinary/d3-transform

mcous commented 8 years ago

Closing because I didn't hear back, so I assume you figured something out. Feel free to re-open if you're still having trouble