Exemple #1
0
#!/usr/bin/env python
# This example draws a dashed 2 color circle with increasing radius length
from LaserClient import *
import math
import pygame
import random

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

x=0x80
y=0x80
r=0x00

RED = [255,0,0]
GREEN = [0,255,0]
BLUE = [0,0,255]

CIRCLE = [[0.0,0.5],[0.0,1.0],[0.5,1.0],[1.0,1.0],[1.0,0.5],[1.0,0.0],[0.5,0.0],[0.0,0.0],[0.0,0.5]]

def gen_circle(x, y, r):
  points = []
  for i in range(9):
    points.append([(int)(x + (CIRCLE[i][0]-0.5)*r*2), (int)(y + (CIRCLE[i][1]-0.5)*r*2-0.5)])
  return points

circle1 = gen_circle(0x80, 0x80, 0x10);
circle2 = gen_circle(0x80, 0x80, 0x18);
circle3 = gen_circle(0x80, 0x80, 0x20);

pygame.init()
Exemple #2
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()

Exemple #3
0
#!/usr/bin/env python
# This example draws a dashed 2 color circle with increasing radius length
from LaserClient import *
import math

PI = 3.1415
RED = [255, 0, 0]
GREEN = [0, 255, 0]

x = 0x80
y = 0x80
r = 0x00

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


def draw_dashed_circle(x, y, r, c1, c2):
    step = 32
    for alpha in range(step):
        if alpha % 2:
            LD.set_color(c1)
        else:
            LD.set_color(c2)

        LD.draw_line(
            x + r * math.cos(alpha * 2 * PI / step),
            y + r * math.sin(alpha * 2 * PI / step),
            x + r * math.cos((alpha + 1) * 2 * PI / step),
            y + r * math.sin((alpha + 1) * 2 * PI / step),
        )
Exemple #4
0
  def update_position(self):      
    self.x += self.vx
    self.y += self.vy
    self.vx += self.ax
    self.vy += self.ay

    if self.x < self.r or self.x > WIDTH-self.r or self.y < self.r or self.y > HEIGHT-self.r:
      self.reset()

    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:
Exemple #5
0
FPS = 30
cont = 1

numbers = []

curve = []
vec = []
ctl_x = 0
ctl_y = 0
curvelen = 0

config_snap = 1
config_border = 1

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

def clamp_int(value, min, max):
  if value > max: return max
  if value < min: return min
  return value

while cont == 1:
#  clock.tick(FPS)

  for event in pygame.event.get():
    if event.type == pygame.KEYDOWN:
      if event.key == pygame.K_ESCAPE:
        cont = 0
      if event.key == pygame.K_r:
Exemple #6
0
WIDTH = 255
HEIGHT = 255

PI = 3.1415

RED = [255,0,0]
GREEN = [0,255,0]
BLUE = [0,0,255]
CYAN = [0,255,255]
MAGENTA = [255,0,255]
YELLOW = [255,255,0]
WHITE = [255,255,255]

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

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)