core graphics - iPhone - CGPoint distance in pixels and screen resolution -
i have code - (void)drawmaprect:(mkmaprect)maprect zoomscale:(mkzoomscale)zoomscale incontext:(cgcontextref)context
method (into mkoverlayview subclass) prevent drawing segments less 10 pixels long on map overlay :
cgpoint origin = [self pointformappoint:poly.points[0]]; cgpoint lastpoint = origin; cgcontextmovetopoint(context, origin.x, origin.y); (int i=1; i<poly.pointcount; i++) { cgpoint point = [self pointformappoint:poly.points[i]]; cgfloat xdist = (point.x - lastpoint.x); cgfloat ydist = (point.y - lastpoint.y); cgfloat distance = sqrt((xdist * xdist) + (ydist * ydist)) * zoomscale; if (distance >= 10.0) { lastpoint = point; cgcontextaddlinetopoint(context, point.x, point.y); } }
will test >= 10.0 take care screen resolution, or may introduce [uiscreen mainscreen].scale
parameter ?
i believe test >= 10.0 not take account screen resolution. apple of drawing arithmetic using "points" instead of pixels- way code not have change retina display compared normal display.
if want draw 10.0 pixels wide, need take account screen resolution; however, if you'll have write method support both retina display , normal display.
Comments
Post a Comment