I'm trying to do following action using CS6 SDK:
1 Covert the selected path into chained circles
2 Fill the selected shapes with circles
All circles are of equal size, and cannot be overlapped each other.
Any reference/suggestions? thanks
For the first question to replace a path by circles, you could do:
Get the length of the path with the MeasureSegments function in AIPath.h.
Calculate the centers positions. Divide the length of the path by the number of circles and use functions like
GetPathBezier (from AIPath.h) and TAtLength, PointAndTangent (from AIRealBezier.h).
When you have the positions of the centers, you create the circles.
To fill a shape with circles, I have no idea.
Thanks JLG for your reply, which is very helpful.
I just realize to address my 2nd question, basically I'm facing a 2D circle packing question, which is a NP hard question, and looks currently there is no elegant solution at AFAIK.
So I'm thinking about some alternatives, like to transform a shape into equally spaced contour lines (which ends in the boundary of a shape), then covert lines into circles. Then, my question becomes how to convert a shape into equally spaced contour lines?
Can you use a pattern brush and fill pattern? If I understand your problem correctly a brush would "replace a path" and a fill pattern would "fill a shape." You could create these assets in the document or perhaps have your plugin create them. Then have the plugin apply them to the path.