[cairo] Two closed path problems

Andrew Ellis andrewjellis at hotmail.com
Sun Aug 28 05:37:38 PDT 2011


I have two challenges with closed paths, which may not be Cairo problems, but the output from the algorithms I must find will be drawn using Cairo, so I'm wondering if it can be used to save me some programming effort.
(A)I have a closed shape representing some physical object.  The application represents the shape as (1) a collection of straight lines, each joining two points [x1,y1] and [x2,y2], and (2) a collection of (circular) curved lines, each with a circle centre point [xc, yc], a radius r, and starting and finishing angles theta1 and theta2.  I have a routine which can calculate how to order the lines, both straight and curved, to produce a path defining the shape, which I will then draw using Cairo.  No bezier curves are involved (so far, but I may have to think about that one day...)  The shape is not necessarily regular, and the application's user defines his own objects and draws their shapes.  Simple stuff so far.
The entire object may itself be rotated.  There is an axis centre point [xa, ya], and a rotation angle thetaR.  I need to find the closed path representing the area swept by the object as it rotates between the two positions.
I'm part of the way there.  I already have routines for some of this:If I create a rotated copy of the shape, and intersect that with the original shape, and also with a collection of new curved lines each defining the movement of vertices as they move between the two positions, I now have a shape with many straight and curved components.  I need to find the outermost components of this shape, and pass these into my routine for ordering them and producing the path.  This last step is something I haven't figured out how to do.  Any suggestions?
(B)Some objects are provided by the user as bitmap images.  Perhaps they originated as photographs.  There will be an area of the (rectangular) bitmap around the outside of the object itself which is 'transparent', and each transparent pixel has the same colour.  I need to generate the path defining the edge of the object itself, i.e. the outer extent of pixels which have some other colour than 'transparent'.  I'm sure someone must have tackled this problem already.
I'm quite green with Cairo.  I mentioned when joining the list, I'm using a wrapper DLL which gives me access to its functionality from applications written in 'classic' VB.
Andy 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20110828/05e5a99d/attachment.htm>


More information about the cairo mailing list