コード例 #1
0
def chktrngl(tmp):
    x = rgbcie(tmp[0], tmp[1], tmp[2])
    s = (1 / area) * (red[1] * blue[0] - red[0] * blue[1] +
                      (blue[1] - red[1]) * x[0] + (red[0] - blue[0]) * x[1])
    t = (1 / area) * (red[0] * green[1] - red[1] * green[0] +
                      (red[1] - green[1]) * x[0] + (green[0] - red[0]) * x[1])
    return (s > 0) and (t > 0) and (1 - s - t > 0)
コード例 #2
0
def chktrngl(tmp):
    x = rgbcie(tmp[0],tmp[1],tmp[2])
    s = (1/area)*(red[1]*blue[0]  - red[0]*blue[1]  + (blue[1]- red[1])*x[0]   + (red[0]  - blue[0])*x[1])
    t = (1/area)*(red[0]*green[1] - red[1]*green[0] + (red[1] - green[1])*x[0] + (green[0]- red[0])*x[1])
    return (s>0) and (t>0) and (1-s-t>0)
コード例 #3
0
def trans(b, l,rgb,val):
    b.lights[l].on = True
    xy = rgbcie(rgb[0],rgb[1],rgb[2])
    b.set_light(l+1,'xy',(xy[0],xy[1]),transitiontime=val)
コード例 #4
0
    elif not chktrngl(tmp):
        print "Failed Triangle"
        return False
    return True


def move(x,vv):
    return [int(round(x[i]+vv[i])) for i in range(0,3)]
#    tmp = [0,0,0]
#    for i in range(0,3):
#        tmp[i] = int(round(x[i]+vv[i]))
#    return tmp

point = findrndsp()
direct = findrnddir(50)
path = [(1000*rgbcie(point[0], point[1], point[2])[0],1000*rgbcie(point[0], point[1], point[2])[1])]
#for i in range(0,40):
#     print "Step " + str(i) + ":" + str(point) + " (dst: " + str(distdiag(point)) + ")"
#    print validmove(point, direct)
while(True):
    trans(bridge, 0,point,20)
    print str(point) + " (dst: " + str(round(distdiag(point),2)) + ", xy: " + str([round(x, 2) for x in rgbcie(point[0],point[1],point[2])]) + ", vel:" + str([round(x,2) for x in direct]) + ")"
    time.sleep(2)
    while (not validmove(point, direct)):
        direct = findrnddir(50)
    point = move(point, direct)
    path.append((1000*rgbcie(point[0], point[1], point[2])[0],1000*rgbcie(point[0], point[1], point[2])[1]))
    draw.line(path,fill=(0,0,0))
    draw.point(path,fill=(255,255,255))
    img.save("pathp.bmp")
コード例 #5
0
def trans(b, l, rgb, val):
    b.lights[l].on = True
    xy = rgbcie(rgb[0], rgb[1], rgb[2])
    b.set_light(l + 1, 'xy', (xy[0], xy[1]), transitiontime=val)
コード例 #6
0
        return False
    return True


def move(x, vv):
    return [int(round(x[i] + vv[i])) for i in range(0, 3)]


#    tmp = [0,0,0]
#    for i in range(0,3):
#        tmp[i] = int(round(x[i]+vv[i]))
#    return tmp

point = findrndsp()
direct = findrnddir(50)
path = [(1000 * rgbcie(point[0], point[1], point[2])[0],
         1000 * rgbcie(point[0], point[1], point[2])[1])]
#for i in range(0,40):
#     print "Step " + str(i) + ":" + str(point) + " (dst: " + str(distdiag(point)) + ")"
#    print validmove(point, direct)
while (True):
    trans(bridge, 0, point, 20)
    print str(point) + " (dst: " + str(round(
        distdiag(point), 2)) + ", xy: " + str([
            round(x, 2) for x in rgbcie(point[0], point[1], point[2])
        ]) + ", vel:" + str([round(x, 2) for x in direct]) + ")"
    time.sleep(2)
    while (not validmove(point, direct)):
        direct = findrnddir(50)
    point = move(point, direct)
    path.append((1000 * rgbcie(point[0], point[1], point[2])[0],