Live data from Hacker News

SVG can do that?

slides.com

111–120 of 202 posts

Re: SVG can do that?

#111
post #94

This showcases what's wrong with SVG: It does way too much! To be useful as a vector image format, there should be strict rules (and less cruft). Why is there no libsvg like libjpeg or libpng? Why have interaction as part of an image format? SVG lives in an uncanny valley between jpeg and flash/js. I think there is still a big need for a real vector interchange and display format. Right now people pick a "good" subse…

This! I've started to look for usable vector image format for game development somewhere in 2004, now it's 2017 and there is still nothing available. For SVG you literally need to pull-in whole browser engine, which is most likely 2-3 times the size of your whole game.

One possible solution is to the same what XMPP did on XML, or JSON did on JavaScript: Define a "safe subset" of SVG, and stick to that. Perhaps use the "safe subset of XML" as a base (as defined e.g. in XMPP.)

Use a library (or at least a validator) that works exactly on this subset, and fails for anything not strictly conforming to this.

Of course, this is not as satisfying as a "clean slate" approach, but on the other hand, this is a clear migration path with backwards compatibility - which is always good to have during a transition period to avoid all those bootstrapping and chicken-egg issues.

Re: SVG can do that?

#112
post #104

Earlier quoted context omitted.

that's not 100k unique elements though, it's 100k instances of a set of isn't it ?

No, in our case they're all unique elements - unfortunately for me! That demo example is actually much smaller though (2k nodes). Here's an example with over 150k nodes [1]. To be honest, we would normally doctor documents that had this many nodes to make the experience smoother for users. You'll notice that it's a bit sluggish when you zoom in and out, but panning is the same speed regardless of number of elements,…

performance degrades to <10fps above 2k nodes (2k random circles in an svg) for me regardless of browser

Re: SVG can do that?

#113
post #110

Earlier quoted context omitted.

When I started learning React, I realised a dream of mine could finally come true: a proper Celtic Knotwork generator. Uses SVG and React together in harmony. http://celtic-knotwork.online

Pardon my ignorance, but aren't these patterns just composed of certain tiles in rows and columns? This is something you can do equally well with raster graphics, so what's the gain of using SVG here?

Scalable vector output?

Re: SVG can do that?

#115
post #61
post #51

Earlier quoted context omitted.

There is https://www.w3.org/TR/SVGTiny12/ which is a subset of SVG without scripting, without CSS styling. Not sure why it never gained more traction.

Because SVG Tiny 1.2 still has support for scripting and CSS styling. https://www.w3.org/TR/SVGTiny12/styling.html https://www.w3.org/TR/SVGTiny12/script.html

It explicitly doesn't require that the engine do anything with the content of tags, and CSS is explicitly unsupported - they simply use a small subset of properties from CSS as attributes.

Re: SVG can do that?

#116
post #104

Earlier quoted context omitted.

No, in our case they're all unique elements - unfortunately for me! That demo example is actually much smaller though (2k nodes). Here's an example with over 150k nodes [1]. To be honest, we would normally doctor documents that had this many nodes to make the experience smoother for users. You'll notice that it's a bit sluggish when you zoom in and out, but panning is the same speed regardless of number of elements,…

performance degrades to <10fps above 2k nodes (2k random circles in an svg) for me regardless of browser

What are you doing with them? Animating them?

Re: SVG can do that?

#117
post #91

Earlier quoted context omitted.

I think GP was referring to the fact that you don't need to generate SVG assets at multiple sizes for size/picture clarity balance, as you do with popular raster formats.

But GP was asking : "Why the lack of love while we pour ever increasing energy into mangling HTML and CSS" SVG can't be, shouldn't be and never will be the replacement for HTML/CSS/JS.

But GP's point is the opposite, that HTML/CSS/JS is being used too often for tasks that could be much more simply solved by SVG. I can think of a couple just in my current project.

Re: SVG can do that?

#118

SVG works so fantastically well with React -- it's just part of the DOM, after all. Unless there are performance concerns, that reason alone would make me choose it over Canvas every time. Shameless plug, one of my first experiments with SVG+react (+cljs): https://polymeris.github.io/carlos/ Done in one day, without knowing the tech.

I would say not fantastically - it is part of the DOM, but it is 1. XML - so namespaces? 2. SVG has it's own DOM - it builds on an extends the HTML DOM but React only understands the HTML DOM. But I could also say these were minor quibbles.

Most of that is a problem in browsers already as well. While SVG works without problems in other XML languages due to namespaces, browsers run it through an HTML parser and certain things are simply required by that parser for no good reason, e.g. that the XLink namespace prefix must be xlink and otherwise it won't work.

Re: SVG can do that?

#119
post #117

Earlier quoted context omitted.

But GP was asking : "Why the lack of love while we pour ever increasing energy into mangling HTML and CSS" SVG can't be, shouldn't be and never will be the replacement for HTML/CSS/JS.

But GP's point is the opposite, that HTML/CSS/JS is being used too often for tasks that could be much more simply solved by SVG. I can think of a couple just in my current project.

That's exactly my point. It's seems the task now with Web UI is adapting to screen sizes and capabilities to build complex layouts of components that IMHO HTML/CSS is fundamentally not suited for. The leap from using SVG just for simple elements that scale to entire UIs that scale and shift their layouts doesn't seem to far fetched to me...Oracle, Google, Adobe, Microsoft all use(d) XML with a schema for their layout engines and yet the Web won't (cant?) While it has in its grasp an XML as well?

Re: SVG can do that?

#120
The SVGO-GUI has not been updated since 2015. I added out-of-the-box SVG optimization to my Optimage [1]. Fun fact: Node.js binary can be just 3MB compressed. ImageOptim [2] handles SVGs as well if Node.js is installed.

The transparent JPEG-in-SVG files can also be made with nothing but ImageMagick and Bash [3].

[1] http://getoptimage.com

[2] https://imageoptim.com/mac

[3] https://github.com/vmdanilov/svgize

Post reply on HN