Inkcanvas Stroke Top,Left,Right,Bottom Location - inkcanvas

In inkcanvas I can able to draw the stroke ,where i want to find the location(Top,Left,Right.Bottom) of the stroke.
If the stroke is drawn at the Top of the inkcanvas control,then stroke location is at Top.
How to find this as i am using getBounds() it is not helping me to find the Top location of the drawn Strokes

GetBounds() is working for me. In my case I'm intercepting the InkCanvas StrokeCollected event and doing:
Rect bounds = e.Stroke.GetBounds();
It gives me the top, left, right, and bottom.
If you need the locations of individual points such as the first or last, you can use the StylusPoints property of the collected stroke to access them.

Related

How to find radius of drawn shape in MKMapView

I am stuck with an issue,
I have drawn a shape in map view and even get the center coordinate, the thing which is left to be found is the radius from the center coordinate.
if anyone could help me out.
This is the shape I have drawn, the annotation is the center point, Need to find the radius and then draw a circle on it
Here is the image :
The above issue is resolved, now i need to find the difference in space between circle border and polygon border so that when my server returns data i can only show pins on the polygon.
Here is the image :-
https://i.stack.imgur.com/tezWr.png

clear part of UIImage

I've been doing some research on online for a project I'm doing but so far haven't been able to quite get it working. I want to be able to slide my finger over a UIImage and delete part of it, kind of like an eraser. I'm able to draw lines on the screen but can't figure out how to do this. Any help would be greatly appreciated.
Can you mask the image and when you draw on it, it adds the lines to the mask (in white, rest of mask is black) and then it should make those spots transparent
http://iosdevelopertips.com/cocoa/how-to-mask-an-image.html
There are two parts to this problem-
a) Determining the curve along which the finger was moved
b) Drawing the curve (which is really a combination of short lines) with the white color
For part (a), have a look at UIPanGestureRecognizer. Using the touchesBegan: & touchesMoved methods, you will be notified every time the finger moves even the smallest distance, and the source and destination co-ordinates, say (x1, y1) & (x2, y2).
Part (b), As you know how to draw a line, now you need to draw a line from the source to the destination with the line's width (thickness) equal to the finger's. For that you can set the line's width using CGContextSetLineWidth.

MKCircle - Stroke Width equivilant to meters

I have a MKCircle. I would like to be able to set a stroke width equivilant to meters not points. So that I can draw an overlay with both radius in meters of a stroke width in meters.
I understand that the points to meters relationship changes whenever the map is zoomed. I have a very low annotation count (1) right now so removing and readding it on zoom should be OK if I can figure out a way to calculate the desired stroke width in points for a meter distance at a given map state.
The first thing to consider is whether you really want to do this: the line could wind up being invisibly thin if the user zooms out.
The only way I can see to do it is to create an appropriately-sized MKCoordinateRegion using MKCoordinateRegionMakeWithDistance and then use MKMapView's convertRegion:toRectToView: to convert it to a CGRect, from which you can read out the width/height to calculate the appropriate line width.

Clipping in MKOverlayView:drawMapRect

I'm having an issue with drawing to areas outside of the MKMapRect passed to drawMapRect:mapRect:zoomScale:inContext in my MKOverlayView derived class. I'm trying to draw a triangle for each coordinate in a collection and the problem occurs when the coordinate is near the edge of the MKMapRect. See the below image for an example of the problem.
In the image, the light red boxes indicate the MKMapRect being rendered in each call to drawMapRect. The problem is illustrated in the red circle where, as you can see, only part of the triangle is being rendered. I'm assuming that its being clipped to the MKMapRect, though the documentation for MKOverlayView:drawMapRect makes me think this shouldn't be happening.
From the documentation:
You should also not make assumptions that the view’s frame matches the bounding rectangle of the overlay. The view’s frame is actually bigger than the bounding rectangle to allow you to draw lines for things like roads that might be located directly on the border of that rectangle.
My current solution is to draw objects more than once if they are in a maprect that is slightly larger than then maprect given to drawMapRect but this causes me to draw some things more than needed.
Does anyone know of a way to increase the size of the clipping area in drawMapRect so this isn't an issue? Any other suggestions are also welcome.
I ended up adding a buffer to the rect passed in to drawMapRect:mapRect:zoomScale:inContext and using that to determine which objects to draw. This results in more objects being drawn than needed, but not by much.

CoreGraphics rounded corner thickness

Whenever I stroke a path with rounded corners on iPhone, the rounded corners are thicker than the rest of the stroked path. See here for what I mean:
rounded corner thickness http://img181.imageshack.us/img181/6372/screenshot20100320at123.png
Not sure why this happens, any ideas?
I agree with Peter Hosey's analysis that the outer half of your lines is getting clipped off, but my recommendation would be to move all the coordinates .5 pixels inward instead. This way your straight lines will be crisper (not antialiased across 2 screen pixels) as well.
I suspect that you're drawing within a rectangular clipping path; the corners fall completely within the rectangle, but the sides get cut in half: half inside the clipping path and so drawn, half outside and so clipped out.
Try adding the path to the clipping path before stroking it.
To do this, you will need to add the CGPath to the context's current path twice:
Add CGPath to current path.
Add current path to clipping path (thereby emptying current path).
Add CGPath to current path.
Stroke current path.
It just looks thicker. If you zoom in on it you will see what looks like a couple extra pixels of black is actually some pixels of gray caused by antialiasing.
Try turning off antialiasing to see if the result looks better.
Edit: Also the bottom right corner seems to have a drop shadow effect.