Rendering lottie json into cesium, is it possible? - svg

In threejs and aframe, the json animation of lottie can be loaded into it. I think cesium can do it too, can this be done? Thanks.

Related

Pixi.JS: Using the Pixi Loader to create textures for inline SVG images

Everyone seems to recommend utilizing the Pixi Loader to load textures together, get updates on progress, etc. This works great so far.
However, I am wondering if there is a way to load a texture from an inline SVG using the Pixi Loader? Any insights would be appreciated.
(Note: I am looking to load the SVG as a texture, so I understand it will become a raster image, I am not looking for scalability features of SVG, but to simply reduce the amount of web requests needed by utilizing inline SVG images)
The only way I was able to get this to work, was to make the URL passed into the loader be a base64 encoded dataURI. Everything after "base64," is just a base64 encoded svg. Example:
let svgTest = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5..."
Loader.shared.add('SvgTest',svgTest);
Loader.shared.load((loader, resources) => {
//callback, do what you wish
});

Is there a way to have the user upload an SVG file but then render the SVG source?

Using 2sxc on DNN, I have a website that uses SVGs for icons in content types. The client wants to be able to upload the SVG icons to 2sxc via a Link field but then instead of rendering <img src="#Content.SVG" />, they want it to render the source code of the SVG (so we could manipulate the fill color via CSS). Is this even possible and how could it be done?
Basically 2 steps
Get the real file name using 2sxc and DNN
Then load the file as a string using normal .net stuff System.IO and add it to your html - https://learn.microsoft.com/en-us/dotnet/api/system.io.file.readalltext?view=netframework-4.5.1
ca. like this
<div>
#Html.Raw(System.IO.File.ReadAllText(fileName)
</div>
Some examples of how to do this can be found below
Using the fetch API
How to convert image (svg) to rendered svg in javascript?
Older methods such as XMLHttpRequest or jQuery
Include SVG files with HTML, and still be able to apply styles to them?
Using D3
(Embed and) Refer to an external SVG via D3 and/or javascript
Using a custom JS library
One example: SVGInjector
Interestingly Dnn is doing this nowadays and you can look at the code here. If you ignore the caching, you might be able to do similar in a View.
https://github.com/dnnsoftware/Dnn.Platform/blob/0d3b931d8483b01aaad0291a5fde2cbc0bac60ca/DNN%20Platform/Website/admin/Skins/Logo.ascx.cs#L123
And that is called from above, see ~line 71, so they are doing a real inject of the file contents to inline. Obviously caching file-access stuff should be a priority for caching if the website is high-traffic, but otherwise it is not needed or at least secondary.

can i export svg from bonsaijs to png

Using bonsaijs, is there a way to export the stage (or entire svg) to a png file ?
I saw an option for importing a svg, but couldn't find an easy way to export it. Any leads on this would be appreciated ?
No, there isn't any API provided to export SVG to PNG.
Nevertheless you could either create your own exporter that draws the whole SVG context to a Canvas context and exports that as PNG or instead of storing a static image and losing all movie informations and interactivity you could possibly store the whole Bonsai-Script for that specific user.

Weird results when converting SVG to js for Raphael

Im trying to use this image with Raphael:
http://upload.wikimedia.org/wikipedia/commons/9/9f/Argentina_Buenos_Aires_City_location_map.svg
I convert it to js with: http://toki-woki.net/p/SVG2RaphaelJS/
And I get this:
Any Idea of what can I do to solve this? This is worst apparently when I add text in inkscape above each reagion to change later via javascript.
Im using SVGWEB now without problems buy Im trying another alternatives because I cannot make the addeventlistener work in IE7/8 like I said here:
can't add listener to a SVG in Internet Explorer using SVGweb
Any ideas?
Thanks!
Try mapSVG plugin instead.
Demo with your map: http://map.karaliki.ru/bu.html (zoom in-out with mouse wheel)
It works in IE7-8 as well.
Plugin's description: http://map.karaliki.ru

Can html2canvas render svg in a page?

I am using html2canvas to create a 'screenshot' of a HTML page that contains SVG.
Everything looks good, except the element.
I know that it should be possible to render SVG in Canvas; PhantomJS, fabric.js and CanVG do it.
Is this something that html2canvas does not support? Or am I doing something wrong, and this should just work?
If this has not been implemented, what is the best way to extend html2canvas (using canvg)?
Capturing SVG images works by transforming them into canvas, using canvg. Include both javascript files as indicated on that page. Then the easiest way to do this is:
<body onload="canvg()">
See the parameterless call example.
When all SVG images have been converted, html2canvas works flawlessly.
Of course, all SVG images will be converted to canvases, but I did not see a difference.

Resources