Compound path inside/outside test

Is there an API for testing if a point is inside or outside of a specific compound path? I've found stuff for the length/area, but not inside outside. I supposed I could implement it myself but that kind of code tends to have a lot of fiddly <= vs < sensitivity when implementing the winding rule, and I'd rather not re-invent the wheel when illustrator is obviously already able to do this test. (Plus I could take advantage of whatever acceleration code illustrator already has for this test.)
If there's a individual path inside outside test, I don't mind tallying things up for the components of the compound path, but I didn't even find that. I'm probably just missing something obvious.
Thanks,
PS (I'm still back using CS2 since that's the suite I have and I'm unable to shell out the big bucks to upgrade.)

Well, I think the problem with that is that the hit test will also report a "hit" when you're on things like control points outside of the fill region. Now you could say "well then check the hit type and don't report a hit if it's over a control point" but then you're just in trouble because you might be over an internal control point.
So I don't think it can reliably be used for that.
I guess you might be able to make it work by manually making sure no control points are visible, and that fill is on, and then use the hit test lib. I'll look into it, but my gut feeling is that this is going to have issues. Interesting though. Thanks for the suggestion!
-Kurt

Similar Messages

  • Compound Path - determine  winding rules

    I have a compound path, and i need to parse all points, for export to CANVAS HTML , for this I wrote this script:
    But the problem is how to detect the holes. I find information, and i think that i need the fill rule or clockwise fill, but in the reference doesn't exist.
    Somebody can help me. Thanks
    Compound Path fill rules:  http://forums.adobe.com/message/4507598?tstart=0#4507598
    Nonzero winding fill rule
    Uses mathematical equations to determine if a point is outside or inside a shape. Illustrator uses the nonzero winding rule as the default rule.
    Even-odd fill rule
    Uses mathematical equations to determine if a point is outside or inside a shape. This rule is the more predictable rule because every other region within an even‑odd compound path is a hole, regardless of path direction. Some applications, such as Adobe Photoshop, use the even‑odd rule by default, so compound paths imported from these applications will use the even‑odd rule.
    http://help.adobe.com/en_US/illustrator/cs/using/WS714a382cdf7d304e7e07d0100196cbc5f-6462a .html#WS714a382cdf7d304e7e07d0100196cbc5f-644ea
    http://www.fireworkszone.com/tuts/476/fill_rules.pdf
    /*bool*/ Polygon.prototype.collideShapes = function(/*Polygon*/ _poly)
    // Ret. TRUE if the shapes intersect
    // slow method
    try {
         this.intersectPath(_poly);
         app.activeDocument.undo();
         return(true);
    catch(ex)
         return(false);
    var selection = app.activeDocument.selection;
    var a= selection[0]
    var b= selection[1]
    //alert( a.collideShapes(b))
    function inArray(agulla, paller){
        var length = paller.length;
        for(var i = 0; i < length; i++) {
            if(paller[i] == agulla) return true;
        return false;
    var item  = app.activeDocument.selection;
    var items = item[0].releaseCompoundPath();
    var restantes = items;
    var groups={}
    var i = items.length;
    //          while( i-- )
    for (var i=0;i< items.length;i++)
                        a = items[i];
                        try{
                        $.writeln( items[i].LocalDisplaySetting          )
                        }catch(e){$.writeln( e)}
    for (var s=0;s< restantes.length;s++){
    var b = restantes[s]
    if(a!=b){
    if(inArray(b, restantes)== true){
    try{
    if(a.collideShapes(b)){
    if(typeof groups[i]== "undefined"){
    groups[i]=[]
    groups[i].push(i)
    groups[i].push(s)
    restantes[i]= "void";
    items[i]= "void";
    restantes[s]= "void";
    items[s]= "void";
    catch(e){}
    app.activeDocument.undo();
    for (var t=0;t< restantes.length;t++){
    if(restantes[t]!= "void")
    $.writeln ( "_" + t +",");
    for(var g  in groups){
    var group = groups[g]
    $.writeln ("var compoundPath = new CompoundPath( _" + group.join(", _") +").fillColor = 'red';");

    I just want all inner shape and overlapping shape areas to be considered the composite fill of the compound shape - so in my example above, the three red rectangles lacking a centerpoint I want to contribute to compound path's composite fill, instead of knocking it out.
    BTW, that example up there has a big outer stroke, no fill. Maybe confusing, but that's how I'm currently using the shape (to mask the outsides of 3 different designs).

  • [Ai CS4] So I cannot convert compound path to regular paths?

    I have some complicated shapes done with the pathfinder tools, and I need to use the gradient mesh on them. But I cannot, because they are compound paths. I cannot seem to find a way to convert them to regular paths. I am almost 100% sure that there must be a way, because Illustrator :hopefully: won't expect me to redraw those with a pen tool. Or hand-draw them, scan and trace.
    Guidance please

    Doh! I guess I found my answer, a minute after I post the question.
    The problem was, I was punching holes using the "Minus Front" tool. Because there are no connection between two object's paths, Ai cannot make a single shape out of them.
    Workaround:
    Pick the line tool
    start from the inside the hole
    drag end point to outside of the shape
    and make "Divide everything under"
    Easy for the fill-only shapes, but will get a bit more complicated if I use strokes...
    Other tips are also welcomed..

  • KVC simple path vs compound path

    Hi
    According to Apple's article about KVC http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concept s/BasicPrinciples.html paths for valueForKey can be compound. I mean consist from several property names separated by dot.
    So if I want to get value of property of an object inside of one of it's accessors, than I can use [self.someproperty valueForKey:@"somevalue"]; or [self valueForKey:@"someproperty.somevalue"];
    But second does not work! It says "this class is not key value coding-compliant for the key". So what is the problem with compound key path?

    Totally different features.
    A compound path is basically an object with a "hole" or "holes" in it. (Like an O or an 8)
    A clipping path (which can also be a compound) is a mask. Parts of objects that lie outside the mask become invisible and unprintable.

  • Adding multiple paths into a compound path

    If I use the gui to add multiple paths into a compound path all I have to do is select multiple paths and choose Object->Compound Path->Make (or ctrl-8). When I do this then the bottom path which is filled has holes 'punched through' creating a window in the shape of the smaller paths which were on top of the larger one. For example, a large rectangle with a white fill color is the bottom item and two smaller paths are on top. I create a compound path and whatever is below the new compound path shows through in the largest shape of the previous two smaller paths.
    If I use JavaScript and create a new compoundPathItem and move 3 paths into it, with the largest being first, then I get a compound path but only the first of the smaller objects creates a transparent space.
    Here is a simplified example:
        var grpMask = doc.groupItems['mask group'];
        var compound = grpMask.compoundPathItems.add();
        var pathobj = grpMask.pathItems['bigbox'];
        pathobj.move(compound,ElementPlacement.INSIDE);
        pathobj = grpMask.pathItems['PathLeft'];
        pathobj.move(compound,ElementPlacement.INSIDE);
        pathobj = grpMask.pathItems['PathRight'];
        pathobj.move(compound,ElementPlacement.INSIDE);
    In the above example the 'bigbox' path has the left and right paths on top of it but only the left path creates a transparent space in the original box.
    I also tried using PLACEATEND instead of INSIDE and grouping the two smaller paths together and moving the group to the compound path.
    Merging path items together won't work - I want to keep the original path's closed and intact without drawing a line between them so I can't just add their pathpoints together.
    Is move() the best way to add existing paths to a new compound path?
    Thanks!

    Im at work at the moment so only have access to CS2 where the second script works… The first script worked at home with CS5…
    here were my test files… Before
    and After…
    As you can see with this I did not change the polarity of the last path as in this test case I knew it was the largest of the shapes not sure if that had any bearing on my results…?

  • Help needed to make a compound path of text in rectangle

    Hello, I hope some one will really solve my problem.
    Im trying to make a compound path (text inside a rectangle). I had done this previously with success but now the whole shape and text is showing same color. Although text should be transparent! And now due to the similarity in colors i cannot see any font.
    I don't know why this is happening?
    I made outlines of text, ungrouped it, released their compound paths, placed all fonts and rectangle in seperated layer and then made it a compound  path.
    Please let me know if im following all the steps.
    Also, please forgive my bad English as im not native.

    adobied,
    As you know now, Larry answered the Compound question while you were still typing.
    We do have quite a few cross postings in this busy forum, especially at this time of day with natives present both over there and over here.
    You can use Opacity Masks for a whole range of purposes, and they can act as (inverted) Clipping Masks, and also for partial/varying transparency.
    In this case, the suggested use corresponds to an inverted Clipping Mask.
    I quite understand your wish to have the Compound under control, and I believe that is sorted with the advice from Larry.

  • Can someone explain to me what are the benefits of compound path when it comes to text?  I can understand one or two lines but a whole paragraph?

    Every year we do a fundraiser to help my job, but my co-worker is getting frustrated.  We receive outside files laid out in Illustrator, but the person who does the file sets all of the text using compound path. These aren't one or two lines of text to be manipulated but whole paragraphs of text.  This person does this every year, and it is time consuming if my co-worker can't manipulate a paragraph without going to each individual layer that has a letter. Is there a way to make these compound paths merge as one without altering the document i.e. make some element disappear. Any kind of help is appreciated.

    ikaika,
    As I (mis)understand it, you should simply ask this outside person to keep all text as Live Type, using a font that you have on your machines (in the exact same version) so there will be no font substitution issue(s).
    That way, you could get the job done without silly waste of time.
    Failing to comply would seem quite uncooperative.
    I presume there is no copyright question onvolved in this.

  • Live trace, gradients and compounding paths

    I have a complex shape, and I want to have a copy behind of it that is filled.. the shape itself is a combination of stokes and fills, so a straight-out fill doesn't look good at all.. I can get it all colored the same way using live paint groups to only fill in the areas that are completely surrounded.  The problem with that, though, is a gradient will apply separately to each object, but if I make a compound path it fills in some bits of the strokes the protrude as lines into the outside (it's a ironwork sort of pattern).
    The only way i can think to do this automatically would be to color all the selections the same and then rasterize it and then live trace it so it's one object and then apply the gradient to that, but I feel there's probably a more straightforward way.  Not sure I explained that properly, if something's unclear I'll be happy to elaborate

    "The problem with that, though, is a gradient will apply separately to each object..."
    Once you get to this point, you can grab the gradient tool from the tool panel and drag across all of the filled shapes. This will make one uniform gradient seen through the many pieces of the selection.
    Give that a try, let us know how it goes.

  • Use a compound path as clipping mask?

    Hello,
    I’m trying to use a complex compound path as a clipping mask, but it won’t work. I have narrowed down the problem a little in two smaller scripts described below.
    Using a single path as clipping mask works very well:
    var doc = app.documents.add();
    var clipGroup = doc.groupItems.add();
    var bgItem = clipGroup.pathItems.rectangle(200, 200, 200, 200);
    bgItem.position = Array(200, 500);
    bgItem.fillColor = doc.swatches[8].color;
    var fgItem = clipGroup.pathItems.polygon(144, 288, 72.0, 7);
    fgItem.position = Array(220, 480);
    fgItem.fillColor = doc.swatches[7].color;
    fgItem.zOrder(ZOrderMethod.BRINGTOFRONT);
    clipGroup.clipped = true;
    alert(clipGroup.clipped); // will alert true
    But when trying the simplest form of a compound path, it’s not working:
    var doc = app.documents.add();
    var clipGroup = doc.groupItems.add();
    var bgItem = clipGroup.pathItems.rectangle(200, 200, 200, 200);
    bgItem.position = Array(200, 500);
    bgItem.fillColor = doc.swatches[8].color;
    var compoundItem = clipGroup.compoundPathItems.add();
    var fgItem = compoundItem.pathItems.polygon(144, 288, 72.0, 7);
    fgItem.position = Array(220, 480);
    fgItem.fillColor = doc.swatches[7].color;
    compoundItem.zOrder(ZOrderMethod.BRINGTOFRONT);
    clipGroup.clipped = true;
    alert(clipGroup.clipped); // will alert false
    Using compound paths as clipping masks is really simple in the Illustrator GUI. So what am I missing here?
    Help would be greatly appreciated.

    The simplest way, I think, would be to set the white line work as an opacity mask on top of the tan circle. That is not a clipping mask, but does the same thing and it's much easier.
    Otherwise, outline white strokes and "Unite" using pathfinder tool, then delete outside path (the circle), from the compound shape. That will leave the appropriate compound object to make the clipping mask:

  • Calling all compound path and clipping mask experts...

    I am attempting to get all the white areas in the attached "globe" artwork to knockout to the background color. I have tried making the entire thing a compound path, tried clipping mask and different combinations in pathfinder with no success. The image on the right is what happens when I make it a compound path. Any suggestions would be greatly appreciated, thanks!

    The simplest way, I think, would be to set the white line work as an opacity mask on top of the tan circle. That is not a clipping mask, but does the same thing and it's much easier.
    Otherwise, outline white strokes and "Unite" using pathfinder tool, then delete outside path (the circle), from the compound shape. That will leave the appropriate compound object to make the clipping mask:

  • Making a clipping group with a compound path

    So, as of today I'm new to scripting for Illustrator, I'm using the ExtendScript Toolkit. However I'm not new to scripting my own solutions and I do have some experience with JavaScript already.
    What I'm trying to do is this: For all selected Items->Duplicate selected item and make a simple clipping group with it
    What I end up with visually doesn't change the picture, but gives me a lot of clipped colored areas which I then can edit in the isolated mode, allowing me far faster and better shading. Doing that by hand takes hours on some pictures, it'd take a second with a script.
    The script itself already perfectly works for normal PathItems. As obvious in the title, as soon as I have to apply the same to CompundPathItems things stop working. My issue is somewhat similar to this old thread [Problem with compound path clipping], but I couldn't find a solution there because I get different behavior.
    When I run the very same script that perfectly works with the normal PathItems with CompoundPathItems I get this: Error 9046: The top item in the group must be a path item to create a mask
    Well that's a problem. In the GUI there is absolutely no difference between making a clipping mask with a simple path and a compound path. The reference guide has frankly not helped me with this issue at all, the only thing I learned from that is that the CompoundPathItem object doesn't have a clipping attribute, but those included PathItems do.
    Here's what I have so far:
    if ( selected[i].typename == "PathItem" ) {
    var newGroup = doc.groupItems.add();
    copy = selected[i].duplicate(newGroup,ElementPlacement.PLACEATEND);
    selected[i].moveToBeginning(newGroup);
    newGroup.clipped = true;
    As I said, this part perfectly does what it's supposed to do for normal Paths.
    For CompoundPaths I use this workaround.
    if ( selected[i].typename == "CompoundPathItem" ) {
    var newGroup = doc.groupItems.add();
    copy = selected[i].duplicate(newGroup,ElementPlacement.PLACEATEND);
    selected[i].moveToBeginning(newGroup);
    compoundItems = selected[i].pathItems;
    compoundIndex = compoundItems.length;
    for ( f = 0; f < compoundIndex; f++ ) {compoundItems[f].clipping=true;}
    var lineList = new Array(10);
    for ( l = 0; l < lineList.length; l++ ) {lineList[l] = new Array( i * 10 + 50, ((i - 5) ^ 2) * 5 +50);}
    newPath = app.activeDocument.pathItems.add();
    newPath.setEntirePath(lineList);
    newPath.moveToBeginning(newGroup);
    newGroup.clipped = true;
    newPath.remove();
    Mind you, this workaround does work in so far that it bypasses that annoying and wrong error, and the Compound Clipping Path also works, with the only problem being that the Compound Clipping Path created like this is still displayed in its original colors in the Layers section, and is still selectable. When I lock the Compound Clipping Path I can work with it but still...
    So the question is, what am I missing here? Surely there must be a proper way to do this.

    app.executeMenuCommand()? That one eluded me so far, might be just the right thing. I'll definitely take a look, now just to find a ref on that, as unfortunately the official ref documents I have don't mention that command. Any place with a list of possible commands?
    Ah, also of course I'm not only doing it for the isolation mode. If you care to hear the background, here is it:
    As I said it's for shading the pictures I'm working on. I've iterated and tried through a bunch of techniques. For example gradient meshes on my first few real works. Now those meshes don't do well with complex shapes, which previously I alleviated by using a simple square or rectangle gradient mesh and using the original colored shape as a clipping mask. That did work, but it was a huge lot of work.
    After a bunch of attempts at that I went over to using simple gradients as a background for the shape and then I'm doing the shading freehand with the blob brush tool, using a graphic style and filters to make it look right. That's better, but properly making all the clipping masks takes me much longer than anything else.
    Now the problem is that the shading is not supposed to go over the lines, which is impossible to do properly without either messing up the order, or using clipping masks, hence the script. Because you know, if you use a blob brush with a strong Gaussian blur close to the lines you'll end up with stuff on both sides. If you don't start close to the line the shading won't look right if the darkest part of the shade needs to be close to the line. And that's where clipping masks do magic.
    And finally here's an example how I work with the script and the result:
    After I have traced a sketch, adjusted the line widths and everything to look neat I turn the paths to outline strokes and then make them into a live paint group (which would mess up the line widths, unless you turn the paths into outline strokes first).
    With that live paint group it takes me just a few minutes to flat color my piece. Then I expand the live paint group, in case of doubt spend some more minutes to make compound paths from all areas I need to shade in one piece, then I select all the areas and use my script to turn them into neat clipping masks. Then I can click any area, enter the isolation mode and go up one level so I'm in the appropriate group, where I can shade freely without the problem of going over the lines.
    At the end that allows me to apply a complex and in-depth shading, without wasting any time to get there.
    PS: Well, I just found out that Draw Inside is pretty darn close to what I want to do, and oddly enough it produces the same visual discrepancy with compound paths that my script produces. I'll be taking a closer look at that, though my script does a little more than just the clipping mask stuff, so maybe I'll go for a hybrid solution. Whatever makes for a better workflow.

  • Is it possible to add an inside/outside stroke to a clipping mask?

    I'm pretty new to Illustrator so there's a chance this is a stupid question, but I'm pretty stumped on this. If I have a path with a stroke that is set to either inside or outside, it disappears if I draw something inside of it to convert it into a clipping mask. The stroke shows up again if I align it to center, but even this seems to have some quirks as it won't display multiple strokes.  After searching the web for a bit this is the best description/example I've been able to find for this problem: http://blog.rockymountaintraining.com/?p=2186.
    Does anyone know if there's a work around to get inside/outside strokes or multiple strokes to work correctly in this scenario? If not, is there a logical reason for this or is there a bug?
    Thanks for your help!

    Seems to be a long-term bug that I hadn’t noticed before.
    You can of course rectify it by copying the masking path, deselecting and pasting to front.
    Then you can give the path any stroke you like.

  • Compound Path fill rules

    I rarely want my Compound Paths to have voids where overlapping takes place, but sometimes (and it seems random) I get voids anyway.
    The Attribute Panel options don't seem to do anything.
    Am I stuck having to apply Pathfinder effects to solve this?

    I just want all inner shape and overlapping shape areas to be considered the composite fill of the compound shape - so in my example above, the three red rectangles lacking a centerpoint I want to contribute to compound path's composite fill, instead of knocking it out.
    BTW, that example up there has a big outer stroke, no fill. Maybe confusing, but that's how I'm currently using the shape (to mask the outsides of 3 different designs).

  • Compound Path Question

    Aside from using them to cut holes in shapes, are there any other reasons to create a compound path? They seem to be similar to a grouping paths so I just wondered.

    Thanks for the reference to the manual. Made things much clearer.
    I saw in the manual that you can move items inside a compound path so I tried it and found something interesting: I drew 2 rectangles, one inside the other. If you use the Group Selection tool, you can move the inner rectangle around by grabbing it by it's side or corner anchor point. If you use the Direct Selection tool, you can move it by clicking in the exact center and after that (as long as it's still selected) you can click by it's side or corner anchor point and move it. If you don't click the center first, then the Direct Selection tool will just move a side or an anchor point but not the rectangle. If that isn't interesting enough, if you are using the Direct Selection tool and hold down the Option key, the cursor changes to the Group Selection tool but if you try to grab the inner rectangle and move it, you will duplicate it instead??

  • Compound Path without border on inner path

    Hi Guys,
    I'm trying to create a shape with text that has to be transparent.
    I fixed this by creating a compound path but it inherits all the elements of the shape (which is logical) but since the shape has a border it now get an innner border as well.
    Is there a way to discard the inner border and just have the outside one?

    Or you may:
    1) With the type on top of the shape, select the type.
    2) In the Transparency panel set the opacity to 0.
    3) Select type and shape; group.
    4) With the group selected, in Transparency Panel click Knockout Group once  or twice, as needed, until the check (tick) mark appears.
    The transparency (or opacity) of the type is then infinitely variable by again selecting the type in the Layers Panel and adjusting the opacity setting in the Transparency Panel. I think (though I may be mistaken) that in CS5 it's adjustable in the Appearance Panel.
    Peter
    Hello, Jacob.

Maybe you are looking for

  • How to find out memory of a java card

    is there anyone could tell me that how can we check the size of the memory of a card? thank you in advance:D

  • Lost audio in Premiere CS4 - PLEASE HELP...

    I have been building several projects and after weeks of problems and tweaking I am finally ready to export them to their final formats and all of the sudden the audio is not playing in the time line or the export. I saw a reference that this can hap

  • Wsimport/xjc JDK 1.6: using schema-elements with underscores

    Hi, the jaxb-schema-compiler/the embedded schema-compiler used by wsimport eliminates underscores by default. You can set a binding file to influence this behavior in a special way since JAXB 2.1: <?xml version='1.0' encoding='UTF-8'?> <jaxb:bindings

  • Corrupt Logic Files over a Network

    Hi, I am running Logic Pro 7.2.3 over a network of eMacs running back to an XServe. All students have their own individual Home Folders stored back on the Xserve. The Logic Pro application lives on the local eMac. Students are regularly experiencing

  • Non-admin users can't view GAL with Outlook Connector

    Non-admin users are unable to view the Global Address List with Outlook Connector. When I give a test user admin rights (in our portal), the user can view the GAL. The VLV index is setup and functioning correctly for admin users. My versions are Dire