Now we have points for all four edges of every piece in our puzzle, offset to their correct locations. In order to make some of the knobs point inward and some of them point outward, we also randomly invert each of the second coordinates in about half of the edges. The second coordinate represents its percentage displacement perpendicular to the edge. The first coordinate of each point represents its percentage displacement in the direction of the edge. In order to make each edge’s curve easier to position, we express all points as percentage offsets from the edge’s corner. Here’s the function we’ll use to generate the control points for a single edge. This lays the basis for how we can generate random edges: slightly vary the locations for each control point within well-defined regions. (We’re using the fantastic D3 library to generate the curve from the points you dragged around.) You might have noticed that each point can move around a pretty good amount in its local region and still produce a nice-looking puzzle edge. The puzzle edge that you created is a B-spline, with control point duplication on the ends.
0 Comments
Leave a Reply. |