How to draw a circle using arcs in createjs? - easeljs

How to draw an arc in createJS. I have gone through arcTo function but its not what i want. I want to be able to draw several arcs which when put together resembles a circle.
for Ex: I want to be able to draw a circle using 8 arcs. not able to do it using ArcTo function. Please some one suggest me a way to do it.

The arcTo function draws directly from the specified point. The arc() function is what you are looking for.
Here is a quick sample that draws random segments.
http://jsfiddle.net/lannymcnie/nJKHk/
shape.graphics.arc(0,0,50,startAngle,endAngle);
here is another sample with random color fills.
http://jsfiddle.net/lannymcnie/nJKHk/1/

Related

How do I Convert an OpenLayers Polygon to a Circle?

I have a drawing feature where, as in one case, a person can draw a circle using the methodology in OL docs example. When that's saved, the server needed to be have it converted to a polygon, and I was able to do that using fromCircle.
Now, I'm needing to make the circle modifiable after it's been converted and saved. But I don't see a clear cut way to get a Circle geometry out of the Polygon tools provided in the library. There is a Polygon.circular, but that doesn't sound like what I want.
I'm guessing the only way to do this is to grab the center, and one of the segment points, and figure out the radius manually?
As long as fromCircle used sides set to a multiple of 4 and rotation zero (which are the default) center and radius can be easily obtained to convert back to a circle:
center = ol.extent.getCenter(polygon.getExtent());
radius = ol.extent.getWidth(polygon.getExtent())/2;

How to find objects with circle hole inside

Hello in the following picture i need to find objects that have circle hole inside of it.I tried to use euler number but it allowed me to find all holes not only circles.

Identify different shapes drawn using UIBezierPath?

I am able to draw shapes using the UIBezierPath object. Now I want to identify different shapes drawn using this eg. Rectangle , Square , Triangle , Circle etc. Then next thing I want to do is that user should be able to select a particular shape and should be able to move the whole shape to different location on the screen. The actual requirement is even more complex , but If I could make this much then I can work out on the rest.
Any suggestion or links or points on how do I start with this is welcome . I am thinking of writing a separate view to handle every shape but not getting how do I do that..
Thank You all in advance !!
I recommend David Gelphman’s Programming with Quartz.
In his chapter “Drawing with Paths” he has a section on “Path Construction Primitives” which provides a crossroads:
If you use CGContextAddLineToPoint your user could make straight lines defined by known Cartesian points. You would use basic math to deduce the geometric shapes defined by those points.
If you use CGContextAddCurveToPoint your user could make curved lines defined by known points, and I’m pretty sure that those lines would run through the points, so you could still use basic math to determine at least an approximation of the types of shapes formed.
But if you use CGContextAddQuadCurveToPoint, the points define a framework outside of the drawn curve. You’d need more advanced math to determine the shapes formed by curves along tangents.
Gelphman also discusses “Path Utility Functions,” like getting a bounding box and checking whether a given point is inside the path.
As for moving the completed paths, I think you would use CGContextTranslateCTM.

MapKit lines and polygons

I have a map and line (poly-line) on it. I'm trying to make a smooth polygon around this line. The problem I'm facing is how to create that polygon look smooth with rounded ends. any suggestions/solutions?
I've tried to draw another line over existing one with different thickness, but it doesn't work well with zooming...
In MKOverlayPathView which is a superclass of MKPolylineView there is a property called lineCap. Set it to
kCGLineCapRound
check here:
http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKOverlayPathView_class/Reference/Reference.html
Hope it helps.

how to draw line with animation?

I have implemented game application in which i want to draw line between two object.I have drawn line between two objects.But i want to draw with animation.can u advise me which animation i have to used between two points.
Edit:My excatly question is that:
Suppose there is two point like start point(100,100) and endpoint(300,300).I can draw line between this two point but i want to draw line with animation.I mean i can see line start from start point to end point with 2 secon duration.please help me about this question.
+1 for Brad's answer—it'll work—but it looks like you can accomplish the same thing in a more straightforward fashion by animating the strokeStart and strokeEnd properties on CAPathLayer.
See http://oleb.net/blog/2010/12/animating-drawing-of-cgpath-with-cashapelayer/
If you're looking to animate the extension of a line from point A to between points A and B, my recommendation would be to use a CAShapeLayer for this. CAShapeLayer lets you animate the interpolation between two paths with the same number of control points. For an example of this in action, see Joe Ricioppo's post on the subject.
In your case, you'd start with a path that has two control points, both the same point, and use as the final path one that has a control point at the start of the line and one at the end. The line will then animate out as if it were being drawn in a single brush stroke.