Пример #1
0
  def project_to_intensity_list(self, n_leds):
    pxl_ranges = [((i * self.width/n_leds), ((i+1) * self.width/n_leds)) for i in range(n_leds)]

    for ball in self.space.shapes:
      ball_left = ball.body.position.x - (self.width/n_leds) / 2
      ball_right = ball.body.position.x + (self.width/n_leds) / 2
      pct_overlaps = [ProjectionHelper.interval_overlap_pct((pxl_range), (ball_left,ball_right)) for pxl_range in pxl_ranges]

    return pct_overlaps
Пример #2
0
  def project_to_intensity_list(self, n_leds):
    pxl_ranges = [((i * self.width/n_leds), ((i+1) * self.width/n_leds)) for i in range(n_leds)]
    COMET_WIDTH = 8

    pct_overlaps = [0 for a in range(n_leds)]
    for comet in self.space.shapes:
      comet_left = comet.body.position.x - (self.width/n_leds) * COMET_WIDTH
      comet_right = comet.body.position.x + (self.width/n_leds) * COMET_WIDTH
      comet_pct_overlaps = [ProjectionHelper.interval_overlap_pct((pxl_range), (comet_left,comet_right)) for pxl_range in pxl_ranges]
      pct_overlaps = [a+b for a,b in zip(pct_overlaps, comet_pct_overlaps)]

    pct_overlaps = [min(a, 1) for a in pct_overlaps]

    return pct_overlaps