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

Calculate optimal path #21

Open
Danny-Engelman opened this issue Dec 3, 2020 · 3 comments
Open

Calculate optimal path #21

Danny-Engelman opened this issue Dec 3, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@Danny-Engelman
Copy link

Your tool is mentioned by SuperTinyIcons which in turn got some attention in Newsletters.

See edent/SuperTinyIcons#504
I used your editor to play with scale and precision, ended up with precision in the viewBox notation:

I wonder, would it be possible to do some calculations in your editor, see a list which scale settings make a smaller minified path.
Maybe even calculate which results overlap very well with the original.

Ever seen such a tool?

@Yqnn Yqnn added the enhancement New feature or request label Dec 8, 2020
@Yqnn
Copy link
Owner

Yqnn commented Dec 8, 2020

That would be great, but it's something very advanced and complex to automate.
If we start considering destructive transformations, there are a lot of operations that could be combined:

  • changing precision
  • changing scale
  • relative or absolute commands (M10 10V11 => M10 10v1 )
  • scientific notation (1000 => 1e3)
  • translations (M1.55 1.55V2.55 => M1 1V2)
  • command simplification (l 3 0 => h 3)

Before doing that, there are still some basic, non-destructive optimisations, that are not yet implemented, like this one:
l-1-1l-2-3l-4-5 => l-1-1-2-3-4-5

@Danny-Engelman
Copy link
Author

Yes, I do those edits trial and error by hand

Does SVGO recalculate paths?

showing path length

FYI, I hook into your path textarea to display the path length (knowing only GZip size on delivery really counts)

setTimeout(function() {
	let textarea = document.querySelector('[placeholder*="Paste"]');
	let title = textarea.closest("[paneltitle]");
	let span = title.querySelector(".title span")
	
	let update=()=>setTimeout(()=>{
		span.innerText= "Path: "+textarea.value.length + " Bytes";	
	},100);

	document.addEventListener("keyup",update);
	document.addEventListener("click",update);
	console.warn("loaded PathLengthObserver", textarea);
}, 200);

@ace-dent
Copy link

ace-dent commented Nov 1, 2021

Related issue ~

  1. Loading the highly optimised github.svg...
  2. Toggle Minify Output on/off/on.
  3. Minified output is now larger than original. It has added extra c commands, which original skips.

Suggestion:

  • If no changes are made, check minified output is actually smaller than input file, otherwise revert to original.
  • Avoid inclusion of extra c curve commands when avoidable.

PS- Thanks for sharing this fantastic tool! :-)

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

No branches or pull requests

3 participants