Exemplo n.º 1
0
def transform(point_array, transformation_matrix):
    out = []
    for p in point_array:
        p1 = transformation_matrix * [p.x, p.y, 1] # matrix multiplication
        p1 = p1[0] # get column vector
        if p1[2] is not 1: p1[0] /= p1[2]; p1[1] /= p1[2]; p1[2] = 1 # Homogeneous coordinates
        out.append( Helios.Point(int(p1[0]), int(p1[1]), p.r, p.g, p.b, p.i) )
    return out
def pattern_circle(
        scale=1,
        n_points=100,
        color=(1, 1, 1, 1),
):
    p = []
    for i in range(n_points):
        a = 2 * math.pi / n_points * i
        p.append(make_point(scale * math.cos(a), scale * math.sin(a), *color))
    return Helios.Frame(*p)
Exemplo n.º 3
0
def barrel_distort(point_array, k=0, cx=0, cy=0):
    out = []
    for p in point_array:
        dx = (p.x - cx) / 4095 # distance from center of distortion (but scaled to 0..1)
        dy = (p.y - cy) / 4095
        d = math.sqrt( dx*dx + dy*dy )
        dd = d * (1 + k * d * d) # distorted distance
        if d == 0: d = 1
        nx = cx + dx/d*dd * 4095
        ny = cy + dy/d*dd * 4095
        out.append( Helios.Point(int(nx), int(ny), p.r, p.g, p.b, p.i) )
    return out
Exemplo n.º 4
0
def interpolate(point_array, fullwidth_steps = 100, close = False):
    step_size = 0xFFF / fullwidth_steps
    # print(step_size)
    out = []
    l = len(point_array)-1
    if close: l += 1
    for i in range(l):
        p0 = point_array[i]
        p1 = point_array[(i+1) % len(point_array)]
        d = dist(p0.x, p0.y, p1.x, p1.y)
        n = int(d / step_size) # number of interpolated points (including start and end)
        if n < 2: n = 2 # include at least start and end
        for j in range(n):
            a = j / (n-1) # interpolation parameter [0, 1]
            attrs = interp_attrs(['x','y','r','g','b','i'] , p0, p1, a)
            out.append( Helios.Point(*attrs) )
            # print(a, attrs)
        # print(i, d, n)
    return out
Exemplo n.º 5
0
from helios import Helios
from helios.helpers import make_point
from helios import matrix
import time
import config
import math
import re

cfg = config.load('_config.json')

numDevices = Helios.OpenDevices()
print(f'Found {numDevices} Helios DAC(s)')

if numDevices is 0:
    print('Quitting (No Devices found)')
    exit()

name = Helios.GetName(0)
ver = Helios.GetFirmwareVersion(0)
print(f'Device 0: {name} (FW ver. {ver})')

d = '''
231.56,536.1397646963596
231.56,586.1379980360507
231.56000000000003,636.137858805165
231.56,686.1216426257976
231.56,736.1321803812124
195.4371631027339,750
159.42,736.0122641019523
159.42,686.0148338804705
159.42,636.0036850793562
Exemplo n.º 6
0
import time
from helios import Helios

numDevices = Helios.OpenDevices()
print(f'Found {numDevices} Helios DAC(s)')

if numDevices is 0:
    print('Quitting (No Devices found)')
    exit()

name = Helios.GetName(0)
ver = Helios.GetFirmwareVersion(0)
print(f'Device 0: {name} (FW ver. {ver})')

try:
    while True:
        shut = Helios.SetShutter(0, 0)
        print('shutter CLOSED:', shut)
        time.sleep(3)
        shut = Helios.SetShutter(0, 1)
        print('shutter OPENED:', shut)
        time.sleep(3)

except KeyboardInterrupt:
    Helios.SetShutter(0, 0)
    Helios.CloseDevices()
    exit()
import time
from helios import Helios
from helios.helpers import make_point, color_shift_frame
import math

numDevices = Helios.OpenDevices()
print(f'Found {numDevices} Helios DAC(s)')

if numDevices == 0:
    print('Quitting (No Devices found)')
    exit()
Helios.SetShutter(0, 1)


def pattern_circle(
        scale=1,
        n_points=100,
        color=(1, 1, 1, 1),
):
    p = []
    for i in range(n_points):
        a = 2 * math.pi / n_points * i
        p.append(make_point(scale * math.cos(a), scale * math.sin(a), *color))
    return Helios.Frame(*p)


def parse_hex_color(str, normalize=False):
    '''
    normalize: return color values between 0 and 1 (instead of 0 and 255)
    '''
    str = str.lstrip('#')