Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define size #32

Open
ppot opened this issue May 6, 2018 · 22 comments
Open

Define size #32

ppot opened this issue May 6, 2018 · 22 comments

Comments

@ppot
Copy link

ppot commented May 6, 2018

Would be great to be able to define size of the vector in order to make tray icon for application. Like 16px.

@neauoire
Copy link
Member

neauoire commented May 6, 2018

What would be an ideal UX to set the vector size?

@ppot
Copy link
Author

ppot commented May 6, 2018

I would say like the the way we set color now.
Click on the actual vector size and then set it as 16 or 32 etc.

@neauoire
Copy link
Member

neauoire commented May 6, 2018 via email

@ppot
Copy link
Author

ppot commented May 6, 2018

More of a target size!

@neauoire
Copy link
Member

neauoire commented May 7, 2018

So, I was thinking about adding a scale transform to the SVG, something along the lines of transform="scale(0.5)", but inferring that scale value dynamically. Think that would work for you?

@ppot
Copy link
Author

ppot commented May 8, 2018

Yes. As long as you can have a size of 16pxx16px in the final it would be fine!

@espy
Copy link

espy commented Sep 25, 2018

Hey, short heads up, I’m working on an experimental PR that adds a cropping frame to the guide. This generates a viewBox for the resulting svg, allowing you to more easily use the svg either as a fixed-size image or as a container-filling icon. The viewBox also actually crops the svg, so you can choose to only export a bit of your image. The svgs no longer have an absolute size, or any width or height attributes, they’ll always fill their containers while maintaining aspect ratio. If you want a fixed size, you just give the svg width and height via html attributes or CSS styles. So you’d be completely flexible in terms of scaling and sizing. That would also solve this issue, since sizing the exported svg is then super simple.

This is attacking a particular pain point I had with Dotgrid, namely that building scalable icons always required me to edit the resulting SVG to adjust the viewBox, and viewBox is super weird to wrap my head around. When I’m done, Dotgrid’s svg output will be immediately usable as scalable svg icons, hopefully without messing things up for people who use Dotgrid as a pre-Illustrator tool.

I’ll also try to make sure the png gets cropped as well, and that the cropping frame defaults to the canvas size and sticks with it unless it is explicitly resized. In that way, the current behaviour would still be the default, you’d just get a scaling svg instead of a fixed size one. If you want a fixed-size image, you’re better off with the png anyway :D

Hope that all makes sense and doesn’t add anything you don’t want to Dotgrid, @neauoire.

@neauoire
Copy link
Member

I will totally merge that. <3

@espy
Copy link

espy commented Sep 27, 2018

Small update. Got it working, just needs polish and some edge case handling.

Interestingly, the svg viewBox only constrains the svg, it doesn’t actually crop it. Take this example: the yes is inside the cropping frame, and if the svg is constrained widthwise, the viewBox correctly scales the svg so that the no isn’t visible.

bildschirmfoto 2018-09-27 um 10 33 15

But currently, the svg will try to 1. maintain aspect ratio and 2. be completely visible within the available viewport, so then this happens:

bildschirmfoto 2018-09-27 um 10 33 31

If you use the svg in html though, everything’s cool, as long as there’s a container element, that will crop the svg correctly, even without overflow: hidden:

bildschirmfoto 2018-09-27 um 10 42 43

So this is still useful as far as I’m concerned.

@neauoire
Copy link
Member

neauoire commented Sep 27, 2018 via email

@espy
Copy link

espy commented Sep 27, 2018

I just added the cropping frame always staying in view when resizing the app. I’ve only really got the png cropping and storing the crop in the .grid file left to be before I open a PR.

dotgrid_cropping

Edit: Branch is here if you want to take a look already: https://github.com/espy/Dotgrid/tree/feat/better-svg

@neauoire
Copy link
Member

That's awesome, I'd move the control points at the centre of the lines.
Nice work!

@neauoire
Copy link
Member

neauoire commented Oct 6, 2018

Any update on this :)

@espy
Copy link

espy commented Oct 6, 2018

No time to work on it this week or next, I’m afraid. I’ll open the PR now in case you want to do the rest. As for the control points, I’d leave them on the corners, having them in the middle means you need two clicks to do most things with the crop frame instead of one. I wanted to have different handles for the frame to make it easier to find, but I won’t get around to that.

@neauoire
Copy link
Member

neauoire commented Oct 6, 2018

Good point, and I also realized that that would put the control point between two dots on the grid for odd sized crops.

@espy
Copy link

espy commented Oct 6, 2018

Argh, just saw you switched to standard in the meantime, that’s good, but it’s going to make the rebase rather painful :/ Not going to manage that today, sorry.

@neauoire
Copy link
Member

neauoire commented Oct 6, 2018

That's alright, we'll be in transit for the next 2 weeks, we can look at this when we're back near land.

@espy
Copy link

espy commented Oct 6, 2018

Cool, safe travels!

@AntonNiklasson
Copy link

Any updates on this?

@espy
Copy link

espy commented Dec 2, 2018 via email

@jkarttunen
Copy link

So whats still to do? I might be able to help.

@Ledmington
Copy link

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants