Exemple #1
0
    if random.random()<PROBAB_COLOR_CHANGE:
      self.color[0] = clamp(self.color[0] + random.random()*COLOR_CHANGE_MAXSTEP - COLOR_CHANGE_MAXSTEP/2, 0,255)
      self.color[1] = clamp(self.color[1] + random.random()*COLOR_CHANGE_MAXSTEP - COLOR_CHANGE_MAXSTEP/2, 0,255)
      self.color[2] = clamp(self.color[2] + random.random()*COLOR_CHANGE_MAXSTEP - COLOR_CHANGE_MAXSTEP/2, 0,255)    

LD = LaserClient({"server":"localhost","port": 50000})
#LD = LaserDisplay({"server":"localhost","port": 50000})
#LD = LaserDisplay()

shapes = []
for _ in range (NUM_SHAPES):
  particles = []
  for _ in range(NUM_POINTS):
    p = Particle(LD)
    particles.append(p)
    
  shapes.append(particles)

#LD.set_noise(NOISE)
  
while True:
  for particles in shapes:
    points = []
    for p in particles:
      p.update_position()
      points.append([p.x,p.y])
      LD.set_color(p.color)
    LD.draw_quadratic_bezier(points, 10)
  LD.show_frame()

Exemple #2
0
  if region != -1:
    bounce_idx = region + bounce_idx - 2
    if bounce_idx < 0: bounce_idx = 0
    if bounce_idx > 6: bounce_idx = 6
    ball_dx = -ball_dx

  if bally < BARRIER_BOTTOM or bally > BARRIER_TOP:
    bounce_idx = 6 - bounce_idx

  if (ballx < BARRIER1):
    reset()
  if (ballx > BARRIER2):
    reset()

  circle = gen_circle(ballx, bally, BALL_RADIUS)
  circle2 = gen_circle(ballx, bally, BALL_RADIUS-2)

  LD.set_color(RED)
  LD.draw_quadratic_bezier(circle, 10)
  LD.set_color(GREEN)
  LD.draw_quadratic_bezier(circle2, 6)
  LD.set_color([0xff,0x00,0x20])
  LD.draw_line(PLAYER1_X, player1-20, PLAYER1_X, player1+20)
  LD.set_color([0x20,0xff,0xff])
  LD.draw_line(PLAYER2_X, player2-20, PLAYER2_X, player2+20)

  LD.draw_text("%02i"%(score1), 20, 220, 20)
  LD.draw_text("%02i"%(score2), 235, 220, 20)
  LD.show_frame()
Exemple #3
0
  m_x = (float)(pygame.mouse.get_pos()[0])/WIDTH
  m_x = 1.0 - m_x
  m_y = (float)(pygame.mouse.get_pos()[1])/HEIGHT
  m_y = 1.0 - m_y

  m_x = clamp_int(m_x * 255, 6, 249)
  m_y = clamp_int(m_y * 255, 6, 249)

  if config_border:
    MIN_BORDER = 64
    MAX_BORDER = 192

    LD.set_color([0xff, 0x00, 0xff])
    mouse = gen_circle(MIN_BORDER, MIN_BORDER, 1)
    LD.draw_quadratic_bezier(mouse, 2)
    mouse = gen_circle(MIN_BORDER, MAX_BORDER, 1)
    LD.draw_quadratic_bezier(mouse, 2)
    mouse = gen_circle(MAX_BORDER, MAX_BORDER, 1)
    LD.draw_quadratic_bezier(mouse, 2)
    mouse = gen_circle(MAX_BORDER, MIN_BORDER, 1)
    LD.draw_quadratic_bezier(mouse, 2)

  mouse = gen_circle(m_x, m_y, 3)
  LD.draw_quadratic_bezier(mouse, 2)

  LD.set_color([0xff, 0x00, 0x00])
  if curvelen >= 3:
    LD.draw_quadratic_bezier(curve, 8);

  if curvelen % 2 == 0 and curvelen > 0: