Removing sections from CGMutablePath - ios

For this project, I'm using the addCurve method of CGMutablePath to draw a curve-shape on a view.
What I'm not understanding at all, is how (or whether it's even possible) to remove that exact same curve from the mutable path? Judging by the API, it looks like there are lots of methods for adding various shapes at different points, but no methods on how to remove them...

Is not possible, you may hold the elements of the original path so you can construct a new one just with the elements you want or, you can use CGPath.applyWithBlock to construct a new one selecting the wanted elements.

Related

What is the easiest way to draw line in absolute layput vaadin?

After creating absoluteLayout object what is the easiest way to draw line between two objects in that?
I would recommend not to use absoluteLayout for drawing lines, but instead one of the Canvas addons:
https://vaadin.com/directory#!addon/canvas
https://vaadin.com/directory#!addon/canvas-plus
Depending of your use-case you also want to draw whatever you are drawing directly in the client and not from the server.
For your question is very limited I can't give you more guidance.
If you still want to use absoluteLayout and drawing lines, you should go with a simple div-element (you could for example add an empty Label or whatever) and style it via CSS so it looks like a line. You won't be able to "connect" your two objects easily, though - use a canvas for that purpose.

How to assign two models to one marker in ARToolKit

I want to make two models appear over one marker in ARToolkit. The key is they much come from two separate WRL files. Is this possible?
I know this is an old question, but maybe it is useful for someone else.
The answer is yes, you can.
The way you do it is to have an empty object that is the parent of the other 2 objects and make that object trackable.
The other 2 objects can define an offset in any direction based on the position of the parent, so they will behave as a scene of sorts, keeping their relative positions.

How can I collide line with line itself?

I am following this great Smooth line drawing tutorial for my game,
http://www.merowing.info/2012/04/drawing-smooth-lines-with-cocos2d-ios-inspired-by-paper/#.U1kiCJG6_Ez
My problem is that I can't get collision of line.
If your line is a list/array of multiple line segments (which is the case for the tutorial link), As new line objects are added, check against all previous segments in your array for intersection.
This can be done rather easily, as there are multiple solutions on stackoverflow on how to detect line intersection.
In the example code, everything is just rendered on the screen. No part of a collision detection system is implemented.
For implementing one of those, one of the simplest ways is to put all the points that make up the line in an NSMutableArray, and every time you want to draw a new point, you can check it against all the points contained in the array. If the new point is already contained in the array, then you have a collision between the line and the new point you are trying to draw.
From there on, you can research standard collision systems, and implement one of those.
Cocos2D also supports 2 physics engines: Box2D and Chipmunk, both of which have collision detection of their own. For efficiency, you might want to use one of those instead of implementing your own system.

SVGKit, how to get all the layers

Being playing with SVGKit, I more or less find my way around, using code like this:
CALayer *layer;
layer=[svgView.document layerWithIdentifier:#"path1730"];
But this is when I know the identifier of the layer I want to look at.
Is there a way for me to get a list of all the identifiers (layers) in the document?
You would reference svgView.document.layerTree, which is the root of the sublayers. You'll need to recursively descend through the sublayers to catch all of them. Alternately, if you're working from a single SVGPathView, you can use its enumerateChildLayersUsingBlock: method and pass it a block that will operate on each sublayer in the view.

Drawing lines in cocos2d

I'm trying to draw lines in Cocos2d using touches.
I had a system where it would just add a small sprite where you touched, but it's working terribly. So I've been trying to find a way to draw actual lines using a method like ccDrawLine, but every tutorial I find seems to leave out something, and I just can't figure it out.
I've found this tutorial, Drawing line on touches moved in COCOS2D but I don't understand a few things about that.
It seems to reference the same variable from two different files, so I don't understand how it's doing that. (The naughtyTouchArray variable)
I can't find a complete guide on drawing lines, so sorry for the codeless question, but I'm getting frustrated.
Thanks.
The answer you've linked in your question provides good solution to your problem. There is no "two different files". Just two different methods of one layer. One method (ccTouchesMoved:withEvent:) handles touches and fill the array of points to be connected to each other one-by-one with lines. From cocos2d documentation, all drawing must be placed in the draw method of the node. So, another (draw) method just draws lines according to the given array. Cocos2d is based on OpenGL and it fully redraws scene every tick, so you cannot just draw new line. You had to draw all of them.
Or any other node can draw your array in it's draw method, so you can simply pass stored array of points from the layer, that detects touches, to this node.

Resources