Shape path iterator

I have searched the forum to no avail, and have only found one tutorial that gets remotely close to what I am trying to do (i.e. http://www.developer.com/java/other/article.php/626101)
Here's the jest:
I've got a circle that has a linecoming out of it. Each line connects to the end point of the previous one, so if you will, think of this as one big connected path made of up lines of variable size.
Currently my circle class extends Ellipse2D.Double and houses a global LinkedList that houses the lines. Everything works perfect, BUT NOW I need to figure out some way to have the circle move along this proverbial connected line. Here's what I have attempted in much simplified form:
ListIterator lineIterator = currentCharacter.lineList.listIterator();
while (lineIterator.hasNext())
  StraightLine currentLine = (StraightLine)lineIterator.next();
  // here it draws the line on the screen
  generalPath.append(currentLine, true);
}I won't even both including my feable attempt at getting it to work with a PathIterator other than the following statement which instantiates the iterator:
PathIterator path = generalPath.getPathIterator(null);Can someone please point me in the right direction. I would like for the circle to move position by position in the current segment before moving on to the next, AND not just move segment to segment. I'm having a real hard time understanding the PathIterator interface, so if anyone could give me a few pointers, I'd be much obliged.

Here is an updated code sample for those who are helping. Unfortunatly, this sample gets the wrong locations it seems for the x and y iteration points:
               while (it.hasNext())
                        StraightLine currentLine = (StraightLine)it.next();
                        // Gets the line's coordinates
                        int x1 = (int)currentLine.x1;
                        int x2 = (int)currentLine.x2;
                        int y1 = (int)currentLine.y1;
                        int y2 = (int)currentLine.y2;                                  
                        // Temp storage variables
                        int x = 0;
                        int y = 0;
                        // Calculates the slope
                        int numerator = (y2-y1);
                        int denominator = (x2-x1);
                        int slope = 0;
                        if (denominator != 0)
                            slope = ((y2-y1)/(x2-x1));
                        // Calculates the y-intercept
                        int b = y2 - (slope*x2);
                        Vector xCords = new Vector();
                        Vector yCords = new Vector();
                        // Gets the Y coordinates
                        if (x1 > x2)
                            for (int i=x1; i > x2; i--)
                                y = (slope * i) + b;
                                yCords.addElement(new Integer(y));
                        else if (x1 < x2)
                            for (int i=x1; i < x2; i++)
                                y = (slope * i) + b;
                                yCords.addElement(new Integer(y));                           
                        else
                            y = (slope) + b;
                            yCords.addElement(new Integer(y));
                        // Gets the X coordinates
                        if (y1 > y2)
                            for (int i=y1; i > y2; i--)
                                x = (slope * i) + b;
                                xCords.addElement(new Integer(x));
                        else if (y1 < y2)
                            for (int i=y1; i < y2; i++)
                                x = (slope * i) + b;
                                xCords.addElement(new Integer(x));                               
                        else
                            x = (slope) + b;
                            xCords.addElement(new Integer(x));
                        for (int i=0; (i < xCords.size()) && (i < yCords.size()); i++)
                            System.out.println(xCords.elementAt(i) + " " + yCords.elementAt(i));
                            selectedCharacter.x = Integer.parseInt(xCords.elementAt(i).toString());
                            selectedCharacter.y = Integer.parseInt(yCords.elementAt(i).toString());
                    }

Similar Messages

  • Can I isolate part of a shape path to simplify if?

    Hello, I want to simplify part of a complex shape.  Is it possible to isolate part of a shape path and simplify it, leaving the rest of the shape with the original number of anchor points? Thank you

    drive,
    Maybe redrawing it is the solution.
    Always keep (a copy of) the original artwork before you start destroying it, hidden or locked or elsewhere.
    You may plunge (deeper) into using the Pen Tool.
    In this case, you may (Smart Guides are your friends):
    0) Lock the path;
    1) ClickDrag from one of the end Anchor Points (Smart Guides say anchor when you are there), dragging the Handle in the direction of the path;
    2) ClickDrag from the other end Anchor Point, away from the path, dragging the Handle in the direction of the path.
    You may drag back and forth in 2), and you may switch to the Direct Selection Tool and ClickDrag either Anchor Point to adjust afterwards.
    This may be enough, depending on the shape, of course.

  • Convert Mask path to shape path?

    Can I convert a Mask path into a shape path in AECS4?
    I am running into a problem with resizing my layers - I am animating a signature, and part of it was done as a shape, part of it as a mask that 'reveals' a signature (someone else created the original) when I try to enlarge the whole thing, only the shape portion enlarges without artifacting (vector) the mask portion gets blocky and ugly if enlarged.

    The After Effects CC (12.2) update makes creating Bezier paths easier and more obvious.
    option for creating shape layers based on Bezier paths:
    When a shape tool (Rectangle, Rounded Rectangle, Polygon, Star, or Ellipse tool) is active, you can use the new Bezier Path option in the Tools panel to create a new shape based on a Bezier path, as opposed to the default of creating a new shape based on a parametric path. Holding the Alt (Windows) or Option (Mac OS) key while drawing a shape causes the opposite behavior—i.e., if the Bezier Path option is enabled, holding the Alt or Option key causes the shape tool to create a parametric path; if the Bezier Path option is disabled, holding the Alt or Option key causes the shape tool to create a Bezier path.
    command for converting a parametric shape layer path to a Bezier path:
    You can convert a parametric path to a Bezier path after the parametric path has already been created by context-clicking (right-clicking or Control-clicking on Mac OS) the property group for the parametric path (e.g., Rectangle Path 1) and choosing the Convert To Bezier Path command from the context menu. If the parametric path is animated (keyframed), the converted Bezier path is a static path based on the parametric path at the current time; keyframes are lost.
    IMPORTANT: When you use the Convert To Bezier Path command to convert a parametric shape path to a Bezier shape path, the Bezier path that is created does not animate well (i.e., interpolation between paths behaves strangely and unpredictably). This is related to path direction and how transformations are stored. For now, you should not use these converted paths for animated paths (interpolation between paths); but, if you do want to try, you may be able to work around the issues by reversing the path before conversion.

  • How to retrieve "KeyValue" from multiple Shape paths then "SetValue" to Mask path Keyframes?

    Hello AEScriptsComm.,..
    i have one question (hopefully the tutorer will answer soon), which is the goal and reason i'm learning ExtendScripts:
    I have a few dozen Adobe Illustrator, imported Shape Layers with paths "Created..from Vector Layers" in AEffects.
    In order to use a .jsxbin script to change every path to the same number of verticies for animating, i must 1st convert them to Keyframes on the same Mask Path property.
    1) i hoped to please be shown\sent an example showing how to,..
    a) Get\Retrieve "KeyValue" from multiple, single (Shape Layers):Outlines > Contents > Group > Path > Path as shown in screenshot "4-CreateShapeFromVecLyr2Outlines.JPG",
    and then,..
    b) "SetValue" from those paths into Mask > Mask Path keyframes also in screenshot "1-ExtendScript_ShapePathsTOMaskPathKeyframes.JPG"?
    Really appreciate any help soon as time allows,
    Jeff

    Hello Xavier,
                       esp. with my limited experience i can't determine how your concise script works.
    Because it 1st errors  esp. with undefines  i'm thinking at best its incomplete (or algorithm) to give me the gist and i'm to fill in the blanks, which i am doing with the sort of working code example pasted below.
    Its written with every  definition, declaration and initialization completed, so a novice like me can read the manuals, rev. eng. pertinant script(s), then with fragmented code and understanding quickly connecting to form a complete custom script, as we've all done.
    like this:
    var comp = app.project.activeItem:
    var layer  = comp.layers.addSolid([1,1,1,], layerName, comp.width, comp.height, 1.0, comp,duration);
    therefore,..
    var CompLayerSolid = app.project.activeItem.layers.addSolid([1,1,1,], layerName, comp.width, comp.height, 1.0, comp,duration);
    ..then with such direct access in other essentials, i can substitute compatible properties, methods,  parameters etc. and remaining code that affect the layer objects i need to control simultaneously. Also thereby learning more complex code quickly enough to use.
    Only, i hoped to save time here by those already familiar.
      But by comparison your script without declarations or many references in AE's CS6 Scripting Guide and online, i can't decipher or understand,
    although you wrote this more complete segment at CCow:
    "shapeLayer.content.addProperty("ADBE Vector Graphic - Fill");",
    ..in which is the addProperty i 1st looked for in your script after erroring with "ShapeLayer is undefined"
    But i could'nt find a ref. to either .content or content. anywhere in ExtendScript, nor "targetLayer.mask", and "targetLayer" i found once in ref. to ExtendScript as an AE layer name. So perhaps their your variables?, you see i can't determine or use.
    i don't know that was'nt meant, maybe a bit to tell me do my own research?,  no offence, can't confirm that without reply, hope you will, but my research is why i'm here and your probably advanced script could only help with your assistance.
    Thanks anyway,
    Cheers.
    function()
    var comp = app.project.activeItem;
    var masksLayer = comp.selectedLayers[0];
    var masksGroup = masksLayer.property("ADBE Mask Parade");
    app.beginUndoGroup(rd_MasksToShapesData.scriptName);
    // Create an empty shape lay
    // Get the mask layer's pixel aspect; if layer has no source, use comp's pixel aspect
    var pixelAspect = (masksLayer.source != null) ? masksLayer.source.pixelAspect : 1.0; //copixelAspect;
    // Iterate over the masks layer's masks, converting their paths to shape paths
    var mask, maskPath, vertices;
    for (var m=1; m<=masksGroup.numProperties; m++)
    var suffix = " Shapes";
    var shapeLayer = comp.layers.addShape();
    shapeLayer.name = masksLayer.name.substr(0,31-suffix.length) + suffix;
    shapeLayer.moveBefore(masksLayer);
    var shapeLayerContents = shapeLayer.property("ADBE Root Vectors Group");
    var shapeGroup = shapeLayerContents; //.addProperty("ADBE Vector Group");
    //shapeGroup.name = "Masks";
    var shapePathGroup, shapePath, shapePathData;
    // Get mask info
    mask = masksGroup.property(m);
    maskPath = mask.property("ADBE Mask Shape");
    // Create new shape path using mask info
    shapePathGroup = shapeGroup.addProperty("ADBE Vector Shape - Group");
    shapePathGroup.name = mask.name;
    shapePath = shapePathGroup.property("ADBE Vector Shape");
    shapePathData = new Shape();
    // ...adjust mask vertices (x axis) by pixel aspect
    vertices = new Array();
    for (var v=0; v<maskPath.value.vertices.length; v++){
    vertices[vertices.length] = [maskPath.value.vertices[v][0] * pixelAspect, maskPath.value.vertices[v][1]];
    shapePathData.vertices = vertices;
    shapePathData.inTangents = maskPath.value.inTangents;
    shapePathData.outTangents = maskPath.value.outTangents;
    shapePathData.closed = maskPath.value.closed;
    shapePath.setValue(shapePathData);
    shapeLayer.transform.anchorPoint.setValue(masksLayer.transform.anchorPoint.value);
    shapeLayer.transform.position.setValue(masksLayer.transform.position.value);
    shapeLayer.transform.scale.setValue(masksLayer.transform.scale.value);
    if (masksLayer.threeDLayer)
    shapeLayer.threeDLayer = true;
    shapeLayer.transform.xRotation.setValue(masksLayer.transform.xRotation.value);
    shapeLayer.transform.yRotation.setValue(masksLayer.transform.yRotation.value);
    shapeLayer.transform.zRotation.setValue(masksLayer.transform.zRotation.value);
    shapeLayer.transform.orientation.setValue(masksLayer.transform.orientation.value);
    else
    shapeLayer.transform.rotation.setValue(masksLayer.transform.rotation.value);
    shapeLayer.transform.opacity.setValue(masksLayer.transform.opacity.value);
    // Match the mask layer's transfor
    // Mute the mask layer
    masksLayer.enabled = false;
    app.endUndoGroup();

  • Shape/Path - transform/convert -bug?

    I have noticed a few subtle UI changes in PShop CC -some of which seem like bugs. Here's one:
    When I apply "transform" to a newly created Elipse path (which has been pre-specified as a path), I get this prompt:
    "This operation will turn a live shape into a regular path. Continue?"
    But the elipse I have created is NOT a shape. The Path option has alrady been selected. Yes, this is a very minor quibble, but as a former beta (and alpha) tester, I tend to be compulsively thorough! OTOH, perhaps there is a user error on my part. I did double check that new paths created with elipse tool are spec'd as "paths".
    thanks

    There are some issues with the new shapes.  I'm not 100% sure on this but they now have "Live shapes" where you can set some of the shape/path properties like how rounded the curves are on a rounded rectangle.  So I guess the elipse also has some "Live" properties.  However, once you transform the shape/path, you lose the ability to edit those properties and the shape/path becomes a regualar shape/path.  I suppose it would be good for them to specify in the alert what exactly on what you working - path or shape.

  • Add an inertia script to mask/shape-path keyframes?

    anyone knows how to add an inertia script to mask/shape-path keyframes? OR a workaround that would yield similar results?
    thanks
    manojit

    Since no answer seems to be forthcoming would you recommend that this be a manual test?
    Thanks,
    Eric

  • Reference a Shape Path as Text Path

    Hi!
    Is it possible to reference a shape path from a shape layer as the path for the text to follow?
    regards
    Henning

    I think you simply want to use a shape layer's path as a path for your text to follow.
    If there is no scaling applied to the shape layer then you can copy the path by setting a keyframe for it then start a mask on your text layer using the pen tool and putting the first point anywhere and then doing a paste. You can now reveal the text layer's properties and set the path options to the new path. This works best if you use the pen tool to draw your shape layer path, then add a text layer using New>Text Layer and typing the text. If you just click in the frame and start typing or you move or scale your shape layer you will run into position problems because the paths will not line up.
    If you use the shape tools (rectangle, polygon, etc.,) you will have to convert the shape to a path before you start. You can do this by right clicking on the path. Here again, if your path is not in the center of the comp you'll have position problems that you will have to adjust. The most efficient workflow if you were using the shape tools would be to hold down the Alt/Option key before you start dragging out your shape so that it creates a bezier path instead of a shape. This would solve position problems. If you have already created the shape layer with a shape tool then center it in the comp and parent the shape layer to the text layer so you can reposition them both later.

  • How To Edit A Shape Path

    A PS newbie here. I am trying to follow THIS TUTORIAL  and am getting hung up at this point where the author adds anchor points to a rounded rectangle:
    There is not a lot of explanation about how to do this in the tutorial. I know how to add anchor points when using the Pen Tool, but getting the shape to exhibit the path is eluding me.
    Can anyone help?

    Thanks for the answer.
    So I guess this is where I'm losing it because I've worked w. the Pen Tool a little in the past and using the Direct Selection Tool is exactly what I'd think would be called for. But it's not doing anything for me. I create a brand new layer w. a brand new rounded rectangle, hit Ctrl+A and make sure its the white arrow (not black), then click on the newly created solid black rounded rectangle. There isn't actually a "path" or an outline. And none ever appears no matter where I click.

  • Cutting a shapes' path from a shape group

    hi guys!
    Im quite a new user of illustrator so my problem may be noobish, but please be kind and help me.
    I want to make the A shape as if it was composed from the grouped hexagons from B. the hexagons from B are grouped and the shape from A was made from two elipses and function Minus Front prom pathfinder.
    I 've tryed all the functions from pathfinder in all ways but some don't give a result(I don't need explanation for this) and some do not work as I wish.
    I hope you understand what I want to create, and will help me. Thanks

    With the Clipping Mask selected go to Object>Clipping Mask>Edit Contents to be able to change the color of the masked objects.
    Here's what ti looks like with the Edit Contents

  • Changes in Options Bar for Paths and Shapes

    Wow, I love the changes to the options in the Options Bar when using the Shape Tools.
    Having Width and Height fields right there at top is FANTASTIC. (I used to have to open the Info Panel and watch the height and width as I transformed shapes.) This is MUCH better. A dream for web designers.
    I also appreciate the Geometry Options getting a big gear icon. Easier to click on than CS5's microscopic arrow icon. Nice!
    Shape/Path/Pixel selectors are no longer upfront icons and are hidden behind a dropdown you have to pay for with an extra click. Not sure how I feel about that. But I do appreciate the text clearly declaring what you have selected right now. I think many icons just slow me down anyway because I have to look at them for a second longer to figure out what the hell it is.
    I'm a tad annoyed that the path operations and align functions have be hidden behind a single buttons (extra clicks again). Not a deal-breaker though.

    I've found that I am growing more fond of always making a path, then clicking the button that turns it into whatever I need (e.g., Selection / Mask / Shape).
    -Noel

  • How do I move or copy a shape layer's path to another layer?

    i'm looking how to apply an existing vector shape from a layer to another, before it was simple as hell just by alt + drag 'n drop from a layer to another.
    But now this command doesn't work anymore ? so how i can do it ? i need to simply apply a vector clipping mask to a bitmap layer or a group or just apply a shape to another vector layer (not the blending option)
    why it's not anymore possible ? it was simple and easy since CS1 or 2 why have you changed that ?

    It's unclear to me from your keyboard shortcuts whether you are on Windows or Mac, so here are the keyboard shortcuts for both platforms:
    Command-drag (Mac)/Ctrl-drag (Win) the shape layer thumbnail to move the shape path to another layer.
    Command-Option-drag (Mac)/Ctrl-Alt-drag (Win) the shape layer thumbnail to copy the shape path to another layer.
    We had to make this slight change since there is no longer a separate vector mask thumbnail on shape layers.
    For non-shape layers with a separate vector mask, the old keyboard shortcuts should still work for moving/copying the vector mask.

  • Can one select the path of a shape layer?

    I previously have created a "route" on a map using the stroke filter which allows me to select the path and then copy it into the anchor point of the map so I can make the map move with the stroke.
    I was wondering if this is possible using shape layers. I know I can create the route using an open shape on a shape layer, but I'm not able to select the "open shape" to paste this into the anchor point as above. Is it possible to select the "open shape" to use it in this manor.
    Sorry if I'm not clear.
    Thanks in advance.
    John Rich

    The After Effects CC (12.2) update makes creating Bezier paths easier and more obvious.
    option for creating shape layers based on Bezier paths:
    When a shape tool (Rectangle, Rounded Rectangle, Polygon, Star, or Ellipse tool) is active, you can use the new Bezier Path option in the Tools panel to create a new shape based on a Bezier path, as opposed to the default of creating a new shape based on a parametric path. Holding the Alt (Windows) or Option (Mac OS) key while drawing a shape causes the opposite behavior—i.e., if the Bezier Path option is enabled, holding the Alt or Option key causes the shape tool to create a parametric path; if the Bezier Path option is disabled, holding the Alt or Option key causes the shape tool to create a Bezier path.
    command for converting a parametric shape layer path to a Bezier path:
    You can convert a parametric path to a Bezier path after the parametric path has already been created by context-clicking (right-clicking or Control-clicking on Mac OS) the property group for the parametric path (e.g., Rectangle Path 1) and choosing the Convert To Bezier Path command from the context menu. If the parametric path is animated (keyframed), the converted Bezier path is a static path based on the parametric path at the current time; keyframes are lost.
    IMPORTANT: When you use the Convert To Bezier Path command to convert a parametric shape path to a Bezier shape path, the Bezier path that is created does not animate well (i.e., interpolation between paths behaves strangely and unpredictably). This is related to path direction and how transformations are stored. For now, you should not use these converted paths for animated paths (interpolation between paths); but, if you do want to try, you may be able to work around the issues by reversing the path before conversion.

  • Flattening paths/shapes together

    Hi there,
    Still a bit of a newbie at Illustrator but would be grateful if anyone could help.
    I've cobbled together a few different shapes to make a bigger one and want to outline the whole shape not each individual one.
    Is it possible to somehow flatten the shapes/paths?
    I've attached a few images to show the problem.
    Many Thanks

    You want the outline around all of them?
    Then group them.
    Open appearance panel.
    Make new stroke for the group
    Move stroke below "Content"

  • Trying to subtract a complex path from another, can't get the result I need

    I'd really appreciate some help on this. I'm not familiar with illustrator and am stuck trying to accomplish what I hope is an easy task. I've uploaded my .ai here just in case anyone can help.
    I have two layers, one is a collection of lines/paths which make up a line drawing of a tree, then the layer above that is a bunch of paths using a 'distressed' brush. I've read several tutorials on using the pathfinder tool to subtract one from the other but every time I'm left with way more of the tree deleted than I want. I tried a simple test case (subtracting a single distressed path from a rectangle shape) and it worked as expected. I don't know why this one isn't working other than maybe it's just too complex.
    On the left (tempoary red background) is what my layers look like, on the right is the effect I'm trying to achieve (the white parts removed from the black parts). I need this to end up being a vector so it can get cut out of a vinyl decal.
    Thanks a ton for any help, I'm really stuck on this as I spent 99% of my time in photoshop.

    That worked perfectly, thank you. I selected everything on the tree layer, made compound path, then did the same on the texture layer. Then the subtract worked great.
    Just so I understand what's going on here - make compound path means take all the selected stuff and make it into one single shape/path, vs. having a bunch of separate paths on the same layer?
    Really appreciate your help, thanks again.

  • Illustrator converting paths to embedded images

    I have a funky issue that I've come across. I have several files that were made using Illustrator CS3. There is a particular type of path item in them (a basic shape path with gaussian blur applied to them) that when I open up the file using CS6 that path item is treated by Illustrator like it's a embedded image.
    I've remade those items as an actual path item with gaussian blur applied, and all seems fine until I save and re-open the file, they become embedded images again. I'm thinking it might be an issue with a setting somewhere but I'm not finding it.
    I have several files of the same type that don't have this issue but I'm not finding any difference between them. At this point I'm stumped...any suggestions?

    After playing around with things for a while I've learned that what I must do is choose "Save as..." with the file, then it will change it to a CS6 file and the world seems happy, but because I had warning dialogs supressed it wasn't alerting me to the fact that the file still was a legacy file when I simply saved, and when I chose "Save as..." I just wasn't making it far enough to get to the dialog where I got to change the file type. Again, most of the files (which were all created at the same time) were not having this issue which was why it was confusing...

Maybe you are looking for

  • Java.lang.NullPointerException when connect to the J2EE engine

    I want to connect to the J2EE engine ,but the error message "java.lang.NullPointerException" is displayed in the console.  Please help me ! Thank you !!  The full error exception like this: java.lang.NullPointerException         at com.sap.engine.ser

  • IR Report Group by issue

    Hi, I have application built in Oracle Apex 4.1. It has several Interactive Reports. IR having functions like Sort, Filter, Grouping etc. All these are working fine except Group By function. I can select Group by function, even select column and func

  • Displaying Footer on last page of report

    Hi: Is there a way to display the footer only on the last page of a report? For example, if I have a three-page report, I need the footer to be displayed on the third page only. Any help would be greatly appreciated. Thank you kindly. Sincerely, Dine

  • Query to find the the free space in raw disks

    I am new to ASM. What is the query to find the free space in the raw disks in ASM diskgroup.? Can i get space info about individual raw disks in the disk group? Is there an ip address for the ASM disk group? If so how can i find it?

  • My first Kernel Panic, what should I do?

    I've had my new MacBook Pro (17" 2.33 GHz, 2GB ram) since April 14, 2007 and I had my first Kernal Panic today. Since Apple Care is now closed for the day, I was wondering if anyone knows what I should do--if I should talk to Apple Care about this ye