(sample_strokes, factor=100)
return copy_stroke
Cut irrelevant end points, scale to pixel space and store as integer.
Cut irrelevant end points, scale to pixel space and store as integer.
Cut irrelevant end points scale to pixel space and store as integer .
def clean_strokes(sample_strokes, factor=100):
  """Cut irrelevant end points, scale to pixel space and store as integer."""
  # Useful function for exporting data to .json format.
  copy_stroke = []
  added_final = False
  for j in range(len(sample_strokes)):
    finish_flag = int(sample_strokes[j][4])
    if finish_flag == 0:
      copy_stroke.append([
          int(round(sample_strokes[j][0] * factor)),
          int(round(sample_strokes[j][1] * factor)),
          int(sample_strokes[j][2]),
          int(sample_strokes[j][3]), finish_flag
      ])
    else:
      copy_stroke.append([0, 0, 0, 0, 1])
      added_final = True
      break
  if not added_final:
    copy_stroke.append([0, 0, 0, 0, 1])
  return copy_stroke
def clean_strokes ( sample_strokes , factor = 100 ) : # Useful function for exporting data to .json format. copy_stroke = [ ] added_final = False for j in range ( len ( sample_strokes ) ) : finish_flag = int ( sample_strokes [ j ] [ 4 ] ) if finish_flag == 0 : copy_stroke . append ( [ int ( round ( sample_strokes [ j ] [ 0 ] * factor ) ) , int ( round ( sample_strokes [ j ] [ 1 ] * factor ) ) , int ( sample_strokes [ j ] [ 2 ] ) , int ( sample_strokes [ j ] [ 3 ] ) , finish_flag ] ) else : copy_stroke . append ( [ 0 , 0 , 0 , 0 , 1 ] ) added_final = True break if not added_final : copy_stroke . append ( [ 0 , 0 , 0 , 0 , 1 ] ) return copy_stroke