16 ms·
TinyVG: A challenger to the throne of vector graphics
- RyanGoosling 5y agoSVG is great. CSS is great. Both are not difficult to understand, relatively. There are existing libraries. Why reinvent the wheel? Does this reinvent CSS too?
- tromp 5y agoFor Haskell fans, there is diagrams [1]: "a powerful, flexible, declarative domain-specific language for creating vector graphics, using the Haskell programming language." [1] https://diagrams.github.io/ https://diagrams.github.io/
- deleted 5y ago[deleted]
- losvedir 5y agoVery interesting! I like the idea. One sort of concerning thing is in the comparison chart on the page, the middle column (the TinyVG renderer) the images look a little blurry to me. Is that just a limitation of the renderer? I suppose since the right column is clear, it means the spec is _capable_ of producing clear images, right?
- ikskuh 5y agoAuthor here: This is actually a limitation of chrome! The images are perfectly sharp when displayed as files: https://tinyvg.tech/img/app-icon.png https://tinyvg.tech/img/app-icon.png The are just up/downscaled to 3em height so the table looks uniform
- adgjlsfhk1 5y agoI'm seeing the same thing in firefox (Linux)
- ikskuh 5y agoYes, it's because the images in the PDF are always scaled. I cannot get them to pixel-perfect display in the PDF renderings anyways The images are the output from the offline renderer, so they are included as PNGs
- ComputerGuru 5y agoReally cool work - I've been looking for something like this for some time and have played around with HVIF and IVG to that end. @ikskuh since I see you here in the comments, I have one nitpick: I don't think it's fair to compare your binary format to an uncompressed SVG file since they are most often used online (and often used even offline) as gzip- or brotli-compressed resources. It would be nice to see an additional comparison between gzipped TinyVG and gzipped SVG to help even the playing field.
- ikskuh 5y agoYes, i've heard it from some people already. Will add this to the benchmark tomorrow. It's late here in germany and running the benchmark takes roughly 30 minutes already. With gzip, i expect it to go up to 45 or 60 minutes, as we all want good compression rates!
- ShrigmaMale 5y agoAlso is the svg itself optimized? Usually possible to take a lot off them with tool like svgomg: https://jakearchibald.github.io/svgomg/ https://jakearchibald.github.io/svgomg/
- goodmachine 5y agoor Nano https://vecta.io/blog/how-nano-compresses-svg/ https://vecta.io/blog/how-nano-compresses-svg/
- ikskuh 5y agoI have a full description of the benchmarking process on https://tinyvg.tech/benchmark.htm https://tinyvg.tech/benchmark.htm tl;dr: The input svg is pushed through svgo, so we have a very compact format already
- pupppet 5y agoI have to install a plugin to allow my WP sites to support SVG because they can potentially contain scripting, what a pain in the ass. All we wanted was vector images, what we got was vector images and a couple kitchen sinks. Bring on the alternatives.
- ARandomerDude 5y agoAlso, don't use WordPress. It sucks.
- anaganisk 5y agoWordpress itself doesn’t suck, its the plugin ecosystem developed by script kiddies that suck.
- jancsika 5y agoFYI-- if a user right clicks to "View Image" on an SVG, the new tab will run any scripts contained in the SVG.
- wongarsu 5y agoSVG is basically HTML, but for graphics; with much the same ecosystem (JS, CSS, etc). In my opinion that's pretty awesome and opens a whole world of possibilities. At some point it looked like SVG was poised to become the successor of Flash, but the authoring site never appeared so we didn't get any successor to Flash. Of course this has some drawbacks, particularly when talking about user-uploaded SVGs on a website (they probably shouldn't be on the same domain as the website at all). But that's a much narrower use case than what SVG was supposed to be or even than what SVG is used for today.
- pcwalton 5y agoThere are many other popular vector graphics formats beyond those mentioned here. Lottie has already displaced SVG for animation/motion graphics, and for static content IconVG exists and is backed by Google. There's also PDF, PostScript, Flash, the glyf format in OpenType, etc.
- dosshell 5y agoI have heard very good words about the eps format from a vector-format nerd (he reads file format specifikation books because its fun). I would love to here more opinions about eps from other developers. How does eps really compare with the other formats mentioned above?
- andybak 5y agoI've been avoiding EPS like the plague for several decades. Unless something has changed since I last looked it would be well below SVG on my preferred format list.
- IshKebab 5y agoI can't imagine those good words ever came from anyone that has actually used it.
- heleninboodler 5y agoEPS is just PostScript that's designed to be more embeddable. It's a PostScript program that contains some metadata like a preview image (so you can display a thumbnail when embedding it even if you don't have a PS interpreter) and a bounding box (since PS has an arbitrary coordinate system, in order to represent an embedded document without actually interpreting it, you need to know the bounds of what it's going to draw). The big problem with PS, EPS and Flash as simple graphics formats is that they're all turing complete and you can author documents that will never terminate. When importing EPS, Illustrator used to have a timeout and would fail if the render didn't complete in a couple minutes. I assume it still does, but haven't tried it in years.
- 5y ago
- HideousKojima 5y agoThe examples in his benchmark image are noticeably blurry compared to the SVGs. Is this due to his software renderer or something in the format itself? Because for me most of the reason I would use vector graphics in the first place is to maintain a crisp look regardless of resolution, and if the middle images are what I can expect from it then I definitely wouldn't use the format. Edit: Nevermind, this was answered in another comment, apparently it's a limitation of Chrome
- BudaDude 5y agoExcluding animations kills this for me . We need more SVG animations on the web. But the state of animation in SVG is a headache unless your using a third party library .
- deleted 5y ago[deleted]
- MisterBiggs 5y agoIf your argument is that animations in SVG don't work well then wouldn't it be best to use TinyVG in place of static SVG assets and make something new that is better suited for animation?
- jlarocco 5y ago> We need more SVG animations on the web. Do we, though? We've already had animated GIFs, the marquee tag, Java applets, and Flash animation, and they've all died out because 99.9% of the time the animation is obnoxious and terrible. Vector animation would be just as annoying.
- bsder 5y agoFlash animation didn't die out--it was assassinated by Steve Jobs. Flash renderers didn't have to suck. However, there wasn't enough money in it for anyone to care.
- jlarocco 5y agoOkay, and he killed it because it was annoying to users and provided little value.
- hutzlibu 5y agoGIFs are horrible in terms of memory. Java applets died out of technical reasons (and was replaced by flash) Flash died, because it was proprietary and Adobe did not open it up. (and flash was vector animation btw.) Otherwise it surely would still be around. And in a way it is, as you can export flash animations to the html canvas element. And some people do that (with quirks) In other words, a simple, but powerful vector animation tool, is very much needed. The current state is a mess. And you probably do not like vector animated advertisement, or websites that use animations for the sake of animations. Sure, no one wants that. But how about games, or interactive graphic to for example show complex data in context to some map? Or animations for didactic purposes? Cartoons? A animation well done is actually one, you do not notice. (but you would notice, if it was missing)
- fsgghjhgfd 5y ago
- styfle 5y agoLooks really interesting! Can TinyVG be converted to other image formats, such as PNG?
- ikskuh 5y agoYes, the SDK contains tvg-render which can render TVG to TGA. Implementing PNG in that tool would double the size of the SDK source ^^
- mmcgaha 5y agoFor simple image generation, nothing beats SVG or EPS. For years, these two technologies have let me add cool stuff to PDFs and web pages without the need for expensive/complex/insecure libraries. It is going to be pretty hard to beat the ease of generating these formats.
- ikskuh 5y agoThen you should check out the TinyVG text format: (tvg 1 (32 32 1/1 u8888 reduced) ( (1 0 0) ) ( (fill_polygon (flat 0) ( (16 0) (32 32) (0 32) )) ) ) This draws you a tiny triangle. The only problem you'll get is when doing text, but for SVG: These wouldn't be portable anyways
- shatteredgate 5y agoAm I the only one who dislikes S-expressions and prefers XML or JSON or even YAML? The parenthesis are way too confusing when editing manually and the format doesn't have enough semantic information to always correctly parse into common structures in any language besides lisp. I enjoy writing lisp myself but I really think it is a mistake to use them for common formats everywhere that I've seen it tried.
- dnautics 5y agoseriously, it shouldn't be so hard to write a parser that compiles your favorite text format to TVG, or even to the lispy text format.
- shatteredgate 5y agoIMO that defeats the purpose of using this format if you have to write things to compile to it. If you do that you might as well just compile to the binary format since you won't be editing your canonical representation anyway. I'd imagine with image formats you'd want to pick a format that is the easiest possible thing to parse and consume while not harming it's "editableness" and I don't think S-expressions fit that bill.
- matthewmacleod 5y agoWhile I do appreciate the thought process and hard work, it does maybe feel like the most of the benefits could be obtained with a strict subset of SVG instead - something like SVG Tiny was meant to be, but with fewer bad decisions! That would allow for compatibility with the existing ubiquitous SVG ecosystem.
- ikskuh 5y agoThe problem with that is that you still need to implement a full XML parser. Even if you strip out any CSS and ECMAScript, it will still require the complexity of XML with all it's gloryness and escapiness and ambigious defines. And even if we rely only on XML, we get the DOM and hierarchical structures. If we forbid those, we have <svg><object /><object /><object /></svg> as a file format and people will look weird because their other SVG won't be supported in there.
- tracnar 5y agoYou could also restrict the allowed XML so it can be parsed/generated without a full parser.
- exabrial 5y ago"XML is bad" is still one of the worst engineering arguments. Why is it bad? What is the tradeoff? Things that are bad are easy to quantify as they're measurable. What does it have? It has strong schema support built in. Any intelligent IDE allows for cmd-space completion by reading the XSD. I don't buy this argument as full XML parsers are not even as complicated as HTML5 parsers, which nobody seems to have an issue with. It's not the end-all-be-all of formats, but this is something that's oft-repeated and never quantified. Your second point is actually valid though. If the TinyVG format takes advantage of non-tree based data-structures, I can certainly understand the motivation. I have a hard time conceptualizing how a tree based format would be beneficial to a vector format, other than describing metadata about certain "areas" of the image.
- adgjlsfhk1 5y ago
- cryo 5y agoThis looks interesting. Small issue, the link to the SDK manual currently throws a 404: https://tinyvg.tech/download/tinyvg-sdk-readme.txt https://tinyvg.tech/download/tinyvg-sdk-readme.txt
- ikskuh 5y agowhoopsies. CI failure on my side, will be fixed in roughly 20 minutes
- goodmachine 5y agowhat's wrong with SVGTiny? https://www.w3.org/TR/SVGTiny12/index.html https://www.w3.org/TR/SVGTiny12/index.html
- the_duke 5y agoIf you take a look at the spec you will find: 12 Multimedia, 13 Interactivity, 14 Linking, 15 Scripting, 16 Animation, 17 Fonts That does not sound very tiny to me.
- deleted 5y ago[deleted]
- userbinator 5y agoI wondered how it compares to the same subset of SWF, which is another vector format designed with a huge emphasis on size and decode efficiency. The example tiger.svg is 96719, and tiger.tvg is 27522, but I have a tiger.swf which is 21381 and tiger.pdf 77377. It seems to be a little worse than SWF, but much better than SVG and PDF. I agree with the author that SVG is bloated, but not sure making another format is the answer, especially when there's already very good prior art. (I have written SWF rendering and conversion code before, so I might be biased in saying that it's an example of a very well-designed vector format; too bad Adobe has been trying to kill it off.)
- mdswanson 5y agoSWF is more of a painters/immediate-mode model and SVG/PDF/etc. is a retained mode that defines a set of objects. Different use cases for sure. I've written SWF->vector conversion tools, and the formats are quite different.
- userbinator 5y agoYou can define sprites in SWF too.
- hutzlibu 5y agoYeah, SWF looked promising in its day and its a shame it is basically dead(?)
- richardanaya 5y agoMesh gradients might make and impressive feature!
- ikskuh 5y agoCan you elaborate that and provide some sources on what a mesh gradient is?
- jancsika 5y ago> How will this look in different browsers? Let's test! obviously different font widths for rendering of SVG text in different browsers/font stacks > That didn't go as expected. I thought that at least both files on my Linux machine look the same, but it seems like Firefox doesn't like the font-size specification, while Chrome and Edge do. I asked the Render-A-Webpage-As-An-SVG-framework guy about this last week. He claimed over multiple years he hasn't had a single report of broken text rendering from users of his framework. So what's the deal? Are OP and me the only devs who have ever hit up against this issue in practice?
- deleted 5y ago[deleted]
- ikskuh 5y agoThat's a good question! I fell for this problem with text rendering once as the font i've used in a SVG wasn't installed on the target machine. If i create a image, i want that image to look exactly the same on all machines. This is sadly not the fact for SVG :( The W3C SVG example files contain a lot of these files that make every SVG renderer explode. There's images that don't render anywhere except inkscape
- nine_k 5y agoThis is a problem with any image format. Either you embed the font (or parts of it), or convert the text to curves.
- Shared404 5y ago> There's images that don't render anywhere except inkscape You just have to convert the text in the image to a path before using it wherever you plan on, just be sure to save the original for editing.
- ikskuh 5y agoI wasn't talking about text in that case. Here's a screenshot of that image: https://mq32.de/public/9f3cd5eb7f310139cf8acdd61edb73080d26a4e2.png https://mq32.de/public/9f3cd5eb7f310139cf8acdd61edb73080d26a...
- pier25 5y agoWhat about performance? I assume a TinyVG decoder will be much faster than an SVG one. I expected to see something related to performance in the benchmark[1] but it's only focused on file size. [1] https://tinyvg.tech/benchmark.htm https://tinyvg.tech/benchmark.htm
- ikskuh 5y agoThe question is if we talk about decoding or rendering performance. Right now, the software renderer is slow as heck and not optimized at all. But the decoding speed should be blazingly fast, as there is not much memory heavy lifting to do, and only a handful of int to float conversions. As soon as i have a competetive rendering (aka Vulkan), i will add those to the benchmark. My guess is that rendering TinyVG should also be much faster than SVG due to not having any matrix transformations or hierarchies included in the format
- 28uwedj 5y agoTiny differences? Shits blurry as hell.
- flohofwoe 5y agoLooks crisp here on a 14"MBP (this demo: https://tinyvg.tech/polyfill/index.htm https://tinyvg.tech/polyfill/index.htm)
- akdor1154 5y agoHuh, nice. I always reach for SVG when i want a hand-editable format for some random project, but your points on the parsing and implementation complexity seem very reasonable. Two qns: 1. Did you consider a re-specification of SVG or a subset in another embedding language that's easier to parse? text/json+svg, application/bson+svg, etc. (Examples for clarity, not literally suggesting json/bson are appropriate choices) 2. SVG has broken gamma-correct blending. It was originally not specified at all so all implementations did it wrong; i think the spec fixes it in 1.2 but the only people who care are Inkscape, and they explicitly aren't implementing it because they don't want to author files that in all likelihood will never display properly in browsers. So... the ship sailed in the wrong direction. Could be worth some thought at this early stage of your project, then you'd have a feature that you actually can't achieve in SVG.
- ikskuh 5y ago> 2. … Oh that explains why all my rendering experiments looked different from SVG. I think the reference renderer already does gamma correct blending. This is something we should add to the specification for sure. > 1. … Even re-encoding the SVG crap would only remove XML from the equation, but that's not my main concern with SVG. Zig has the Zen "only one way to do things". Meanwhile SVG has tens of ways to solve the same problem. One example: You can set the opacity via css, fill-opacity and opacity. What you cannot do: Set the opacity via color. But you can make 50% black by just specifying fill-opacity, as black is the default color. to render lines, you need to set fill to "none". ugh.
- CliffStoll 5y agoYes! For a pen plotter, I'd like something like SVG that has color, pen-pressure, and pen-rotation.
- CamperBob2 5y ago90+% of real-world SVG files display just fine with NanoSVG, just to name one of several small SVG renderers that are already available. And it's not one of those Microsoft Office scenarios where the 90% subset is slightly different for every user. So I don't really see the point in introducing any new vector graphic formats. Just define a subset of SVG that supports the features commonly in use, give it a name, and adopt one of the existing lightweight renderers, forking it if necessary. As others have pointed out, representation size doesn't matter because it'll be compressed anyway in any applications where size is important. Plain old text is fine.
- ikskuh 5y agoSo i did the dance with a single file (my starter file): It's the "shield-account" from material design. 353 shield.svg 246 shield.svg.gz 119 shield.tvg 139 shield.tvg.gz Looks like tvg is so well compressed that using gzip compression doesn't help and beats compressed and optimized svg still by a magnitude of two. We'll get better numbers when i find time to improve the benchmark. TinyVG was also designed to be used on constrained embedded systems with low RAM, and i have a proof of concept that it can render medium complexity files with less than 32k RAM without memory optimizations in the reference implementation. NanoVG doesn't seem to support streaming render events either, so it isn't suitable for low memory profiles as it creates a DOM that will be rendered
- sysrpl 5y agoI am not sure how relevant this is, but I recently published a proof a concept library that converts SVG documents into simulated machines. See the link below. https://www.getlazarus.org/videos/physics/blueprint/ https://www.getlazarus.org/videos/physics/blueprint/ The rendering in my library relies upon OpenGL and the NanoVG library. My library is called Tiny Sim. All of these nano tiny and vg names seem to be colliding adding a bit of confusion in my opinion.
- culi 5y agoThis is actually just like... aesthetically pleasing to watch. As someone who loves watching/reading about Game of Life lifeforms, I'd love to see some sort of gallery where people can share their creations and/or build upon other people's
- post-it 5y agoVery reminiscent of Line Rider. https://www.linerider.com/ https://www.linerider.com/
- kinduff 5y agoThis brings me back, loved this game and I'm impressed with the updated version.
- richardanaya 5y agoI love this Zig art.
- cheeaun 5y agoWondering how is this compared to Ian Hickson's research: "A vector format for Flutter (and beyond)" https://docs.google.com/document/d/1YWffrlc6ZqRwfIiR1qwp1AOkS9JyA_lEURI8p5PsZlg/edit?usp=sharing https://docs.google.com/document/d/1YWffrlc6ZqRwfIiR1qwp1AOk...
- Eduard 5y agoWhat about accessibility? SVG can support it, https://www.w3.org/TR/SVG/access.html https://www.w3.org/TR/SVG/access.html Just converting text to vector paths will ruin accessibility, and also hurt SEO / discoverability.
- nine_k 5y agoIf you need complex graphics that need multiple accessibility nodes, stick with SVG. If you need the "tiny" part of TinyVG, add an aria label to the UI node that renders it. Should work well for icons, logos, etc.
- vjeux 5y agoI was hoping to make an excalidraw exporter to TinyVG but unfortunately it doesn't support text. It makes sense given that rendering text is horrible but doesn't work with this use case.
- ikskuh 5y agoIf excalidraw supports conversion of text to paths, you can do it!
- 41b696ef1113 5y ago@ikskuh -I do not see any mention of layers or grouping in the specification (unless it went by some other terminology I missed in my skim). In the blog post you said you wanted to avoid having an "authoring" file and a "redistributable" version. I am far from an artist but have hacked out a few .svg sketches and layers/grouping are a requirement for creating new content.
- ikskuh 5y agoI think you got me wrong then. I WANT authoring files and redistributables to differ. Nobody should send SVG, xcf, psd files to the consumers. We use PNG or JPEG for pixel graphics, why not send of TinyVG instead of SVG, but use SVG as the source file. This is what i've done for a lot of test files until i had the TinyVG text form ready. Also, we should not edit graphic files in a code editor. We have better tools for that
- 41b696ef1113 5y agoWhoops. Well then sounds great.
- est 5y agoThe best streamable vector animation format was invented 20 years ago, called Macromedia Shockwave Flash. It was killed by poor mobile processors and Steve Jobs' "Thoughts on Flash"
- userbinator 5y agopoor mobile processors I don't think even the first generation of iPhone (400MHz ARM) was too slow to run the average Flash games of the time, given that SWF was originally designed to work well on mid-90s PCs (200-300MHz Pentium/Pentium II). and Steve Jobs' "Thoughts on Flash" That's more likely.
- est 5y ago> was too slow to run the average Flash games of the time The peak performance was enough, but the it will drain battary very quickly.
- cmrdporcupine 5y agoIt was killed by its vendor's poor implementation (poor performance, battery eater on mobile and on laptops) and lack of effort to port to and support non-Wintel platforms.
- CyberRabbi 5y agoWhy not just implement a subset of SVG?
- ur-whale 5y ago> Why not just implement a subset of SVG? XML
- CyberRabbi 5y agoJust curious how does XML prevent you from implementing a subset?
- ur-whale 5y agoXML is an integral part of SVG. Don't even know what implementing a subset without using XML would actually mean. An XML being a strong contender for the title of worst file format ever devised by mankind, I'm not sure how 'implementing a subset' would fix that.
- CyberRabbi 5y agoWell yes, it’s true you’d have to implement basic XML parsing to implement a subset of SVG. At the same time, despite how unpopular XML may be it’s among the easiest textual languages for which to write a parser. This isn’t hyperbole. It’s so trivial I didn’t even consider that that’s what you actually meant.
- templix 5y agoCareful now. SVG uses a lot of XML features that goes beyond "basic XML parsing". To define a subset of SVG doesn't imply that simplifying the XML part is going to be easy.
- CyberRabbi 5y ago> Careful now. SVG uses a lot of XML features that goes beyond "basic XML parsing". Could you name the feature to which you are referring specifically? > XML part is going to be easy. What part of parsing XML is hard? My premise is that all XML parsing is easy.
- ur-whale 5y ago> What we definitly don't need is a vector graphic format that can do raw sockets. Amazing.
- mfabbri77 5y agoTiger rendering issue: https://imgur.com/a/huaKQgk https://imgur.com/a/huaKQgk Your effort to create a lightweight vector file format with these features is really appreciable, even if it can never replace SVG for the more general use case. Anyway the tiger has rendering problems (I am quite obsessed with this tiger: even my rasterizer initially did not draw it correctly). Spoiler: I'm one of the developers of AmanithSVG - http://www.amanithsvg.com http://www.amanithsvg.com
- ikskuh 5y agoOh, good catch. But this is actually not a problem in the rendering, but a conversion problem from SVG to TinyVG. The converter doesn't do hierarchical attributes yet, so if something uses a <g> to disable filling, it will still fill those elements
- badsectoracula 5y agoThis looks nice, i was thinking of adding some vector support in my Little Forms[0] GUI toolkit at some point but everything feels overcomplicated and bloated - however this looks quite nice at a first glance. As i don't have any advanced vector drawing code at all (aside from the basic "draw line, draw circle" etc needed to draw the GUI itself) it can work as a template for what to put in there. [0] http://runtimeterror.com/tech/lforms/ http://runtimeterror.com/tech/lforms/
- cycomanic 5y agoI really appreciate the idea, but with the given subset I really like to know more about the use case. The only one I can think about is icons. Considering that there is no animation support, only two point gradients and no text support (as far as I understand the spec), that rules tinyvg out for pretty much 95% of what I use vector graphics for. If I want to have use those features I now need two (or more) formats, which kind of defeats the point of a less complicated format, for size, complexity and security reasons.
- m_eiman 5y agoIt would be interesting to see how it compares to Haiku Vector Icon Format, which shares some of the same priorities. Some more info: https://en.wikipedia.org/wiki/Haiku_Vector_Icon_Format https://en.wikipedia.org/wiki/Haiku_Vector_Icon_Format http://blog.leahhanson.us/post/recursecenter2016/haiku_icons.html http://blog.leahhanson.us/post/recursecenter2016/haiku_icons...
- degurechaff 5y agoIt seem TinyVG don't support LOD which I think an important feature for icon use case
- RazrFalcon 5y agoA small nitpick as the resvg author: the repo located here https://github.com/RazrFalcon/resvg https://github.com/RazrFalcon/resvg I'm not sure why the author linked some random, outdated fork. If you're trying to beat SVG, you should have done a better research. But yes, SVG is extremely bloated and under-documented. Especially SVG 2. The core resvg codebase is close to 20 KLOC, while the whole package is like 50 KLOC. On the other hand, resvg is an exception, because it doesn't rely on any system and/or 3rd party libraries. 95% of the code in the final binary was written by one person (me). Not because it was strictly required, but because it was fun. resvg is basically an epitome of RIIR.
- Loic 5y agoRIIR : Rewrite It In Rust. Just because I had to lookup this, for me, new acronym.
- ikskuh 5y agoOh, hi! > A small nitpick as the resvg author: the repo located here https://github.com/RazrFalcon/resvg https://github.com/RazrFalcon/resvg Oh, i didn't see this. Thanks for some more correct and real numbers, i will correct them in the article later! > I'm not sure why the author linked some random, outdated fork. because it appears way higher up on the google search if you search for "svg rendering library". Sorry i didn't recognize that it's a fork! Nice work then! I should check it out for SVG rendering and parsing. How much work would it be to port over the C# SVG→TinyVG converter to Rust based on resvg? Considering that you already have a well done parser compared to mine...
- niutech 5y agoApart from SVG, there are long-standing and well-established formats for vector graphics: Enhanced Metafile (EMF) and Encapsulated PostScript (EPS). Why not use them instead of a new file format?
- vsl 5y agoIIRC EMF is specified as basically “whatever win32 GDI does”, it never was meant as portable format. And PostScript is a Turing-complete programming language - not really a way to make anything simpler, let alone SVG.
- Const-me 5y agoThis is awesome! A few notes on the formats. > magic must be { 0x72, 0x56 } I usually use weird non-ASCII bytes in file signatures of binary formats. Many tools will then correctly identify the file as binary data. > RGB 565 Not important, but I would remove that. In hardware, these 16-bit formats is a thing of the past. Nowdays, you only saving 2 bytes/color compared to RGBA8, for non-trivial complexity cost. > with the color channels encoded in sRGB I would add another field in the file header for color space. For RGBA8, sRGB is the only reasonable choice, for FP32 colors however, linear colorspace is very reasonable for some applications. > VarUInt.. encoded as a variable-sized integer that uses 7 bit per byte for integer bits and the 7th bit to encode that there is ”more bits available”. This means you need to parse the complete uint just to skip the field, less than ideal. MKV does it much better https://www.rfc-editor.org/rfc/rfc8794.html#name-variable-size-integer https://www.rfc-editor.org/rfc/rfc8794.html#name-variable-si... you only need the first byte to find out the length. Note all modern CPUs have bswap instruction or an equivalent to load integers from memory while flipping endianness to little endian. > Arc Ellipse Even circular arc segments are relatively hard to implement. The only reason it’s relatively hard and not insanely hard, formulae created for SVG and similar: https://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter https://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpoin... Pretty sure elliptical arc segments going to be insanely hard to implement and debug. Another thing, AFAIK no authoring software supports these splines, how people are supposed to get vector art with these things?
- kabdib 5y agoTypo early in the format documentation, where the text has an example: (byte & 0x1F) >> 3 should probably be ((byte >> 3) & 0x1f) ... or something like that.
- Const-me 5y agoAlso, important stroke parameters are missing, line joins and caps. See pictures on these pages for illustrations: https://docs.microsoft.com/en-us/windows/win32/api/d2d1/ne-d2d1-d2d1_line_join https://docs.microsoft.com/en-us/windows/win32/api/d2d1/ne-d... https://docs.microsoft.com/en-us/windows/win32/api/d2d1/ne-d2d1-d2d1_cap_style https://docs.microsoft.com/en-us/windows/win32/api/d2d1/ne-d...
- jokoon 5y agoWouldn't it be possible to use SVG for things that are done with HTML+CSS? Seems like doing a webpage with SVG instead of CSS would also allow more flexible web design.
- dragonwriter 5y ago> Seems like doing a webpage with SVG instead of CSS would also allow more flexible web design. Seems exactly the opposite to me. But maybe I don't understand the intended sense of “flexible” intended.
- randomcarbloke 5y agoif I give this to my laser cutting guy is he going to be annoyed?
- auxym 5y agoFrom my experience, laser cutting shops (we're talking about steel plate cutting right?) are annoyed with everything except DXF.
- jmiskovic 5y agoIt's common to think of vector art of 'ground truth' and bitmaps as sampled image, but SVG and TinyVG don't add so much over bitmaps. When you zoom into 100-point polygon, you still reach the limit where there is no additional details. Those 100 points are in fact samples, an approximation of artist's intention. When boolean operations are preformed on polygons, information gets lost and the shapes degenerate. The SDFs in 3D modeling seem more pure way of defining and manipulating shapes than polygons and bezier curves. TinyVG doesn't implement node referencing. In SVG it is done by the `clone` operation, which creates SVG node that references original shape. Using this you can build smart scenes with shadows, reflections, arrayed clones and other interesting effects. It's like DRY principle for art; you can later modify the original shape and see changes reflected in other parts of the scene. TinyVG doesn't even seem to have object groups. If I wanted to draw a gauge and control needle rotation in runtime I would have to manually re-compute path coordinates each frame. In SVG I would group all parts the gauge needle, and in each frame I would update just the rotation angle in group transform. For a vector format to de-throne the SVG I would expect it to be smarter than SVG while discarding legacy features. I'd like to see things like infinitely large dimensions for shapes (shapes for ground and sky, or a ray of sun), specifying design constraints, interactivity and procedural animations. IMO the TinyVG takes vector graphics into wrong direction, as a boring subset of SVG. Edit: I like that TinyVG takes form of very readable lisp-like data description language. Maybe it could be used as a starting point for a smarter vector format for authoring graphics and not just for distributing the end results.
- unionpivo 5y agoYou are talking about 2 vastly separate things. Most uses today of SVG, that I have seen in the wild are icons, graphs and diagrams. Which this TinyVG covers beautifully. Especially for embeded (TinyVG's authors motivation for this) you often need some icons. Sure if you need something more complex keep using SVG, or create something new. But for 80% - 90% off web and embedded its enough. > TinyVG doesn't implement node referencing. In SVG it is done by the `clone` operation, which creates SVG node that references original shape. Using this you can build smart scenes with shadows, reflections, arrayed clones and other interesting effects. It's like DRY principle for art; you can later modify the original shape and see changes reflected in other parts of the scene. TinyVG is final format optimized for rendering. You can design your graphic with all those futures, and then render them to TinyVG. DRY doesn't apply since you will not be writing it by hand anyway, but use a tool. Author clearly states that this is not an Authoring format, but display format. What you are looking for is better authoring format. > Edit: I like that TinyVG takes form of very readable lisp-like data description language. Maybe it could be used as a starting point for a smarter vector format for authoring graphics and not just for distributing the end results. That's not TinyVG format. That is just sample generator that comes with TinyVG suite. TinyVG is binary format, and you can't edit it with text editor
- chrisweekly 5y agoRelated tangent: despite its age this "SVG Can Do That?" preso by the inimitable Sarah Drasner still floors me every time: https://slides.com/sdrasner/svg-can-do-that https://slides.com/sdrasner/svg-can-do-that
- stuaxo 5y agoPossibly because I am interested in animation, I immediately want some of the things removed, like hierarchy. With a hierarchical system you can do things like bones for animation.