def colorhandle(self,color): #handling veriable in the way color may be passed if type(color) == vox_color.color: #if color is of color object we are good print "that is a god damn color" return color elif type(color) == list or isinstance(color, (int, float, long, complex)):#if color is a list make a color object out of it return vox_color.color(color) else:#else make it just black, you should not have f****d up if you wanted color return vox_color.color('black')
IP_PORT = '10.0.0.10:7890' client = opc.Client(IP_PORT) n_pixels = 6400 ##****************************************## tshift = 0 dshift = 0 tcolor = 0 bcolor = 240 comp = vox.comp() co = vox_color.color([0,0,0]) co.vfadeinit(tcolor,bcolor) c = [vox_points.dualsurface(co,0,3,.75)] c[0].addrwave(target = c[0].moda) def start(): return def create(): return def exit(): return def frameStart(frame):
client = opc.Client(IP_PORT) if client.can_connect(): print ' connected to %s' % IP_PORT else: # can't connect, but keep running in case the server appears later print ' WARNING: could not connect to %s' % IP_PORT ##****************************************## #colorspeed = 1 #maxspeed = 30 #speed range 29 #(energy*29)+1 energy = .01 ###############3 set this to look at "global energy"### comp = vox.comp() comp.addshift(sps = -.99) huecount = 0 wc1 = vox_color.color(0) c = [vox_points.surface(color = wc1, size = 2, alpha = .4)] c.append(vox_points.surface(color = wc1, size = 2, alpha = .4)) c[0].addrwave(zoffset = 2,freq = -1) c[1].addrwave(zoffset = 2, freq = 1) while 1: for x in c: x.update() pixels = comp.complayers(c) client.put_pixels(pixels, channel=0) huecount += (1+energy*29) wc1.changecolor(huecount) time.sleep(1/30.)
print ' connected to %s' % IP_PORT else: # can't connect, but keep running in case the server appears later print ' WARNING: could not connect to %s' % IP_PORT ##****************************************## #minspeed = .015 #maxspeed = .11 #speed range .095 #(energy*.095)+.015 #minpoints = 40 #maxpoints = 150 #point range 110 #(energy*110)+40 energy = .01 ###############3 set this to look at "global energy"### comp = vox.comp() comp.addfade(.8) mxspd = .015 mxpnts = 40 co = vox_color.color([1.0,1.0,1.0]) c = [vox_points.pointgroup(color = co, size = 2, pcount = mxpnts, minspawnz = 1.2192, maxspawnz = 4, maxspeed = mxspd, ratio = 1.)] c[0].addzshift(ztarget = -3) c[0].addkillperam('z','less',-1.2192) while 1: c[0].maxspeed = (energy*.095)+.015 c[0].pcount = (energy*110)+40 for x in c: x.update() pixels = comp.complayers(c) client.put_pixels(pixels, channel=0) time.sleep(1/30.)
IP_PORT = '127.0.0.1:7890' #IP_PORT = '192.168.1.100:7890' #IP_PORT = '10.0.0.10:7890' client = opc.Client(IP_PORT) if client.can_connect(): print ' connected to %s' % IP_PORT else: # can't connect, but keep running in case the server appears later print ' WARNING: could not connect to %s' % IP_PORT ##****************************************## #spawn a compositer comp = vox.comp() #make a red color layer cl_red = vox_color.color([1.0,0.0,0.0]) #make an array to track layers layer = [] #add 3 spheres to the list #the first one will be at location x=0,y=0,z=0 #we will use the remade color layer cl_red layer.append(vox_shapes.sphere([[0.0],[0.0],[0.0]],cl_red)) #this green sphere can be added by passing location and rgb colors 0-1. #default size is 1 so we change it to .5. default mode is fade chaning #it to fill so it will not fade out around the outside layer.append(vox_shapes.sphere([[0.0],[1.0],[0.0]],[0.0,1.0,0.0],size = .5, mode = 'fill')) #blue layer with lowered alpha. lower the max speed to .07 meter per frame #the ratio that it will try to move per frame to it's target is redused
import math IP_PORT = '127.0.0.1:7890' client = opc.Client(IP_PORT) if client.can_connect(): print ' connected to %s' % IP_PORT else: # can't connect, but keep running in case the server appears later print ' WARNING: could not connect to %s' % IP_PORT n_pixels = 6400 co = vox_color.color([1.0,0.0,0.0]) c = vox_shapes.sphere([[0],[0],[0]],co) comp = vox.comp() pixels = [] start_time = time.time() layers = [c] s=1. d=1 c = vox_shapes.sphere([[0],[0],[0]],[1,0,0]) layers.append(c) start_time = time.time() loops = 0 while 1: pixels = [] current_time = start_time - time.time()
# URL to get progress from OctoPrint server octo_url = 'http://%s:%s/api/job' % (options.octo_host, options.octo_port) # create default view, split into sections by function default_view = create_pixel_array() default_view[:] = default_color white_pixels = (default_view[14:35], default_view[78:100]) progress_pixels = (default_view[65:78], default_view[0:13]) # create error view, populate with error color error_view = create_pixel_array() error_view[:] = error_color # create victory view, initialize with a rainbow victory_view = create_pixel_array() color = vox_color.color(0) for x in range(led_count): color.shifthue(options.step) victory_view[x] = color.c*255 # loop forever while 1: try: # get print progress from OctoPrint response = requests.get(octo_url) job = json.loads(response.content) done = job['progress']['completion'] except: # could not get a value from OctoPrint, display error display(error_view, default_sleep)