First published on MSDN on Jan, 15 2010
In a previous blog post about new ShapeSheet functions , we introduced a set of new functions called the Point Along Path functions. These functions allow interactions with geometry paths of shapes. This post provides more detail about these new functions.
The following functions open up a broad set of shape interactions for shape and solution developers:
Function/Syntax | Description |
ANGLEALONGPATH( section , travel [,segment] ) | Returns the angle of the tangent to the path at a given point. |
DISTTOPATH( section , x , y ) | Returns the shortest distance from the point represented by the specified coordinates to a point on the path. |
NEARESTPOINTONPATH( section , x , y ) | Returns the percentage of the distance along the path of the point that is nearest to the specified coordinates, as a value between 0 and 1. |
PATHLENGTH( section[,segment] ) | Returns the length of the path that is defined in the specified Geometry section. |
PATHSEGMENT(section,travel) | Returns the 1-based segment number at the specified percentage mark along the specified path. |
POINTALONGPATH( section , travel[,offset][,segment] ) | Returns the coordinates of a point on, or offset from, the path. |
SEGMENTCOUNT(pathRef) | Returns the number of line segments that make up the path. |
In the above functions:
To give you an idea of what you can do with these functions, we'll explore three examples.
We've seen shape developers create connector adornments to convey additional information. With the Point Along Path functions, this is now easier than ever to do.
Here's a simple triangle shape that sits at the midpoint of the connector, and changes direction with the connector. It works with curved and right angle connectors:
To create this adornment, you only need a few ShapeSheet formulas:
You can use the NEARESTPOINTONPATH() function to find the coordinates of a point along a path that is closest to a given point. In the picture below, the triangle shape is showing the nearest point along the path to the center of the circular shape:
Here’s how we setup the triangle to do this:
Just like the example above, you then need to transform the local coordinates, and set the PinX and PinY of the triangle so that its glued to the arc.
The above two examples illustrate how you can use the Point Along Path functions. As an application of the same concepts above, we built a curved timeline:
As you change the curve of the timeline, the milestone shapes stay attached to the curve, which allows you to create a great looking visual.
The main difference between this example and the previous one is that we’ve introduced a mechanism for automatically attaching adornments to the arc geometry. Here we turned the arc shape into a custom container to give the milestone shapes a universal reference. Since they are members of the container, we use the CONTAINERSHEETREF() function to reference the geometry of the arc. When you make multiple copies of the milestone shape, their reference to the timeline arc geometry is preserved as long as they are members of the container. (For more info on custom containers, see our previous post ).
To place the milestones accurately on the timeline arc, we used the POINTALONGPATH() function. Each timeline shape stores its own date. The timeline arc contains the “begin” and “end” dates of the timeline.
The attached VSD file includes the curved timeline, and the other two examples, so you can take a look at the formulas and play around with them.
We think these new functions will open up a new set of scenarios for shape developers. Some things you might try to create with them are:
As usual, please tell us what you think by using the Send a Smile feedback tool or by commenting on this post.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.