예제 #1
0
#!/usr/bin/env python
# simple line animation
from LaserClient import *

LD = LaserClient({"server":"localhost","port": 50000})
LD.set_scan_rate(35000)

y=0
while True:
  y += 1
  if y > 255:
    y=0
  LD.draw_line(128, 0, 128, y)
  LD.show_frame()

예제 #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()
예제 #3
0
import time
while True:
  t = time.localtime()
  
  hours = t.tm_hour%12
  minutes = t.tm_min
  seconds = t.tm_sec

  LD.set_color(RED)
#  LD.draw_text("%02i:%02i:%02i"%(hours,minutes,seconds), 220, 220, 20)

  LD.set_color(BLUE)
  angle = 2*PI*seconds/60 + PI/2
  r = 2.0/3 * (WIDTH/2)
  LD.draw_line(WIDTH/2, HEIGHT/2, WIDTH/2 + r*math.cos(angle), HEIGHT/2 + r*math.sin(angle))

  LD.set_color(MAGENTA)
  angle = 2*PI*minutes/60 + 2*PI/60 * float(seconds)/60 + PI/2
  LD.draw_line(WIDTH/2, HEIGHT/2, WIDTH/2 + r*math.cos(angle), HEIGHT/2 + r*math.sin(angle))

  angle = 2*PI*hours/12 + 2*PI*minutes/(60*12) + PI/2
  r *= 2.0/3
  LD.draw_line(WIDTH/2, HEIGHT/2, WIDTH/2 + r*math.cos(angle), HEIGHT/2 + r*math.sin(angle))

  r1 = 2.0/3 * (WIDTH/2)
  r2 = 1.9/3 * (WIDTH/2)

  LD.set_color(RED)
  for i in range(12):
    angle = i * 2*PI/12