I'm using D3 to create sets of polygons and I'd like to be able to outline the sets. For instance, if you have a set of path elements, such as all the states of Mexico, Canada, and the United States, and you wanted to procedurally draw a border around the path elements that share the same attribute (such as their ccode) is there an established way to do this?
Obviously, I could overlay a national path, but what I want to do is be able to draw these borders dynamically based on different attributes on-the-fly, and I'm using the geo example because I think it's the most comprehensible.
if you can break up your paths so that each path is a border between exactly two regions then you should be able to simply iterate through your "borders list" to determine when to draw each one: i.e. draw a border that has exactly one match in your list of states-to-highlight. Borders with two matches are interior and borders with no matches do not belong to the regions you are interested in.
Related
I am building a game where 8 players are spawned in an arena and each has their own color and they are suppose to roam around the arena(the blocks they walk on change to the player's color) with the purpose to fill as much of the arena's ground with their color.
When they create a shape they inside of the shape is also supposed to change to their color but I can't think of a way to actually implement this so I would really appreciate some help.
I broke down the process of implementing this into 2 steps:
Identify when a shape is created
Find all the blocks that are inside the perimeter of that shape an fill them
An example for shape that I would like to fill(The blue blocks are supposed to be the perimeter of the shape
I've been asked to build something similar to this so that customers can draw basics shapes of kitchen tops. Similar to that in the image below but also have dimensions.
It looks like konva has support for basic shapes like rectangle and circle etc and it also includes a transformer which allows for resizing. However, I think if I want to build a custom shape like the one in green and have individual sizing i.e. resize each individual line. I am going to have to build something myself.
I was hoping someone could point me in the right direction. I have seen an example where someone has used a "line" class which takes a series of points and then sets the attribute to closed which fills in the shape. Obviously I would need to extend this to allow the custom resizing. However, Im not sure this is the correct path to head down?
Any suggestions?
.
How about using rectangles and having an option to snap them together. It should be fairly simple to do the edge detection and snapping. Then show the result as a Konva.Line around the perimeter.
Then you can show all the control handles for the rectangles except those on the sides where another Rect has joined.
For a game that's similar to Qix, Volfied, Paper.io and splix.io, where you need to encircle an area to capture it, I'm struggling to find proper way for AI to detect valuable territory features to capture.
The image below presents 9 examples of territory fragments of a bigger map, where the blue color is territory owned, black color is empty area that need to be captured, green and white points need to be calculated, so AI could pass through them to actually capture territory.
This can also be formulated as: how to find shortest path that encircles as much of empty area as possible?
Maybe a contour tracing algorithm could be used??
There are many ways to check is point inside path, but i haven't found any algorhitm which can check if the circle(whole object, not center point) is inside svg path.
If you're wondering why I need this algorithm - i want to fill space with circles with different radii (http://bl.ocks.org/mbostock/1893974), and those circles that enters the shape i want to paint in another color. As a result, we get the test image for color-blind people, like Ishihara's pictures.
The expected result like on that picture.
This a collition detection algorithm or intersection.
Step 1
Fill with cirlcles you base shape
Step 2
Create the main shape
Step 3
Detect interserct and color the shape behind. And hide the main shape
Pros: You can add dynamically shapes, animate or change it on the fly.
For an implementation look here
I would like to know, if there is existing code or best practices to realize ordinal axis with a certain hierarchy. Perhaps a example shows, what I mean. I try to realize a Business Support Map like shown in the following image (the upper part, without the legend):
In essence this is a X-Y matrix with cells. The cell coordinates (Acquisition, Headquater, etc.) define the parent layer of the hierarchy. Within each cell there is child ordinal hierarchy of the cell elements. Later on pan and zoom, as well as the addition of layers, which show KPIs, indicators and aggregated data should be easy.
What is here a good combination of scale and axis? Is it easier to build a custom layout?