omit steps from get range steps

This commit is contained in:
frank 2021-05-24 22:56:54 -04:00
parent 47b9c1a27f
commit 1e85c7b619
1 changed files with 12 additions and 2 deletions

View File

@ -88,9 +88,19 @@ def get_point_on_circle(center, radius, angle, translate_angle=True):
return Vector(center[0] + sin(angle) * radius,
center[1] - cos(angle) * radius)
def get_range_steps(start, end, count):
def get_range_steps(start, end, count, omit=[]):
'''
Iterator that yields `count` number of steps from `start` to `end` as floats. Indicies in the
omit parameter will be skipped
'''
# normalize array indicies (for example -1 becomes count - 1)
for ii in range(len(omit)):
omit[ii] = omit[ii] % count
for ii in range(count):
yield start + (end - start) * ii / float(count - 1)
if ii in omit:
continue
else:
yield start + (end - start) * ii / float(count - 1)
def get_percent_way(iterable):
for ii in range(len(iterable)):