Draw a point path using MotionLayout - android-motionlayout

Is there a way to draw in MotionLayout a view path without canvas.drawPath(path, p) ?
example1
example2

MotionLayout does not provide a drawing API.
There are many solutions to this.
The simplest no code solution is to Use Lottie
(Medium on Lottie animations in MotionLayout)
Put a LottieAnimationView in the MotionLayout and drive the progress.
https://airbnb.io/lottie/#/android?id=core-classes
The advantage is no code.
The disadvantage is it would not be dynamic to the shape of the phone/language
Building your own CustomView that is driven from MotionLayout is also very simple.

Related

Pixi js: recognize objects on image

I want to create carcassonne-like game using pixi js. Each tile is a separate image and I need to recognize some objects on this image like roads, towns etc. Is it possible to use pixi for this purpose? If yes what approach I need to use? I googled it but can't find anything useful.
First of all: Of course you can use pixi.js for this purpose. But you should keep in mind that pixi is not a gaming engine. It's just a renderer, so you have to do a lot of the calculations like collisions and positioning for your game by yourself.
A possible approach (I'm sure there are tons of other ways to do it):
You should preload all of you images
Create a Container: var myContainer = new PIXI.Container();
Create textures for your images: var texture = new PIXI.Texture(yourImageStoringObject)
Add the textures to you container: myContainer.addChild(texture);
Create an additional container holding your hit areas (roads, towns
etc) and add this container to the main container again.
Create some pixi geometrics like rectangles (new
PIXI.Rectangle(x,y,w,h)) or circles representing you hit areas and
add them to your hit-area-container
Right now my answer is kind of a abstract approach. I'm just guessing what could help you to start your project. Try to figure out some basics and ask for help again. If you could provide some chunks of code it's a lot easier to help out! :)

Undirected graph using Raphael layouted using Jointjs

I am trying to create an undirected graph in Raphael (unsuccessful till now) and layout it using JointJs. I am able to create an undirected graph in JointJs and layout it.
From past couple of days i have been going through Raphael documentation, did a local setup but struggling to create a graph. My basic requirement is diagramming/graph creation through Raphael and rendering it with proper layout(like in jointjs; DirectedGraph Layout). Now, this auto layout is not supported by Raphael so, i have to use an external library only for layout purpose.
Now, as far as i've worked with JointJs, it does a acceptable job but even though lets say i've graph from raphael, still not sure how will i use it with DirectedGraph Layout.
D3 was also an option but after i explored it, i could not get much about layouting. Not necessarily i should use JointJs but could be another library which can support my use case.
My main concerns are:
How to draw undirected graph in Rapahel.
How to consume the graph drawn in Raphael in JointJs (or any layouting library)
OR
Layout technique/library that would do both diagramming and layout like in image from link below.
http://s000.tinyupload.com/?file_id=10320373554237333472
Any resources/code snippet will be helpful. Thanks in advance!

Adding SVG overlay to nokia HERE map

I'm working with nokia HERE maps and I want to add an additional layer of visualization graphics on top of a map. Since the possibilities to interact, manipulate and customize the graphics created by the HERE api are limited, I would like to work with d3.js/SVG for my visualizations.
My straight forward and obvious solution would have been to just add an absolute positioned SVG element on top of the map and giving it the same dimensions. But of course that takes every possibility to interact with the map. Is there any solution to add an overlay to the map which allows me to put SVG on it while maintaining the full interactivity (panning, zooming, clicking) of the map? Also it should be possible to interact with the SVG.
I know that there is a possibility to add a custom overlay of tiles provided by a tile server to HERE maps but that's not really what I'm looking for. I'm looking for something like the solution google has to offer to this problem. A set of custom layers which are always in sync with the corresponding map and have their own initialize, draw and remove methods. Is there something similar for HERE maps?
I think you are after the nokia.maps.map.provider.CanvasProvider class. This class provides a ground overlay bound to a specific area which offers a draw() method. The attach() method is the equivalent of your intialize I think, and you can refresh the overlay using update().
Depending upon your use case, I've also found the following techniques useful regarding SVG, Images and HERE Maps:
For an SVG marker which is anchored to a point and doesn't resize
use: SVG Markers
Alternatively override the Marker class and write using the low
level graphics commands to add flexibility to the rendering of a
marker anchored to a point. Like this: Defaced Marker
To add an image bound to a specific area use the ImageProvider class
To add a series of tiled images from a TMS (Tile Map Service) use the ImgTileProvider class
Alternatively if the [zoom][col][row] is useful to you and you
want to write SVG based stuff yourself try something like this example - which combines
SVG with 256x256 pixel markers.
Note that the HERE Maps API for JavaScript only supports SVG Tiny.
A class like the old nokia.maps.map.provider.CanvasProvider isn't even available on the new v3 API from Here.
Your best bet is on Leaflet using custom providers loading Here map tiles. Then you just load this Custom Overlay class and you're all set to draw D3, WebGL, whatever you need. Leaflet only loads the tiles from the providers and exposes some simple APIs. You will not have to deal with any of the providers' APIs.
Just don't forget to add your app_id and app_code to the provider class.

Create a map with clickable provinces/states using SVG, HTML/CSS, ImageMap

I am trying to create an interactive map where users can click on different provinces in the map to get info specific to that province.
Example:
archived: http://www.todospelaeducacao.org.br/
archived: http://code.google.com/p/svg2imap/
So far I've only found solutions that have limited functionality. I've only really searched for this using an SVG file, but I would be open to other file types if it is possible.
If anyone knows of a fully functioning way to do this (jQuery plug-in, PHP script, vector images) or a tutorial on how to do it manually please do share.
jQuery plugin for decorating image maps (highlights, select areas, tooltips):
http://www.outsharked.com/imagemapster/
Disclosure: I wrote it.
Sounds like you want a simple imagemap, I'd recommend to not make it more complex than it needs to be. Here's an article on how to improve imagemaps with svg. It's very easy to do clickable regions in svg itself, just add some <a> elements around the shapes you want to have clickable.
A couple of options if you need something more advanced:
http://jqvmap.com/
http://jvectormap.com/
http://polymaps.org/
I think it's better to divide my answer to 2 parts:
A-Create everything from scratch (using SVG, JavaScript, and HTML5):
Create a new HTML5 page
Create a new SVG file, each clickable area (province) should be a separate SVG Polygon in your SVG file,
(I'm using Adobe Illustrator for creating SVG files but you can find many alternative software products too, for example Inkscape)
Add mouseover and click events to your polygons one by one
<polygon points="200,10 250,190 160,210" style="fill:lime;stroke:purple;stroke-width:1"
onmouseover="mouseOverHandler(evt)"
onclick="clickHandler(evt)" />
Add a handler for each event in your JavaScript code and add your desired code to the handler
function mouseOverHandler(evt) {};
function clickHandler(evt) {};
Add the SVG file to your HTML page (I prefer inline SVG but you can use linked SVG file too)
Upload the files to your server
B-Use a software like FLDraw Interactive Image Creator (only if you have a map image and want to make it interactive):
Create an empty project and choose your map image as your base image when creating the new project
Add a Polygon element (from the Shape menu) for each province
For each polygon double click it to open the Properties window where you can choose an event type for mouse-over and click,
also change the shape opacity to 0 to make it invisible
Save your project and Publish it to HTML5, FLDraw will create a new folder that contains all of the required files for your project that you can upload to your server.
Option (A) is very good if you are programmer or you have someone to create the required code and SVG file for you,
Option (B) is good if you don't want to hire someone or spend your own time for creating everything from scratch
You have some other options too, for example using HTML5 Canvas instead of SVG, but it's not very easy to create a Zoomable map using HTML5 Canvas,
maybe there are some other ways too that I'm not aware of.
Just in case anyone will search for it - I used it on several sites, always the customization and RD possibilities were a perfect fit for what I needed. Simple and it is free to use:
Clickable CSS Maps
One note for more scripts on a site: I had some annoying problems with getting to work a map (that worked as a graphic menu) in Drupal 7. There where many other script used, and after handling them, I got stuck with the map - it still didn't work, although the jquery.cssmap.js, CSS (both local) and the script in the where in the right place. Firebug showed me an error and I suddenly eureka - a simple oversight, I left the script code as it was in the example and there was a conflict. Just change the front function "$" to "jQuery" (or other handler) and it works perfect. :]
Here's what I ment (of course you can put it before instead of the ):
<script type="text/javascript">
jQuery(function($){
$('#map-country').cssMap({'size' : 810});
});
</script>
Go to SVG to Script
with your SVG the default output is the map in SVG
Code which adds events is also added but is easily identified and can be altered as required.
I have been using makeaclickablemap for my province maps for some time now and it turned out to be a really good fit.
I had the same requirements and finally this Map converter worked for me. It is the best plugin for any map generation.
Here is another image map plugin I wrote to enhance image maps: https://github.com/gestixi/pictarea
It makes it easy to highlight all the area and let you specify different styles depending on the state of the zone: normal, hover, active, disable.
You can also specify how many zones can be selected at the same time.
The following code may help you:
$("#svgEuropa [id='stallwanger.it.dev_shape_DEU']").on("click",function(){
alert($(this).attr("id"));
});
Source
You have quite a few options for this:
1 - If you can find an SVG file for the map you want, you can use something like RaphaelJS or SnapSVG to add click listeners for your states/regions, this solution is the most customizable...
2 - You can use dedicated tools such as clickablemapbuilder (free) or makeaclickablemap (i think free also).
[disclaimer] Im the author of clickablemapbuilder.com :)
<script type="text/javascript">
jQuery(function($){
$('#map-country').cssMap({'size' : 810});
});
</script>
strong text

How to allow the user to zoom and rotate 3D objects in Opengl and Visual C++

I am new to opengl and visual c++. I have done a sample application which rotates 3D shapes in opengl. I want to allow the user to rotate and zoom the object. Please give me an example of how to do this.
I have tried NeHe tutorial: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=48
I can't understand the class structure in the example. Is there anysimple way to achieve this?
I have found a library as well: http://www.nigels.com/glt/gltzpr/
But still can't figure out how to do this.
Please help me.
Zooming is usually done through gluLookAt. The third parameter is the view distance.
Here is some basic example running this :
http://graphics.stanford.edu/courses/cs248-01/OpenGLHelpSession/code_example.html
Look in display() to see how the viewing distance is used and in MouseMotion() to see how the value is modified and the painting updated.

Resources