Layout manager for HTML5 canvas - javascript

I am working on a project to animate the Data Structures on HTML5 Canvas. I am currently using KineticJs and have looked into other canvas related libraries too. But I have failed to find Layout Manager of any sort in them. Right now if I have to put some rectangles and circles etc. I have to specify their exact coordinates. What I want is something like FlowLayout Manager or Grid layout manager in which if I put some objects they don't overlap on each other and I don't need to mention each of their exact coordinates. When I add new shapes to it they automatically adjust their location accordingly.
Is there any library which provides such feature or What can be the best way to do it ? I am relatively new to the client side programming and HTML5 so if it is very basic please point me right direction to study further.

Related

Using Free-Form-Deformation (or similar technique) in Web

Our AI model recognizes an object in an image and creates a mask on it.
It returns a raster image of mask that covers the detected object.
Here have a look at this example:
Now the black outline is what AI model gives us, and sometimes it makes little errors setting the boundary around the object like shown in red rectangle in the image.
I want to allow the user to correct this outline by dragging the outline.
One way that comes to my mind is to use Free Form Deformation or something similar but I don't know how to do that in React Native, I can't find a library etc. (and don't have much time to implement it from scratch)
Someone please give me a direction on this, Thank you.
If you know coordinates you can use Skia and SVG paths https://shopify.github.io/react-native-skia/docs/shapes/path/ to draw your boundary and using Canvas touch handlers you can allow users to change coordinates.
Example of path building: https://youtu.be/7SCzL-XnfUU
Or this example of a hand drawing app: https://medium.com/react-native-rocket/building-a-hand-drawing-app-with-react-native-skia-and-gesture-handler-9797f5f7b9b4
And this example https://blog.notesnook.com/drawing-app-with-react-native-skia/

Utilizing p5.js/processing for data visualization on a GeoTIFF? How to plot Lon/Lat coordinates in web mercator?

I work on a database collecting archaeological sites. A goal of our project is to make the data accessible on the web. I would like to plot them on a GeoTIFF to show their distribution and change over time. I further want to calculate Delaunay triangulations and a heatmap which you could display as an overlay. Its important to me to visualize the change over time as an animation. I choose p5.js/processing because I'm not a very skilled programmer (some R, NetLogo and Processsing). i think it will fit the task especially regarding the animation. Before I get into more detail my first question is:
Is this a wise choice of tools? Would you recommend other tools?
If you think my choice is vital here is my second question:
I came across Daniel Shiffmans tutorial on visualizing earthquake data in p5.js and this comes close to what I would do:
https://www.youtube.com/watch?v=ZiYdOwOrGyc
The code is here:
https://github.com/CodingTrain/Rainbow-Code/blob/master/CodingChallenges/CC_57_Earthquake_Viz/sketch.js
In the above example he relies on mapbox.js. I would prefer to use a custom build GeoTiff from our project and avoid mapbox since its not 100% free. But how do I get his code to work with a custom GeoTiff as basemap? I can set his variables "clon" and "clat" to my custom Tiff center point but the coordinates did not get transformed right. I think the Problem is the in the zoom level aka "zoom". But how to determine the Zoom for my custom map? I did not find any other implementation of web mercator projection in p5.js nor processing. Or do i get the math beyond projection wrong?
I'm not very proficient with p5.js, but I have a good experience using d3.js for various dataviz tasks, including crunching geodata. So my suggestion would be to use best of both worlds — use p5.js for rendering and d3.js for data manipulation. In your case, it seems like you will need a simple reprojection (LonLat to Mercator).
To reiterate:
Use d3.js to project data from whatever projection it is (LonLat) into projection that p5.js is using (Mercator)
Render projected data in p5.js
Quick googling landed me this guide on d3 + p5 integration
On the d3 side, there is an API documentation
And here is a good example of GeoTIFF reading/rendering in d3.js. Ok, here is one more.

Vector Tracing a Line Around Non-Square Sprites in HTML5

I'm building a game in HTML5. I have hundreds of images that look similar to this:
And at certain points in the game I want to draw an outline around them. Like this:
I want to do different tracing colors at different times and don't want to end up with [number of sprites] * [number of colors] of additional images for memory and bandwidth reasons so I'm looking at vector drawings.
What I need to come to a solution on are really two separate things:
Calculate a vector path for each frame in a spritesheet. This can be either dynamically or ahead of time and stored.
Draw the vector path
The engine I'm using for the game is ImpactJS. It doesn't have any support for vector operations. The author of the game engine I'm using did his own vector drawing manually by exporting the vectors from Illustrator for a particular image, then using an online converter tool to change them to HTML5 syntax. This isn't the best method for hundreds of images so I thought I'd see what information others of you have.
I would like to still draw the images using ImpactJS since this game is already pretty far along, and just do a second-pass drawing of the outline of the image when necessary.
Thank you for any help!

Javascript Map library using canvas like base

We've been working with several libraries like GoogleMaps, OpenLayers, ModestMaps... Even we've written a cartographic visor (Java Applet) that dealed with WMS servers several years ago. Of course this visor is currently useless.
Now we want to develop one FULL HTML5 visor because we're having lots of trouble dealing with the most common frameworks (performance, licensing,design ...). We build advanced and technical maps applications for GIS expert.
We want to draw vectors inside a canvas element. We don't want to draw a canvas object over the base map (like we can do with GoogleMaps ...) , we've been dealing with that and it's not the best way, we need a base object as a canvas HTML5 object in which draw directly.
The question is: Is there a free library that renders on a canvas object which we can extend?
If I understand your question correctly, you want a maps API that will draw the map using html5 canvas. It looks like https://github.com/dfacts/Slippy-Map-On-Canvas/ uses the Open Street Maps API to get map tiles and then draws them on the canvas. Is this what you're looking for?
I think this could be the answer: http://leafletjs.com/. This library does everything that we want, it draws vectors on canvas or SVG, draws tiles maps, good integration with geojson and more...It is far and away the best choice.
Certanly this library doesn't use a unique canvas object, but it's even better.

What Javascript graphing package will let me plot points against a user-selected coordinate system?

My customer has some specific requirements for a graph to show in our web app. We use HighCharts elsewhere in the app for more traditional graphing, but it doesn't seem to work for this situation. Their requirements:
Allow the user to select a background image, set the scale and origin of the coordinate system. We'll graph our points against the user-defined coordinates.
Points can be color coded
Mouse-over boxes show more detail about the points
Support for zooming and panning, scaling the background appropriately
Less importantly:
Support for drawing vectors off the points
Some of this seems basic, but looking around at different graph packages, I was unable to find any with an example of this kind of usage.
I've entertained the thought of just hacking it together in canvas myself, but I've never worked with canvas before so I don't think it would be cost effective. The basics of plotting points with a scaled coordinate system against an image background wouldn't be too hard, but the mouse-over details, zooming and panning sound much more daunting to me.
More info: Right now we use jQuery, HighCharts, and ExtJS for our app. We tried flot in the past but switched to HighCharts after flot didn't meet our needs.
this looks promising:
http://danvk.org/dygraphs/
And this seems to have what You need, but it's not free:
http://www.ejschart.com/

Categories