FixZeroHandles.glyphsFilter/Contents/Resources/plugin.py
def xyAtPercentageBetweenTwoPoints( self, firstPoint, secondPoint, percentage, allowedHandleLengthError = 0 ):
		"""
		Returns the x, y for the point at percentage
		(where 100 percent is represented as 1.0)
		between NSPoints firstPoint and secondPoint.
		"""
		x = firstPoint.x + percentage * ( secondPoint.x - firstPoint.x )
		y = firstPoint.y + percentage * ( secondPoint.y - firstPoint.y )
		if allowedHandleLengthError > 0:
			min_percentage = percentage - 0.5 * percentage * allowedHandleLengthError
			max_percentage = percentage + 0.5 * percentage * allowedHandleLengthError
			min_pt = self.xyAtPercentageBetweenTwoPoints( firstPoint, secondPoint, min_percentage)
			max_pt = self.xyAtPercentageBetweenTwoPoints( firstPoint, secondPoint, max_percentage)
			sample_count = 2 * int(round(distance(min_pt, max_pt)))
			if sample_count > 0:
				step = allowedHandleLengthError / float(sample_count)
				test_percentages = itertools.islice(itertools.count(min_percentage, step), sample_count)
				points = [self.xyAtPercentageBetweenTwoPoints( firstPoint, secondPoint, p) for p in test_percentages]
				xo, yo = self.getBestPoint(points, (x, y), (firstPoint.x, firstPoint.y), (secondPoint.x, secondPoint.y))
				x = xo
				y = yo
		return x, y

		Returns the x, y for the point at percentage
		(where 100 percent is represented as 1.0)
		between NSPoints firstPoint and secondPoint.
		
Returns the x, y for the point at percentage
(where 100 percent is represented as 1.0)
between NSPoints firstPoint and secondPoint.
Returns the x y for the point at percentage ( where 100 percent is represented as 1 . 0 ) between NSPoints firstPoint and secondPoint .
def xyAtPercentageBetweenTwoPoints( self, firstPoint, secondPoint, percentage, allowedHandleLengthError = 0 ):
		x = firstPoint.x + percentage * ( secondPoint.x - firstPoint.x )
		y = firstPoint.y + percentage * ( secondPoint.y - firstPoint.y )
		if allowedHandleLengthError > 0:
			min_percentage = percentage - 0.5 * percentage * allowedHandleLengthError
			max_percentage = percentage + 0.5 * percentage * allowedHandleLengthError
			min_pt = self.xyAtPercentageBetweenTwoPoints( firstPoint, secondPoint, min_percentage)
			max_pt = self.xyAtPercentageBetweenTwoPoints( firstPoint, secondPoint, max_percentage)
			sample_count = 2 * int(round(distance(min_pt, max_pt)))
			if sample_count > 0:
				step = allowedHandleLengthError / float(sample_count)
				test_percentages = itertools.islice(itertools.count(min_percentage, step), sample_count)
				points = [self.xyAtPercentageBetweenTwoPoints( firstPoint, secondPoint, p) for p in test_percentages]
				xo, yo = self.getBestPoint(points, (x, y), (firstPoint.x, firstPoint.y), (secondPoint.x, secondPoint.y))
				x = xo
				y = yo
		return x, y
def xyAtPercentageBetweenTwoPoints ( self , firstPoint , secondPoint , percentage , allowedHandleLengthError = 0 ) : x = firstPoint . x + percentage * ( secondPoint . x - firstPoint . x ) y = firstPoint . y + percentage * ( secondPoint . y - firstPoint . y ) if allowedHandleLengthError > 0 : min_percentage = percentage - 0.5 * percentage * allowedHandleLengthError max_percentage = percentage + 0.5 * percentage * allowedHandleLengthError min_pt = self . xyAtPercentageBetweenTwoPoints ( firstPoint , secondPoint , min_percentage ) max_pt = self . xyAtPercentageBetweenTwoPoints ( firstPoint , secondPoint , max_percentage ) sample_count = 2 * int ( round ( distance ( min_pt , max_pt ) ) ) if sample_count > 0 : step = allowedHandleLengthError / float ( sample_count ) test_percentages = itertools . islice ( itertools . count ( min_percentage , step ) , sample_count ) points = [ self . xyAtPercentageBetweenTwoPoints ( firstPoint , secondPoint , p ) for p in test_percentages ] xo , yo = self . getBestPoint ( points , ( x , y ) , ( firstPoint . x , firstPoint . y ) , ( secondPoint . x , secondPoint . y ) ) x = xo y = yo return x , y
Returns the x, y for the point at percentage
(where 100 percent is represented as 1.0)
between NSPoints firstPoint and secondPoint.
Returns the x y for the point at percentage ( where 100 percent is represented as 1 . 0 ) between NSPoints firstPoint and secondPoint .
"""
		Returns the x, y for the point at percentage
		(where 100 percent is represented as 1.0)
		between NSPoints firstPoint and secondPoint.
		"""
self
firstPoint
secondPoint
percentage
allowedHandleLengthError