accionlabs / isometric-compiler-ui

Isometric Diagram Compiler UI
2 stars 0 forks source link

layer component should have option to set offset #7

Open AnirudhaGohokar opened 1 week ago

AnirudhaGohokar commented 1 week ago
bijoor commented 1 week ago

Providing any kind of physical locations or offset is bad design as it removes the independence of the shape geometry from the svg and hence from the designer's control.

We should realize that this issue will come up for those shapes that are designed primarily to create components, and are not meant to be used as individual shapes in diagrams - such as the layer parts.

Keeping this in mind, we can consider the solution to add an additional attachment point in such shapes that is used for parent components. For example, we can define a special attachment point in such shapes named as parent-attach-front-left or parent-attach-front-right etc.

Now when we create a component, we may find multiple such parent attachment points, while we actually need only one. To resolve this, we collect all parent-attach-[position] points and then find the middle of all the locations (sum of x/y coordinates / number of points).

parent tile-b3

See the above example of parent-tile-b3.svg where I added a new attachment point called parent-attach-front-left.

Now imagine that we add two such tiles to create an overall layer. So you will get the following:

parent tile-b3-component

In the above diagram, you can see that there are two tiles with the same parent-attach-front-left points. When we get the mid point of these two, we will get the coordinates of the attachment point attach-front-left for the parent component.

This will work similarly if we have multiple such tiles (more than 2). And the same logic will work for other attachment points.