tracespace / gerber-to-svg

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

Rotation and size #43

Closed ju5t closed 6 years ago

ju5t commented 6 years ago

We have no control over the files we get or people sent to our website. This makes it challenging to design a box that holds the final svg on a website. Rotating svg's with css is no fun as it turns out.

It would be of great help if we could force the longest side of the board to be either horizontal or vertical. Together with a maximum length (or width for that matter) it would make it much easier to include the svg in a website.

kasbah commented 6 years ago

I have to re-iterate that I think people will be confused if you rotate their boards for them in a gerber viewer. You can fairly easily enforce a maximum width and height of your image container and scale the SVG accordingly.

mcous commented 6 years ago

In addition to @kasbah's point about rotating design files being confusing to the user of a viewer tool, I'm thinking rotation of the image for display purposes is outside the scope of this library. I'm also pretty sure gerber-to-svg provides enough information (i.e. image width and height) for the library client to transform and display the image in any way it sees fit.

I might be able to be convinced otherwise, but at the moment I don't see a compelling reason to add a built-in image transformation feature

ju5t commented 6 years ago

I don't think it is confusing. It's personal. You could argue the same for how to render the top and bottom images. There are people who prefer to have the bottom mirrored to the top layer, others prefer it as it is.

Rotation is the biggest problem as it only changes an element visibly. The actual element will stay where it is. I agree that scaling the image isn't a real challenge.

If you have an image that's 50px in height and you change it to 300px through css/javascript it changes the actual element's height to 300px. If you rotate it 90 degrees the element will use 300px in height but it is visibly rotated. It doesn't matter in which order you do this: the width and height properties will change the actual element, the transform property only changes how it looks.

This means you can easily run into a situation where the svg overlaps other elements of the website or you end up with a lot of whitespace.

mcous commented 6 years ago

@ju5t I think you'd have better luck doing the transform on the SVG and setting width and height on the parent: https://codepen.io/mcous/pen/odZrzV.

It does seem to me like the desired functionality is both easily accomplished in the library client and, like you said, a "personal" preference. Given that gerber-to-svg is, at its core, a 1-to-1 vector image to vector image converter, and I can't think of an elegant way to add "force the height or the width to be the longest length" to gerber-to-svg, I'm going to close this ticket. As always, I'll try to keep an open mind and I'd be happy to re-open / revisit if there really is need for this logic to live in the core conversion library.

Regarding the mirroring of the bottom image in pcb-stackup: the mirroring is an opinionated decision implemented by pcb-stackup outside of gerber-to-svg. Given that pcb-stackup is a gerber-to-svg client that wants to modify the images in certain ways, I feel that leaving transformation out of gerber-to-svg (and, for that matter, leaving additional transformation out of pcb-stackup) is internally consistent