コード例 #1
0
ファイル: example2.py プロジェクト: StudioProcess/helios-py
def make_square(size=2, color=(1, 1, 1, 1)):
    r = size / 2
    return [
        make_point(-r, +r, *color),
        make_point(-r, -r, *color),
        make_point(+r, -r, *color),
        make_point(+r, +r, *color),
        # make_point(-r, +r, *color)
    ]
コード例 #2
0
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)
コード例 #3
0
def interpolate_linestrips(lss, fullwidth_steps = 100, min = 0, max = 1000, color = (1,1,1,1), color_off = (0,0,0,0)):
    lss = list( filter(lambda l: len(l) > 0, lss) ) # remove empty linestrips from input
    if len(lss) == 0: return []
    out = []
    step_size = 0xFFF / fullwidth_steps
    for i, l in enumerate(lss):
        # current linestrip
        interp = interpolate_linestrip(l, step_size)
        points = map(lambda p: make_point(p[0], p[1], *color, xmin=min, xmax=max), interp)
        out.extend(points)
        # gap
        next_idx = i+1
        if next_idx == len(lss): next_idx = 0
        m = lss[next_idx] # subsequent linestrip
        gap = interpolate_linestrip([ l[-1], m[0] ], step_size) # linestrip connecting the gap
        # gap = gap[1:-1] # remove first and last point
        points = map(lambda p: make_point(p[0], p[1], *color_off, xmin=min, xmax=max), gap)
        out.extend(points)
    return out
コード例 #4
0
def line(p0, p1, ppl, color=(1, 1, 1, 1)):
    p0x, p0y = p0
    p1x, p1y = p1
    dx = p1x - p0x
    dy = p1y - p0y
    l = math.sqrt(dx * dx + dy * dy)
    n = int(l * ppl)
    out = []
    for i in range(n):
        a = i / (n - 1)  # [0.0, 1.0]
        x = p0x + a * dx
        y = p0y + a * dy
        out.append(make_point(x, y, *color))
    return out
コード例 #5
0
ファイル: example2.py プロジェクト: StudioProcess/helios-py
232.35090392977,273.56
231.56,322.7651116832861
231.56,372.7622930196687
231.56,422.7692087544281
231.56,472.7618797667697
'''

d = d.strip().split('\n')
d = list(map(lambda x: x.split(','), d))
p = []
max = 600
color = (1, 1, 1, 1)
for e in d:
    x = float(e[0])
    y = float(e[1])
    p.append(make_point(x, y, *color, 0, 600))


def make_square(size=2, color=(1, 1, 1, 1)):
    r = size / 2
    return [
        make_point(-r, +r, *color),
        make_point(-r, -r, *color),
        make_point(+r, -r, *color),
        make_point(+r, +r, *color),
        # make_point(-r, +r, *color)
    ]


def transform(point_array, transformation_matrix):
    out = []