def run(self): while self.trace is None and not self.die: time.sleep(0.1) if self.die: return if ol.init(4) < 0: return print "OL Initialized" params = ol.RenderParams() params.render_flags = ol.RENDER_GRAYSCALE params.on_speed = 2/120.0 params.off_speed = 2/30.0 params.flatness = 0.000001 params.max_framelen = 48000 / 25 params.min_length = 30 params.snap = 0.04 ol.setRenderParams(params) ol.loadIdentity() ol.scale((2, -2)) ol.translate((-0.5, -0.5)) ol.scale((1/640.0, 1/640.0)) ol.translate((0, (640-480)/2)) while not self.die: #ol.rect((100, 100), (640-100, 480-100), ol.C_WHITE) objects = self.trace for o in objects: ol.begin(ol.POINTS) for point in o[::2]: ol.vertex(point, ol.C_WHITE) ol.end() ftime = ol.renderFrame(60) ol.shutdown()
def draw(self, target): x, y = target[0] - self.x, target[1] - self.y # point each segment to it's predecessor for segment in self.segments: dx = x - segment.x dy = y - segment.y angle = math.atan2(dy, dx) segment.angle = angle x = x - math.cos(angle) * arm_length / parts y = y - math.sin(angle) * arm_length / parts # and now move the pointed nodes, starting from the last one # (that is the beginning of the arm) for prev, segment in reversed(list(zip(self.segments, self.segments[1:]))): prev.x = segment.x + math.cos(segment.angle) * arm_length / parts prev.y = segment.y + math.sin(segment.angle) * arm_length / parts segment.prev_x = prev.x segment.prev_y = prev.y ol.translate3((self.x, self.y, 0)) ol.begin(ol.LINESTRIP) for segment in self.segments: segment.draw(self.color) ol.end()
def draw(self): ol.loadIdentity3() ol.loadIdentity() ol.loadIdentity3() ol.perspective(20, 1, 1, 100) ol.translate3((0, 0, -20)) ol.color3(1.0, 1.0, 0.0) ol.translate3( (cos(lux.time / 2.0), cos(lux.time / 3.0), cos(lux.time / 7.0))) ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate) ol.rotate3X(lux.time * pi * 0.25 * lux.simple_rate) ol.rotate3Y(lux.time * pi * 0.13 * lux.simple_rate) for row in self.torender: ol.begin(ol.LINESTRIP) vi = self.faces[row] vi = vi + [vi[0]] for i in vi: tup = tuple(self.verts[i, :]) ol.vertex3(tup) ol.end()
def draw(self): """ Draw the bullet shape """ #print ("drawing bullet") pts = [] pts.append({'x': 0, 'y': 0}) pts.append({'x': self.length*math.cos(self.shotAngle), 'y': self.length*math.sin(self.shotAngle)}) """ # Rotate points for p in pts: x = p['x'] y = p['y'] p['x'] = x*math.cos(self.theta) - y*math.sin(self.theta) p['y'] = y*math.cos(self.theta) + x*math.sin(self.theta) """ # Translate points for pt in pts: pt['x'] += self.x pt['y'] += self.y ol.begin(ol.LINESTRIP) for i in range(len(pts)): ol.vertex((pts[i]['x'], pts[i]['y']), ol.C_WHITE) ol.end() self.drawn = True
def draw(self): ol.loadIdentity3() ol.loadIdentity() # Grab the raw audio buffers mono = audio_engine.left_buffer() # mono = np.zeros(512) # Make sure they aren't empty!! if (mono.shape[0] == 0): return # Openlase can only draw 30000 points in one cycle (less that # that, actually!). Clear the audio buffer and try again! if mono.shape[0] > 10000: audio_engine.clear_all() return ol.loadIdentity3() ol.color3(*(self.color_cycle())) ol.begin(ol.LINESTRIP) for i in range(0, mono.shape[0]-1, self.subsamp): scale_factor = pow(0.9-abs(self.x_coord),0.5)*2 if (mono[i] <= -1.0): mono[i] = 1.0 ol.vertex3((self.x_coord, tanh(mono[i]*scale_factor), -1)) # ol.vertex3((self.x_coord, log(mono[i]*scale_factor+1.0), -1)) self.x_coord = self.x_coord + self.step if (self.x_coord > 0.9) : self.x_coord = -0.9 ol.end()
def draw(self, target=None): for particle in reversed(self.tail): # draw connecting lines if particle.follow: new_x, new_y = particle.follow.x, particle.follow.y if draw_links: ol.color3(1, 0, 1) # magenta links ol.loadIdentity3() ol.loadIdentity() ol.begin(ol.LINESTRIP) ol.vertex3((particle.x, particle.y, 0)) ol.vertex3((particle.follow.x, particle.follow.y, 0)) ol.end() else: if target: new_x, new_y = target[0], target[1] else: new_x, new_y = math.cos(3 * lux.time), math.sin(2 * lux.time) #new_x, new_y = self.mouse_x, self.mouse_y particle.draw('blah') if abs(particle.x - new_x) > 0.01 or abs(particle.y - new_y) > 0.01: self.tweener.add_tween(particle, x=new_x, y=new_y, duration=0.6, \ easing=pytweener.Easing.Cubic.ease_out, on_complete=particle.finish, on_update=particle.draw)
def draw(self, target): x, y =target[0]-self.x, target[1]-self.y # point each segment to it's predecessor for segment in self.segments: dx = x - segment.x dy = y - segment.y angle = math.atan2(dy, dx) segment.angle = angle x = x - math.cos(angle) * arm_length/parts y = y - math.sin(angle) * arm_length/parts # and now move the pointed nodes, starting from the last one # (that is the beginning of the arm) for prev, segment in reversed(list(zip(self.segments, self.segments[1:]))): prev.x = segment.x + math.cos(segment.angle) * arm_length/parts prev.y = segment.y + math.sin(segment.angle) * arm_length/parts segment.prev_x = prev.x segment.prev_y = prev.y ol.translate3((self.x, self.y, 0)) ol.begin(ol.LINESTRIP) for segment in self.segments: segment.draw(self.color) ol.end()
def draw(self): self.x_phase = 0.4*cos(1.7 * lux.time * self.RATE) + 0.6*cos(0.7 * lux.time * self.RATE) self.y_phase = cos(2.2 * lux.time * self.RATE) self.z_phase = cos(5.7 * lux.time * self.RATE) self.z_ratio = 2 + cos(0.1 * lux.time * self.RATE) ol.loadIdentity3() ol.loadIdentity() ol.perspective(20, 1, 1, 100) ol.translate3((0, 0, -10)) ol.scale3((0.5, 0.5, 0.5)) ol.rotate3Z(lux.time * pi * 0.01) ol.rotate3X(lux.time * pi * 0.025) ol.rotate3Y(lux.time * pi * 0.013) ol.color3(*(self.color_cycle())) ol.begin(ol.POINTS) decay_factor = 1 first_point = None for i in range(self.SAMPLES_PER_FRAME): theta = float(i) / self.SAMPLES_PER_FRAME * self.MAX_THETA x = sin(self.x_ratio * theta + self.x_phase) y = sin(self.y_ratio * theta + self.y_phase) z = sin(self.z_ratio * theta + self.z_phase) if (i == 0): first_point = (x * decay_factor, y * decay_factor, z * decay_factor) ol.vertex3((x * decay_factor, y * decay_factor, z * decay_factor)) decay_factor = decay_factor * self.decay ol.vertex3(first_point) ol.end()
def draw(self): self.x_phase = 0.4*cos(1.7 * lux.time * self.RATE) + 0.6*cos(0.7 * lux.time * self.RATE) self.y_phase = cos(2.2 * lux.time * self.RATE) self.z_phase = cos(5.7 * lux.time * self.RATE) self.z_ratio = 2 + cos(0.1 * lux.time * self.RATE) ol.loadIdentity3() ol.loadIdentity() ol.perspective(20, 1, 1, 100) ol.translate3((0, 0, -10)) #ol.scale3((0.5, 0.5, 0.5)) ol.rotate3Z(lux.time * pi * 0.01) ol.rotate3X(lux.time * pi * 0.025) ol.rotate3Y(lux.time * pi * 0.013) ol.color3(*(self.color_cycle())) ol.begin(ol.POINTS) decay_factor = 1 first_point = None for i in range(self.SAMPLES_PER_FRAME): theta = float(i) / self.SAMPLES_PER_FRAME * self.MAX_THETA x = sin(self.x_ratio * theta + self.x_phase) y = sin(self.y_ratio * theta + self.y_phase) z = sin(self.z_ratio * theta + self.z_phase) if (i == 0): first_point = (x * decay_factor, y * decay_factor, z * decay_factor) ol.vertex3((x * decay_factor, y * decay_factor, z * decay_factor)) decay_factor = decay_factor * self.decay ol.vertex3(first_point) ol.end()
def draw(self): ol.loadIdentity3() ol.loadIdentity() # Grab the raw audio buffers newbuffer = audio_engine.mono_buffer() # Make sure they aren't empty!! if (len(newbuffer) == 0): return else: self.mono = newbuffer # Openlase can only draw 30000 points in one cycle (less that # that, actually!). Clear the audio buffer and try again! if self.mono.shape[0] > 10000: audio_engine.clear_all() ol.loadIdentity3() ol.color3(*(self.color_cycle())) ol.begin(ol.POINTS) for i in range(0, self.mono.shape[0]-1, self.SUBSAMP): val = tanh(self.mono[i] * self.BOOST) val = val * 0.5 + 0.5 val = val * (self.MAX_SIZE - self.MIN_SIZE) + self.MIN_SIZE ol.vertex3((cos(self.pos) * val, sin(self.pos) * val, -1)) self.pos = self.pos + self.W / 30000.0; while(self.pos >= 2*pi): self.pos = self.pos -2*pi ol.end()
def draw(self): ol.loadIdentity3() ol.loadIdentity() ol.perspective(60, 1, 1, 100) ol.translate3((0, 0, -3)) ol.color3(1.0, 1.0, 1.0) offset = cos(lux.time * 10) ol.begin(ol.LINESTRIP) npts = 25 #ol.scale3((0.5,0.5,0.5)) for i in range(npts): ol.color3( float(i) / npts, 1.0 - float(i) / npts, (float(i) / npts + (1.0 - float(i) / npts)) / 2.0) offset = 0 mod = (i % 2 * 2.0 - 1.0) * 0.99 #ol.scale3((mod, mod, mod)) ol.rotate3Z(lux.time * pi * 0.01 * lux.simple_rate) ol.vertex3((float(i) / (npts / 2.0) - 1.0 + offset, -1.0, -1)) ol.vertex3((float(i) / (npts / 2.0) - 1.0 + offset, 1.0, -1)) ol.end()
def draw(self): ol.loadIdentity3() ol.loadIdentity() ol.loadIdentity3() ol.perspective(20, 1, 1, 100) ol.translate3((0, 0, -20)) ol.color3(1.0,1.0,0.0); ol.translate3( (cos(lux.time/2.0), cos(lux.time/3.0), cos(lux.time/7.0)) ) ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate) ol.rotate3X(lux.time * pi * 0.25 * lux.simple_rate) ol.rotate3Y(lux.time * pi * 0.13 * lux.simple_rate) for row in self.torender: ol.begin(ol.LINESTRIP) vi = self.faces[row] vi = vi + [vi[0]] for i in vi: tup = tuple(self.verts[i,:]) ol.vertex3(tup) ol.end()
def square(self,x1,y1,x2,y2): ol.begin(ol.LINESTRIP) ol.vertex((x1,y1)) ol.vertex((x1,y2)) ol.vertex((x2,y2)) ol.vertex((x2,y1)) ol.vertex((x1,y1)) ol.end()
def square(posx,posy,size): ol.begin(ol.LINESTRIP) ol.vertex3((posx,posy,0)) ol.vertex3((posx+size,posy,0)) ol.vertex3((posx+size,posy+size,0)) ol.vertex3((posx,posy+size,0)) ol.vertex3((posx,posy,0)) ol.end()
def draw(self): time = lux.time #time = self.time ctf = self.color_time_frequency clf = self.color_length_frequency caf = self.color_angle_frequency/2 theta = abs(math.sin(time*self.time_scale)) R = self.R * math.sin(2*pi*time*self.time_scale*self.R_frequency) r = self.r * math.sin(2*pi*time*self.time_scale*self.r_frequency) p = self.p * math.sin(2*pi*time*self.time_scale*self.p_frequency) * self.bass ol.color3(1.0, 0.0, 1.0); ol.loadIdentity3() ol.loadIdentity() ol.perspective(60, 1, 1, 100) ol.translate3((0, 0, -3)) first = True n = 0 while theta < 2*pi*self.max_cycles and n < self.max_segments: theta += self.theta_step #x = (R + r) * math.cos(theta) #y = (R + r) * math.sin(theta) x = (R + r) * math.cos(theta) + (r + p) * math.cos((R+r)/r * theta) y = (R + r) * math.sin(theta) + (r + p) * math.sin((R+r)/r * theta) if first: ol.begin(ol.LINESTRIP) #ol.begin(ol.POINTS) first = False #red = math.sin(ctf*time*n/37) * math.sin(csf*theta*n/37) #green = math.sin(ctf*time*n/23) * math.sin(csf*theta*n/23) #blue = math.sin(ctf*time*n/128) * math.sin(csf*theta*n/128) angle = math.atan2(y, x)/(2*pi) red = abs(math.sin(2*pi*(self.r_prime/3+ctf*time+clf*n+caf*angle))) green = abs(math.sin(2*pi*(self.g_prime/3+ctf*time+clf*n+caf*angle))) blue = abs(math.sin(2*pi*(self.b_prime/3+ctf*time+clf*n+caf*angle))) ol.color3(red, green, blue) #this makes it square-ish #x += math.cos(2*pi*angle*self.spatial_resonance)*self.spatial_resonance_amplitude #y += math.sin(2*pi*angle*self.spatial_resonance)*self.spatial_resonance_amplitude x += math.cos(2*pi*angle*(self.spatial_resonance+1)+2*pi*self.spatial_resonance_offset)*self.spatial_resonance_amplitude y += math.sin(2*pi*angle*(self.spatial_resonance+1)+2*pi*self.spatial_resonance_offset)*self.spatial_resonance_amplitude x *= self.width y *= self.height ol.vertex3((x,y,0)) n += 1 ol.end() #dynamically adjust resolution target = self.max_segments * 0.8 error = (target - n)/target self.theta_step = min(max(1e-100, self.theta_step * (1-error)), 1) #print n, angle self.time += 1/30
def square(posx, posy, size): ol.begin(ol.POINTS) # ol.begin(ol.LINESTRIP) ol.vertex3((posx, posy, 0)) ol.vertex3((posx + size, posy, 0)) ol.vertex3((posx + size, posy + size, 0)) ol.vertex3((posx, posy + size, 0)) ol.vertex3((posx, posy, 0)) ol.end()
def square(x1, y1, x2, y2): ol.begin(ol.POINTS) ol.vertex3((x1, y1, 0)) ol.vertex3((x1, y2, 0)) ol.vertex3((x2, y2, 0)) ol.vertex3((x2, y1, 0)) ol.vertex3((x1, y1, 0)) ol.end()
def square(x1,y1,x2,y2): ol.begin(ol.POINTS) ol.vertex3((x1,y1,0)) ol.vertex3((x1,y2,0)) ol.vertex3((x2,y2,0)) ol.vertex3((x2,y1,0)) ol.vertex3((x1,y1,0)) ol.end()
def play_ugo(size, frames, meta): frame_pts = [] total_time = 0 for frame_meta in meta['frames']: frame_pts.append(total_time) total_time += frame_meta['delay'] / 1000.0 if ol.init(3) < 0: return width, height = size params = ol.RenderParams() params.render_flags = ol.RENDER_GRAYSCALE params.on_speed = 2/60.0 params.off_speed = 2/30.0 params.flatness = 0.000001 params.max_framelen = 48000 / 25 params.min_length = 30 params.snap = 0.04 ol.setRenderParams(params) ol.loadIdentity() ol.scale((2, -2)) ol.translate((-0.5, -0.5)) mw = float(max(width, height)) print width, height, mw ol.scale((1/mw, 1/mw)) ol.translate(((mw-width)/2, (mw-height)/2)) frame = 0 time = 0 DECIMATE = 2 while True: while time > total_time: time -= total_time frame = 0 while (frame+1) < len(frames) and frame_pts[frame+1] < time: frame += 1 print "t=%.02f frame=%d" % (time, frame) objects = frames[frame] points = 0 for o in objects: ol.begin(ol.POINTS) for point in o[::DECIMATE]: ol.vertex(point, ol.C_WHITE) points += 1 ol.end() print "%d objects, %d points" % (len(objects), points) time += ol.renderFrame(60) ol.shutdown()
def play_ugo(size, frames, meta): frame_pts = [] total_time = 0 for frame_meta in meta['frames']: frame_pts.append(total_time) total_time += frame_meta['delay'] / 1000.0 if ol.init(3) < 0: return width, height = size params = ol.RenderParams() params.render_flags = ol.RENDER_GRAYSCALE params.on_speed = 2 / 60.0 params.off_speed = 2 / 30.0 params.flatness = 0.000001 params.max_framelen = 48000 / 25 params.min_length = 30 params.snap = 0.04 ol.setRenderParams(params) ol.loadIdentity() ol.scale((2, -2)) ol.translate((-0.5, -0.5)) mw = float(max(width, height)) print width, height, mw ol.scale((1 / mw, 1 / mw)) ol.translate(((mw - width) / 2, (mw - height) / 2)) frame = 0 time = 0 DECIMATE = 2 while True: while time > total_time: time -= total_time frame = 0 while (frame + 1) < len(frames) and frame_pts[frame + 1] < time: frame += 1 print "t=%.02f frame=%d" % (time, frame) objects = frames[frame] points = 0 for o in objects: ol.begin(ol.POINTS) for point in o[::DECIMATE]: ol.vertex(point, ol.C_WHITE) points += 1 ol.end() print "%d objects, %d points" % (len(objects), points) time += ol.renderFrame(60) ol.shutdown()
def render_frame(): global renderFrame global openPath if renderFrame: if openPath: ol.end() openPath = False ol.renderFrame(30) renderFrame = False
def draw(self): ol.loadIdentity() ol.rotate(lux.time / 10) # Grab the raw audio buffer mono = audio_engine.mono_buffer() # Make sure it ain't empty!! if mono.shape[0] == 0: return # Openlase can only draw 30000 points in one cycle (less that # that, actually!). Clear the audio buffer and try again! if mono.shape[0] > 10000: audio_engine.clear_all() ol.color3(*(self.color_cycle())) ol.perspective(60, 1, 1, 100) ol.translate3((0, 0, -3)) if (lux.time > self.nextSnapshot): #print "snapshot" self.nextSnapshot = lux.time + self.interval self.currentWave = self.nextWave self.nextWave = zeros(shape=(self.renderPointCount)) # load in new values for i in range(int(self.renderPointCount - 1)): self.nextWave[i] = mono[i * self.skip] * 2 # draw shape fracIntervalComplete = ( lux.time - (self.nextSnapshot - self.interval)) / self.interval # print '%f %f %f' % (lux.time,fracIntervalComplete, self.nextSnapshot) coordsToRender = zeros(shape=(self.renderPointCount, 2)) firstVal = None for i in range(int(self.renderPointCount - 1)): val = ((self.nextWave[i] - self.currentWave[i]) * fracIntervalComplete) + self.currentWave[i] if (firstVal is None): firstVal = val #print "next: %f curr: %f frac: %f" % (self.nextWave[i], self.currentWave[i], fracIntervalComplete) (x, y) = self.doTheTrigStuff( val, (float(i) / float(self.renderPointCount)), firstVal) coordsToRender[i][0] = x coordsToRender[i][1] = y coordsToRender[self.renderPointCount - 1] = coordsToRender[0] # render shape ol.begin(ol.LINESTRIP) for i in range(0, int(self.renderPointCount), 1): # print '%f: %f,%f' % (i,coordsToRender[i][0], coordsToRender[i][1]) ol.vertex((coordsToRender[i][0], coordsToRender[i][1])) ol.end() ol.vertex((coordsToRender[0][0], coordsToRender[0][1]))
def draw(self): ol.loadIdentity() ol.rotate(lux.time / 10) # Grab the raw audio buffer mono = audio_engine.mono_buffer() # Make sure it ain't empty!! if mono.shape[0] == 0: return # Openlase can only draw 30000 points in one cycle (less that # that, actually!). Clear the audio buffer and try again! if mono.shape[0] > 10000: audio_engine.clear_all() return ol.color3(*(self.color_cycle())) ol.perspective(60, 1, 1, 100) ol.translate3((0, 0, -3)) if lux.time > self.nextSnapshot: # print "snapshot" self.nextSnapshot = lux.time + self.interval self.currentWave = self.nextWave self.nextWave = zeros(shape=(self.renderPointCount)) # load in new values for i in range(self.renderPointCount - 1): self.nextWave[i] = mono[i * self.skip] # draw shape fracIntervalComplete = (lux.time - (self.nextSnapshot - self.interval)) / self.interval # print '%f %f %f' % (lux.time,fracIntervalComplete, self.nextSnapshot) coordsToRender = zeros(shape=(self.renderPointCount, 2)) firstVal = None for i in range(self.renderPointCount - 1): val = ((self.nextWave[i] - self.currentWave[i]) * fracIntervalComplete) + self.currentWave[i] if firstVal is None: firstVal = val # print "next: %f curr: %f frac: %f" % (self.nextWave[i], self.currentWave[i], fracIntervalComplete) (x, y) = self.doTheTrigStuff(val, (float(i) / float(self.renderPointCount)), firstVal) coordsToRender[i][0] = x coordsToRender[i][1] = y coordsToRender[self.renderPointCount - 1] = coordsToRender[0] # render shape ol.begin(ol.LINESTRIP) for i in range(self.renderPointCount): # print '%f: %f,%f' % (i,coordsToRender[i][0], coordsToRender[i][1]) ol.vertex((coordsToRender[i][0], coordsToRender[i][1])) ol.end()
def square(self, x1, y1, x2, y2): # simple_rate = 3.0 # ol.rotate3Z(lux.time * pi * 0.1 * simple_rate) # ol.rotate3X(lux.time * pi * 0.25 * simple_rate) # ol.rotate3Y(lux.time * pi * 0.13 * simple_rate) ol.begin(ol.LINESTRIP) ol.vertex3((x1, y1, 0)) ol.vertex3((x1, y2, 0)) ol.vertex3((x2, y2, 0)) ol.vertex3((x2, y1, 0)) ol.vertex3((x1, y1, 0)) ol.end()
def square(self,x1,y1,x2,y2): # simple_rate = 3.0 # ol.rotate3Z(lux.time * pi * 0.1 * simple_rate) # ol.rotate3X(lux.time * pi * 0.25 * simple_rate) # ol.rotate3Y(lux.time * pi * 0.13 * simple_rate) ol.begin(ol.LINESTRIP) ol.vertex3((x1,y1,0)) ol.vertex3((x1,y2,0)) ol.vertex3((x2,y2,0)) ol.vertex3((x2,y1,0)) ol.vertex3((x1,y1,0)) ol.end()
def draw(self): '''a square''' #self.x = math.cos(2*pi*rotate_frequency*lux.time + self.angle + self.base_angle) * self.distance * self.distance_scale #self.y = math.sin(2*pi*rotate_frequency*lux.time + self.angle + self.base_angle) * self.distance * self.distance_scale #stolen from guilloche time = lux.time * time_scale R = math.sin(2*pi*self.R_frequency*time) * self.R + 0.0001 r = math.sin(2*pi*self.r_frequency*time) * self.r + 0.0001 p = math.sin(2*pi*self.p_frequency*time) * self.p + 0.0001 self.x = (R + r) * math.cos(time) + (r + p) * math.cos((R+r)/r * time) self.y = (R + r) * math.sin(time) + (r + p) * math.sin((R+r)/r * time) #clamp to display area if clamp_display: if self.x > 1: self.x = 1 if self.y > 1: self.y = 1 if self.x < -1: self.x = -1 if self.y < -1: self.y = -1 self.x *= scale self.y *= scale #self.graphics.circle(0, 0, self.radius) ol.loadIdentity3() ol.loadIdentity() #ol.color3(self.color[0], self.color[1], self.color[2]) ol.color3(self.red, self.green, self.blue) ol.translate3((self.x, self.y, 0)) angle = math.atan2(self.y, self.x)/(2*pi) red = abs(math.sin(2*pi*(r_prime/3+ctf*time+clf*self.n+caf*angle)))*self.red green = abs(math.sin(2*pi*(g_prime/3+ctf*time+clf*self.n+caf*angle)))*self.green blue = abs(math.sin(2*pi*(b_prime/3+ctf*time+clf*self.n+caf*angle)))*self.blue if seizure_mode: #red, green, blue = red/self.radius, green/self.radius, blue/self.radius red = abs(red*math.tan((2*pi*self.radius/node_big_radius))) green = abs(green*math.tan((2*pi*self.radius/node_big_radius))) blue = abs(blue*math.tan((2*pi*self.radius/node_big_radius))) ol.color3(red, green, blue) #do squares have radii? s = self.radius ol.begin(ol.POINTS) ol.vertex3((-s, s,0)) ol.vertex3((-s, s,0)) ol.vertex3(( s, s,0)) ol.vertex3(( s,-s,0)) ol.vertex3((-s,-s,0)) ol.end()
def draw(self, val): '''a square''' ol.loadIdentity3() ol.loadIdentity() ol.color3(self.color[0], self.color[1], self.color[2]) ol.translate3((self.x, self.y, 0)) ol.begin(ol.POINTS) ol.vertex3((.0,.0,.0)) ol.vertex3((.0,.1,.0)) ol.vertex3((.1,.1,.0)) ol.vertex3((.1,.0,.0)) ol.vertex3((.0,.0,.0)) ol.end() self.moving = True return self
def draw(self, val): '''a square''' ol.loadIdentity3() ol.loadIdentity() ol.color3(self.color[0], self.color[1], self.color[2]) ol.translate3((self.x, self.y, 0)) ol.begin(ol.POINTS) ol.vertex3((.0, .0, .0)) ol.vertex3((.0, .1, .0)) ol.vertex3((.1, .1, .0)) ol.vertex3((.1, .0, .0)) ol.vertex3((.0, .0, .0)) ol.end() self.moving = True return self
def draw(self): if self.lines_only: ol.begin(ol.LINESTRIP) x, y = self.segments[0].start ol.vertex3((x, y, 0), self.color) for i in self.segments: ol.vertex3((i.end[0], i.end[1], 0), self.color) ol.end() else: ol.begin(ol.BEZIERSTRIP) x, y = self.segments[0].start ol.vertex3((x, y, 0), self.color) for i in self.segments: i = i.to_bezier4() ol.vertex3((i.cp1[0], i.cp1[1], 0), self.color) ol.vertex3((i.cp2[0], i.cp2[1], 0), self.color) ol.vertex3((i.end[0], i.end[1], 0), self.color) ol.end()
def draw(self): time = lux.time ctf = self.color_time_frequency clf = self.color_length_frequency caf = self.color_angle_frequency/2 theta0 = abs(math.sin(time*self.time_scale)) for braid_count in range(1,self.NUM_CIRCLES): first = True n = 0 theta = theta0 ol.color3(1.0, 0.0, 1.0); ol.loadIdentity3() ol.loadIdentity() ol.perspective(40, 1, 1, 100) ol.translate3((0, 0, -3)) ol.rotate3Z(lux.time * pi * self.z_rotations[braid_count]) ol.rotate3X(lux.time * pi * self.x_rotations[braid_count]) ol.rotate3Z(lux.time * pi * self.x_rotations[braid_count]) ol.begin(ol.LINESTRIP) while theta < theta0 + 2*pi: r = (0.5+sin(10*theta)/2.0) / float(braid_count) * self.scale x = r * cos(theta) y = r * sin(theta) angle = math.atan2(y, x)/(2*pi) red = abs(math.sin(2*pi*(self.r_prime/3+ctf*time+clf*n+caf*angle)+self.color_phases[braid_count])) green = abs(math.sin(2*pi*(self.g_prime/3+ctf*time+clf*n+caf*angle)+self.color_phases[braid_count])) blue = abs(math.sin(2*pi*(self.b_prime/3+ctf*time+clf*n+caf*angle)+self.color_phases[braid_count])) ol.color3(red, green, blue) ol.vertex3((x,y,0)) n += 1 theta += 1.0/float(self.max_segments) r = (0.5+sin(10*theta)/2.0) / float(braid_count) * self.scale x = r * cos(theta) y = r * sin(theta) ol.vertex3((x,y,0)) # Close the path ol.end()
def draw(self): ol.loadIdentity3() ol.loadIdentity() for i in range(2): ol.loadIdentity3() ol.perspective(20, 1, 1, 100) ol.translate3((0, 0, -20)) if (i == 1): ol.color3(1.0, 1.0, 0.0) ol.translate3((cos(lux.time / 2.0), cos(lux.time / 3.0), cos(lux.time / 7.0))) ol.rotate3Z(lux.time * pi * 0.1 * lux.TwoCubes_simple_rate) ol.rotate3X(lux.time * pi * 0.25 * lux.TwoCubes_simple_rate) ol.rotate3Y(lux.time * pi * 0.13 * lux.TwoCubes_simple_rate) else: ol.color3(0.0, 1.0, 1.0) ol.scale3((0.6, 0.6, 0.6)) ol.translate3((cos(lux.time / 3.2), cos(lux.time / 2.6), cos(lux.time / 5.4))) ol.rotate3Z(lux.time * pi * 0.14 * lux.TwoCubes_simple_rate) ol.rotate3X(lux.time * pi * 0.53 * lux.TwoCubes_simple_rate) ol.rotate3Y(lux.time * pi * 0.22 * lux.TwoCubes_simple_rate) ol.begin(ol.LINESTRIP) ol.vertex3((-1, -1, -1)) ol.vertex3((1, -1, -1)) ol.vertex3((1, 1, -1)) ol.vertex3((-1, 1, -1)) ol.vertex3((-1, -1, -1)) ol.vertex3((-1, -1, 1)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((1, 1, 1)) ol.vertex3((-1, 1, 1)) ol.vertex3((-1, -1, 1)) ol.vertex3((1, -1, 1)) ol.vertex3((1, 1, 1)) ol.vertex3((1, 1, -1)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((1, -1, -1)) ol.vertex3((1, -1, 1)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((-1, 1, 1)) ol.vertex3((-1, 1, -1)) ol.end()
def draw(self): ol.loadIdentity3() ol.loadIdentity() ol.color3(1.0, 0.0, 1.0); font = ol.getDefaultFont() s = "Lux!" w = ol.getStringWidth(font, 0.2, s) ol.drawString(font, (-w/2,0.1), 0.2, s) ol.perspective(60, 1, 1, 100) ol.translate3((0, 0, -3)) for i in range(2): if (i == 1): ol.color3(1.0,1.0,0.0); else: ol.color3(0.0,1.0,1.0); ol.scale3((0.6, 0.6, 0.6)) ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate) ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate) ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate) ol.begin(ol.LINESTRIP) ol.vertex3((-1, -1, -1)) ol.vertex3(( 1, -1, -1)) ol.vertex3(( 1, 1, -1)) ol.vertex3((-1, 1, -1)) ol.vertex3((-1, -1, -1)) ol.vertex3((-1, -1, 1)) ol.end() ol.begin(ol.LINESTRIP); ol.vertex3(( 1, 1, 1)) ol.vertex3((-1, 1, 1)) ol.vertex3((-1, -1, 1)) ol.vertex3(( 1, -1, 1)) ol.vertex3(( 1, 1, 1)) ol.vertex3(( 1, 1, -1)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3(( 1, -1, -1)) ol.vertex3(( 1, -1, 1)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((-1, 1, 1)) ol.vertex3((-1, 1, -1)) ol.end()
def draw(self): """ Draw the healthbar shape. """ # Generate points #print ("drawing healthbar") full = self.radius/2 hPerc = self.health/float(HealthBar.HEALTH_MAX) ihPerc = 1.0 - hPerc green = full * hPerc red = full * (1.0 - hPerc) y = 0.01 xShift = 0.01 pts = [] pts.append({'x': full + xShift, 'y': y}) pts.append({'x': -full*2 + full*3*ihPerc + xShift, 'y': y}) # RED """ pts.append({'x': full - full*3 + xShift, 'y': y}) pts.append({'x': -full*2 + xShift, 'y': y}) """ #pts.append({'x': -full*2, 'y': full}) #pts.append({'x': -full*2, 'y': full}) # Translate points for pt in pts: pt['x'] += self.x pt['y'] += self.y # DRAW THE SHAPE ol.begin(ol.LINESTRIP) for i in range(len(pts)): ol.vertex((pts[i]['x'], pts[i]['y']), ol.C_WHITE) ol.end() self.drawn = True
def draw(self): a = self.alpha * cos(lux.time / 10.0 * self.RATE) b = self.beta * sin(lux.time / 7.0 * self.RATE) + 10 c = self.gamma * cos(lux.time / 11.0 * self.RATE) A = self.rho ol.loadIdentity3() ol.loadIdentity() ol.rotate3Z(lux.time * pi * 0.03) ol.color3(*(self.color_cycle())) ol.begin(ol.LINESTRIP) for i in range(self.SAMPLES_PER_FRAME): theta = float(i) / self.SAMPLES_PER_FRAME * self.MAX_THETA r = exp(cos(a * theta)) - A * cos(b*theta) + pow(abs(sin(theta/c)),b) r = r / (2.7 - A + pow(1,b)) * self.overall_amplitude ol.vertex3((r * cos(theta), r * sin(theta), -1)) ol.end()
def draw(self): ol.loadIdentity3() ol.loadIdentity() # Grab the raw audio buffers mono = audio_engine.left_buffer() # mono = np.zeros(512) # Make sure they aren't empty!! if (mono.shape[0] == 0): return # Openlase can only draw 30000 points in one cycle (less that # that, actually!). Clear the audio buffer and try again! if mono.shape[0] > 10000: audio_engine.clear_all() ol.loadIdentity3() ol.color3(*(self.color_cycle())) count = 0 while count < mono.shape[0]: ol.begin(ol.LINESTRIP) while self.x_coord < 1.0 and count < mono.shape[0]: scale_factor = pow(1.0 - abs(self.x_coord), 0.5) * 2 #ol.vertex3((self.x_coord, mono[count]*scale_factor, -1)) # Linear ol.vertex3((self.x_coord, tanh(mono[count] * scale_factor), -1)) # Tanh #ol.vertex3((self.x_coord, log(mono[count]*scale_factor+1.0), -1)) # Sigmoid self.x_coord += self.step count = count + self.subsamp ol.end() if self.x_coord >= 1.0: self.x_coord = -1.0 ol.end()
def draw(self): ol.loadIdentity3() ol.loadIdentity() for i in range(2): ol.loadIdentity3() ol.perspective(20, 1, 1, 100) ol.translate3((0, 0, -20)) if (i == 1): ol.color3(1.0,1.0,0.0); ol.translate3((cos(lux.time/2.0), cos(lux.time/3.0), cos(lux.time/7.0))) ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate) ol.rotate3X(lux.time * pi * 0.25 * lux.simple_rate) ol.rotate3Y(lux.time * pi * 0.13 * lux.simple_rate) else: ol.color3(0.0,1.0,1.0); ol.scale3((0.6, 0.6, 0.6)) ol.translate3((cos(lux.time/3.2), cos(lux.time/2.6), cos(lux.time/5.4))) ol.rotate3Z(lux.time * pi * 0.14 * lux.simple_rate) ol.rotate3X(lux.time * pi * 0.53 * lux.simple_rate) ol.rotate3Y(lux.time * pi * 0.22 * lux.simple_rate) ol.begin(ol.LINESTRIP) ol.vertex3((-1, -1, -1)) ol.vertex3(( 1, -1, -1)) ol.vertex3(( 1, 1, -1)) ol.vertex3((-1, 1, -1)) ol.vertex3((-1, -1, -1)) ol.vertex3((-1, -1, 1)) ol.end() ol.begin(ol.LINESTRIP); ol.vertex3(( 1, 1, 1)) ol.vertex3((-1, 1, 1)) ol.vertex3((-1, -1, 1)) ol.vertex3(( 1, -1, 1)) ol.vertex3(( 1, 1, 1)) ol.vertex3(( 1, 1, -1)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3(( 1, -1, -1)) ol.vertex3(( 1, -1, 1)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((-1, 1, 1)) ol.vertex3((-1, 1, -1)) ol.end()
def draw(self): self.tweener.add_tween(self, scale_factor=0.25, time_scale = 1.0, duration=0.1, \ easing=pytweener.Easing.Expo.ease_in_out) ol.loadIdentity() ol.loadIdentity3() ol.translate3((-0.1, 0.0, 0.0)) ol.scale3((self.scale_factor, self.scale_factor, self.scale_factor)) # Spawn photons randomly if len(self.photons) < MAX_PHOTONS and random.random( ) < SPAWN_THRESHOLD: p = Photon() self.photons.append(p) # Draw photons dt = self.time_scale * (lux.time - self.last_time) self.last_time = lux.time self.tweener.update(lux.time - self.last_time) for p in self.photons: p.update(dt, self.photon_speed) p.draw() ol.color3(1.0, 1.0, 1.0) font = ol.getDefaultFont() s = "LASER" w = ol.getStringWidth(font, 1.0, s) ol.drawString(font, (-w / 2, 1.1), 1.0, s) # Draw the bounding box, with a very small hole in it. ol.color3(0.0, 1.0, 0.0) ol.begin(ol.LINESTRIP) ol.vertex3((CAVITY_SIZE[0] / 2, 0.1, 0.0)) ol.vertex3((CAVITY_SIZE[0] / 2, CAVITY_SIZE[1] / 2, 0.0)) ol.vertex3((-CAVITY_SIZE[0] / 2, CAVITY_SIZE[1] / 2, 0.0)) ol.vertex3((-CAVITY_SIZE[0] / 2, -CAVITY_SIZE[1] / 2, 0.0)) ol.vertex3((CAVITY_SIZE[0] / 2, -CAVITY_SIZE[1] / 2, 0.0)) ol.vertex3((CAVITY_SIZE[0] / 2, -0.1, 0.0)) ol.end()
def draw(self): self.tweener.add_tween(self, scale_factor=0.25, time_scale = 1.0, duration=0.1, \ easing=pytweener.Easing.Expo.ease_in_out) ol.loadIdentity() ol.loadIdentity3() ol.translate3((-0.1, 0.0, 0.0)) ol.scale3((self.scale_factor, self.scale_factor, self.scale_factor)) # Spawn photons randomly if len(self.photons) < MAX_PHOTONS and random.random() < SPAWN_THRESHOLD: p = Photon(); self.photons.append(p) # Draw photons dt = self.time_scale * (lux.time - self.last_time) self.last_time = lux.time self.tweener.update(lux.time - self.last_time) for p in self.photons: p.update(dt, self.photon_speed) p.draw() ol.color3(1.0, 1.0, 1.0); font = ol.getDefaultFont() s = "LASER" w = ol.getStringWidth(font, 1.0, s) ol.drawString(font, (-w/2,1.1), 1.0, s) # Draw the bounding box, with a very small hole in it. ol.color3(0.0, 1.0, 0.0); ol.begin(ol.LINESTRIP) ol.vertex3(( CAVITY_SIZE[0]/2, 0.1, 0.0)) ol.vertex3(( CAVITY_SIZE[0]/2, CAVITY_SIZE[1]/2, 0.0)) ol.vertex3((-CAVITY_SIZE[0]/2, CAVITY_SIZE[1]/2, 0.0)) ol.vertex3((-CAVITY_SIZE[0]/2, -CAVITY_SIZE[1]/2, 0.0)) ol.vertex3(( CAVITY_SIZE[0]/2, -CAVITY_SIZE[1]/2, 0.0)) ol.vertex3(( CAVITY_SIZE[0]/2, -0.1, 0.0)) ol.end()
def draw(self): """ Draw the asteroid shape """ # Generate points #print "drawing asteroid" ed = self.radius #print "asteroid radius = ", ed pts = [] for pt in self.points: pts.append(pt[:]) #print pts #pts.append([ ed, ed]) #pts.append([-ed, ed]) #pts.append([-ed, -ed]) #pts.append([ ed, -ed]) #pts.append([ ed, ed]) # Rotate points for p in pts: x = p[0] y = p[1] p[0] = x*math.cos(self.theta) - y*math.sin(self.theta) p[1] = y*math.cos(self.theta) + x*math.sin(self.theta) # Translate points #print "asteroid x,y = ", self.x, self.y for pt in pts: #print pt pt[0] += self.x pt[1] += self.y #print pt ol.begin(ol.LINESTRIP) for p in pts: ol.vertex(tuple(p), ol.C_WHITE) ol.end() self.drawn = True
def draw(self): ol.loadIdentity3() ol.loadIdentity() # Grab the raw audio buffers mono = audio_engine.left_buffer() # mono = np.zeros(512) # Make sure they aren't empty!! if (mono.shape[0] == 0): return # Openlase can only draw 30000 points in one cycle (less that # that, actually!). Clear the audio buffer and try again! if mono.shape[0] > 10000: audio_engine.clear_all() ol.loadIdentity3() ol.color3(*(self.color_cycle())) count = 0 while count < mono.shape[0]: ol.begin(ol.LINESTRIP) while self.x_coord < 1.0 and count < mono.shape[0]: scale_factor = pow(1.0-abs(self.x_coord),0.5)*2 #ol.vertex3((self.x_coord, mono[count]*scale_factor, -1)) # Linear ol.vertex3((self.x_coord, tanh(mono[count]*scale_factor), -1)) # Tanh #ol.vertex3((self.x_coord, log(mono[count]*scale_factor+1.0), -1)) # Sigmoid self.x_coord += self.step count = count + self.subsamp ol.end() if self.x_coord >= 1.0: self.x_coord = -1.0 ol.end()
def draw(self, target = None): for particle in reversed(self.tail): # draw connecting lines if particle.follow: new_x, new_y = particle.follow.x, particle.follow.y if draw_links: ol.color3(1,0,1) # magenta links ol.loadIdentity3() ol.loadIdentity() ol.begin(ol.LINESTRIP) ol.vertex3((particle.x, particle.y, 0)) ol.vertex3((particle.follow.x, particle.follow.y, 0)) ol.end() else: if target: new_x, new_y = target[0], target[1] else: new_x, new_y = math.cos(3*lux.time), math.sin(2*lux.time) #new_x, new_y = self.mouse_x, self.mouse_y particle.draw('blah') if abs(particle.x - new_x) > 0.01 or abs(particle.y - new_y) > 0.01: self.tweener.add_tween(particle, x=new_x, y=new_y, duration=0.6, \ easing=pytweener.Easing.Cubic.ease_out, on_complete=particle.finish, on_update=particle.draw)
def draw(self): """ Draw the ship shape. """ # Generate points #print "drawing ship" ed = self.radius/2 #print "ed = ", ed pts = [] pts.append([ed, ed]) #pts.append([-ed, ed]) pts.append([-ed-ed*2, 0]) #pts.append([-ed, -ed]) pts.append([ed, -ed]) pts.append([ed/2, 0]) pts.append([ed, ed]) # Rotate points for p in pts: x = p[0] y = p[1] p[0] = x*math.cos(self.theta) - y*math.sin(self.theta) p[1] = y*math.cos(self.theta) + x*math.sin(self.theta) # Translate points for pt in pts: pt[0] += self.x pt[1] += self.y ol.begin(ol.LINESTRIP) for i in range(5): for p in pts: #print p ol.vertex(tuple(p), ol.C_WHITE) ol.end() self.drawn = True
def draw(self): ol.loadIdentity3() ol.loadIdentity() ol.perspective(60, 1, 1, 100) ol.translate3((0, 0, -3)) ol.color3(1.0,1.0,1.0) offset = cos(lux.time*10) ol.begin(ol.LINESTRIP) npts = 25 #ol.scale3((0.5,0.5,0.5)) for i in range(npts): ol.color3(float(i)/npts,1.0-float(i)/npts,(float(i)/npts+(1.0-float(i)/npts))/2.0) offset = 0 mod = (i%2 * 2.0 - 1.0) * 0.99 #ol.scale3((mod, mod, mod)) ol.rotate3Z(lux.time * pi * 0.01 * lux.simple_rate) ol.vertex3((float(i)/(npts/2.0)-1.0+offset,-1.0,-1)) ol.vertex3((float(i)/(npts/2.0)-1.0+offset,1.0,-1)) ol.end()
def draw(self): try: a = self.alpha * cos(lux.time / 10.0 * self.RATE) b = self.beta * sin(lux.time / 7.0 * self.RATE) + 10 c = self.gamma * cos(lux.time / 11.0 * self.RATE) A = self.rho ol.loadIdentity3() ol.loadIdentity() ol.rotate3Z(lux.time * pi * 0.03) ol.color3(*(self.color_cycle())) ol.begin(ol.LINESTRIP) for i in range(self.SAMPLES_PER_FRAME): theta = float(i) / self.SAMPLES_PER_FRAME * self.MAX_THETA r = exp(cos(a * theta)) - A * cos(b * theta) + pow( abs(sin(theta / c)), b) r = r / (2.7 - A + pow(1, b)) * self.overall_amplitude ol.vertex3((self.SCALE * r * cos(theta), self.SCALE * r * sin(theta), -1)) ol.end() except ValueError: pass # Occasinal math hiccups can be safely ignored
def draw(self): ol.loadIdentity() ol.color3(1.0, 1.0, 1.0) # bounding box ol.begin(ol.LINESTRIP) self.square(1, 1, -1, -1) ol.end() # horizontal line ol.begin(ol.LINESTRIP) ol.vertex((-1, 0)) ol.vertex((1, 0)) ol.end() # vertical line ol.begin(ol.LINESTRIP) ol.vertex((0, -1)) ol.vertex((0, 1)) ol.end() # inner box, for fun ol.color3(0.0, 1.0, 0.0) size = (sin(lux.time) * .2) + .5 ol.begin(ol.LINESTRIP) self.square(size, size, -size, -size) ol.end() # Red dots ol.loadIdentity() ol.loadIdentity3() ol.begin(ol.LINESTRIP) for y in range(0, 20): ol.color3(float(y) / 20.0, 0.0, 0.0) ol.vertex3((-0.6, (float(y - 10) / 12.0), -1.0)) ol.end() # Green dots ol.begin(ol.LINESTRIP) for y in range(0, 20): ol.color3(0.0, float(y) / 20.0, 0.0) ol.vertex3((-0.4, (float(y - 10) / 12.0), -1.0)) ol.end() # Blue dots ol.begin(ol.LINESTRIP) for y in range(0, 20): ol.color3(0.0, 0.0, float(y) / 20.0) ol.vertex3((-0.2, (float(y - 10) / 12.0), -1.0)) ol.end() # vertical line ol.begin(ol.LINESTRIP) ol.vertex((0, -1)) ol.vertex((0, 1)) ol.end()
def draw(self): ol.loadIdentity3() ol.loadIdentity() #ol.color3(1.0, 0.0, 1.0); #font = ol.getDefaultFont() #s = "Lux!" #w = ol.getStringWidth(font, 0.2, s) #ol.drawString(font, (-w/2,0.1), 0.2, s) ol.perspective(60, 1, 1, 100) ol.translate3((0, 0, -3)) #Dodecahedron--------------------------- ol.color3(1.0,1.0,1.0); ol.scale3((0.8, 0.8, 0.8)) ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate) ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate) ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate) for face in self.dodeca_face_edges: ol.begin(ol.LINESTRIP) ol.vertex3(face[0]) ol.vertex3(face[1]) ol.vertex3(face[2]) ol.vertex3(face[3]) ol.vertex3(face[4]) ol.vertex3(face[0]) ol.end() #Icosahedron--------------------------- ol.color3(1.0,1.0,0.0); ol.scale3((0.9, 0.9, 0.9)) ol.rotate3Z(lux.time * pi * 0.5 * lux.simple_rate) #ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate) #ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate) for face in self.icos_face_edges: ol.begin(ol.LINESTRIP) ol.vertex3(face[0]) ol.vertex3(face[1]) ol.vertex3(face[2]) ol.vertex3(face[0]) ol.end() #for strip in self.icos_face_edges: # ol.begin(ol.LINESTRIP) # for f in strip: # ol.vertex3(f) # ol.end() #Cube--------------------------- # ol.color3(0.0,0.0,1.0); # ol.scale3((0.4, 0.4, 0.4)) # #ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate) # #ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate) # ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate) # ol.begin(ol.LINESTRIP) # ol.vertex3((-1, -1, -1)) # ol.vertex3(( 1, -1, -1)) # ol.vertex3(( 1, 1, -1)) # ol.vertex3((-1, 1, -1)) # ol.vertex3((-1, -1, -1)) # ol.vertex3((-1, -1, 1)) # ol.end() # ol.begin(ol.LINESTRIP); # ol.vertex3(( 1, 1, 1)) # ol.vertex3((-1, 1, 1)) # ol.vertex3((-1, -1, 1)) # ol.vertex3(( 1, -1, 1)) # ol.vertex3(( 1, 1, 1)) # ol.vertex3(( 1, 1, -1)) # ol.end() # ol.begin(ol.LINESTRIP) # ol.vertex3(( 1, -1, -1)) # ol.vertex3(( 1, -1, 1)) # ol.end() # ol.begin(ol.LINESTRIP) # ol.vertex3((-1, 1, 1)) # ol.vertex3((-1, 1, -1)) # ol.end() #Octahedron------------------------ ol.color3(0.0,0.0,1.0); ol.scale3((.8, .8, .8)) #ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate) ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate) #ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate) for strip in self.octahedron_face_edges: ol.begin(ol.LINESTRIP) for f in strip: ol.vertex3(f) ol.end()
def draw(self, audio): '''a square''' #self.x = math.cos(2*pi*rotate_frequency*lux.time + self.angle + self.base_angle) * self.distance * self.distance_scale #self.y = math.sin(2*pi*rotate_frequency*lux.time + self.angle + self.base_angle) * self.distance * self.distance_scale #stolen from guilloche time = lux.time * time_scale R = math.sin(2 * pi * self.R_frequency * time) * self.R + 0.0001 r = math.sin(2 * pi * self.r_frequency * time) * self.r + 0.0001 p = math.sin(2 * pi * self.p_frequency * time) * self.p + 0.0001 self.x = (R + r) * math.cos(time) + (r + p) * math.cos( (R + r) / r * time) self.y = (R + r) * math.sin(time) + (r + p) * math.sin( (R + r) / r * time) #clamp to display area if clamp_display: if self.x > 1: self.x = 1 if self.y > 1: self.y = 1 if self.x < -1: self.x = -1 if self.y < -1: self.y = -1 self.x *= scale self.y *= scale #self.graphics.circle(0, 0, self.radius) ol.loadIdentity3() ol.loadIdentity() #ol.color3(self.color[0], self.color[1], self.color[2]) ol.color3(self.red, self.green, self.blue) ol.translate3((self.x, self.y, 0)) angle = math.atan2(self.y, self.x) / (2 * pi) red = self.red #abs(math.sin(2*pi*(r_prime/3+ctf*time+clf*self.n+caf*angle)))*self.red green = abs( math.sin(2 * pi * (g_prime / 3 + ctf * time + clf * self.n + caf * angle))) * self.green blue = abs( math.sin(2 * pi * (b_prime / 3 + ctf * time + clf * self.n + caf * angle))) * self.blue if seizure_mode: #red, green, blue = red/self.radius, green/self.radius, blue/self.radius red = abs(red * math.tan((2 * pi * self.radius / node_big_radius))) green = abs(green * math.tan( (2 * pi * self.radius / node_big_radius))) blue = abs(blue * math.tan( (2 * pi * self.radius / node_big_radius))) if audio: try: #seems most of the time all the samples are empty #sample_index = int((self.n/max_nodes)*audio[0].shape[0]) sample_index = 0 #self.n sample = audio[0][n] except: sample = 1 else: sample = 1 #[0 for x in range(10000)] #empty vector #print sample if audio: red = red blue = blue + sample * self.audio_gain green = green + sample * self.audio_gain ol.color3(red, green, blue) if self.last_sample - sample > 0.1: pass #pulse #do squares have radii? s = self.radius ol.begin(ol.POINTS) ol.vertex3((-s, s, 0)) ol.vertex3((-s, s, 0)) ol.vertex3((s, s, 0)) ol.vertex3((s, -s, 0)) ol.vertex3((-s, -s, 0)) ol.end()
def draw(self): time = lux.time #time = self.time ctf = self.color_time_frequency clf = self.color_length_frequency caf = self.color_angle_frequency / 2 theta = abs(math.sin(time * self.time_scale)) R = self.R * math.sin( 2 * pi * time * self.time_scale * self.R_frequency) r = self.r * math.sin( 2 * pi * time * self.time_scale * self.r_frequency) p = self.p * math.sin( 2 * pi * time * self.time_scale * self.p_frequency) * self.bass audio = self.get_audio() ol.color3(1.0, 0.0, 1.0) ol.loadIdentity3() ol.loadIdentity() ol.perspective(60, 1, 1, 100) ol.translate3((0, 0, -3)) first = True n = 0 while theta < 2 * pi * self.max_cycles and n < self.max_segments: theta += self.theta_step if audio: try: sample_index = int( theta / (2 * pi * self.max_cycles) * (audio[0].shape[0] - 1)) + 1 #skip first sample sample = audio[2][sample_index] except: sample = 0 else: sample = 0 #[0 for x in range(10000)] #empty vector #x = (R + r) * math.cos(theta) #y = (R + r) * math.sin(theta) sample *= self.audio_gain #print sample #x = (R + r) * math.cos(theta) + (r + p + sample) * math.cos((R+r)/r * theta) #y = (R + r) * math.sin(theta) + (r + p + sample) * math.sin((R+r)/r * theta) #ben's ill advised DALT change x = (R + r) * math.cos(theta) + (r + p * sample) * math.cos( (R + r) / r * theta) y = (R + r) * math.sin(theta) + (r + p * sample) * math.sin( (R + r) / r * theta) if first: #ol.begin(ol.LINESTRIP) ol.begin(ol.POINTS) first = False #red = math.sin(ctf*time*n/37) * math.sin(csf*theta*n/37) #green = math.sin(ctf*time*n/23) * math.sin(csf*theta*n/23) #blue = math.sin(ctf*time*n/128) * math.sin(csf*theta*n/128) angle = math.atan2(y, x) / (2 * pi) red = abs( math.sin( 2 * pi * (self.r_prime / 3 + ctf * time + clf * n + caf * angle))) green = abs( math.sin( 2 * pi * (self.g_prime / 3 + ctf * time + clf * n + caf * angle))) blue = abs( math.sin( 2 * pi * (self.b_prime / 3 + ctf * time + clf * n + caf * angle))) ol.color3(red, green, blue) #this makes it square-ish #x += math.cos(2*pi*angle*self.spatial_resonance)*self.spatial_resonance_amplitude #y += math.sin(2*pi*angle*self.spatial_resonance)*self.spatial_resonance_amplitude x += math.cos(2 * pi * angle * (self.spatial_resonance + 1) + 2 * pi * self.spatial_resonance_offset ) * self.spatial_resonance_amplitude y += math.sin(2 * pi * angle * (self.spatial_resonance + 1) + 2 * pi * self.spatial_resonance_offset ) * self.spatial_resonance_amplitude x *= self.width y *= self.height ol.vertex3((x, y, 0)) n += 1 ol.end() #dynamically adjust resolution target = self.max_segments * 0.8 error = (target - n) / target self.theta_step = min(max(1e-100, self.theta_step * (1 - error)), 1) #print n, angle self.time += 1 / 30
def draw(self): ol.loadIdentity3() ol.loadIdentity() ol.color3(1.0, 0.0, 1.0) font = ol.getDefaultFont() s = "davidad" x = sin(lux.time) * 0.5 w = ol.getStringWidth(font, x, s) #ol.drawString(font, (-w/2,0), x, s) ol.perspective(60, 1, 1, 100) ol.translate3((0, 0, -3)) t = lux.time * 2 lx = 0 ly = 0 for i in range(8): c = floor(t * 2 + i) % 3 c = 3 if (c == 1): #if(1): ol.color3(1.0, 1.0, 0.0) if (c == 2): ol.color3(0.0, 1.0, 1.0) if (c == 3): ol.color3(1.0, 0.0, 1.0) ol.scale3((0.6, 0.6, 0.6)) #ol.rotate3Z(lux.time * pi * 0.1 * lux.simple_rate) #ol.rotate3X(lux.time * pi * 0.8 * lux.simple_rate) #ol.rotate3Y(lux.time * pi * 0.73 * lux.simple_rate) z = 2 * sin(t * 2) z = -1 + 4 * (t * 2 - floor(t * 2)) #z = 4 x = 0.5 * sin(t + i / 1.0) y = 0.5 * cos(t + i / 1.0) ol.begin(ol.LINESTRIP) ol.vertex3((x - 1, y - 1, z)) ol.vertex3((x - 1, y + 1, z)) ol.vertex3((x + 1, y + 1, z)) ol.vertex3((x + 1, y - 1, z)) ol.vertex3((x - 1, y - 1, z)) ol.end() if i != 0: ol.begin(ol.LINESTRIP) ol.vertex3((x - 1, y - 1, z)) ol.vertex3((lx - 1, ly - 1, z + 4)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((x - 1, y + 1, z)) ol.vertex3((lx - 1, ly + 1, z + 4)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((x + 1, y + 1, z)) ol.vertex3((lx + 1, ly + 1, z + 4)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((x + 1, y - 1, z)) ol.vertex3((lx + 1, ly - 1, z + 4)) ol.end() lx = x ly = y
def draw(self): self.i=self.i+1.0; #inverse persistence length self.thetad=0.25*(1.0+sin(2.0*pi*self.i/2000.0)) #RGB curliness offset offset=pi/6.0 #RGB curly-straight cycle frequency crlstrt=0.005 #RGB maximum curlyness curlmx=0.2 theta0B=curlmx*cos(self.i*crlstrt) theta0R=curlmx*cos(self.i*crlstrt+offset) theta0G=curlmx*cos(self.i*crlstrt+2.0*offset) self.thetaB=self.thetaB+random.gauss(theta0B,self.thetad) self.thetaR=self.thetaR+random.gauss(theta0R,self.thetad) self.thetaG=self.thetaG+random.gauss(theta0G,self.thetad) self.BX=np.append(self.BX[1:], self.BX[-1]+self.dr*cos(self.thetaB)) self.BY=np.append(self.BY[1:], self.BY[-1]+self.dr*sin(self.thetaB)) self.RX=np.append(self.RX[1:], self.RX[-1]+self.dr*cos(self.thetaR)) self.RY=np.append(self.RY[1:], self.RY[-1]+self.dr*sin(self.thetaR)) self.GX=np.append(self.GX[1:], self.GX[-1]+self.dr*cos(self.thetaG)) self.GY=np.append(self.GY[1:], self.GY[-1]+self.dr*sin(self.thetaG)) # derivative roughness parameter # b=0.1; # if b != 0.0: # [Fx,Fy]=gradient([self.BX;self.RX;self.GX;self.BY;self.RY;self.GY]) # self.BX=b*Fx(4,:)+self.BX # self.RX=b*Fx(5,:)+self.RX # self.GX=b*Fx(6,:)+self.GX # self.BY=b*Fx(1,:)+self.BY # self.RY=b*Fx(2,:)+self.RY # self.GY=b*Fx(3,:)+self.GY #combine paths rmult=0.0001; if 1: fmB=0.5 fmG=0.5 # self.BX=(self.BX+self.RX+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0 self.BX=(self.BX+self.RX)/2.0 self.BY=(self.BY+self.RY+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0 self.RX=(self.RX+self.GX+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0 self.RY=(self.RY+self.GY+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0 self.GX=(self.BX+self.GX+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0 self.GY=(self.BY+self.GY+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0 else: fmB=1.0 fmG=1.0 #spin frequency freq=0.01+random.gauss(0,0.002) self.BX=cos(freq*fmB)*self.BX-sin(freq*fmB)*self.BY self.BY=sin(freq*fmB)*self.BX+cos(freq*fmB)*self.BY self.RX=cos(freq)*self.RX-sin(freq)*self.RY self.RY=sin(freq)*self.RX+cos(freq)*self.RY self.GX=cos(freq*fmG)*self.GX-sin(freq*fmG)*self.GY self.GY=sin(freq*fmG)*self.GX+cos(freq*fmG)*self.GY #centering self.BX=self.BX-self.BX.mean() self.BY=self.BY-self.BY.mean() self.RX=self.RX-self.RX.mean() self.RY=self.RY-self.RY.mean() self.GX=self.GX-self.GX.mean() self.GY=self.GY-self.GY.mean() #scaling and bouncy factor bounce=5.0 self.fB = self.fB + ((self.fB+max(np.sqrt(self.BX**2+self.BY**2)))/2.0-self.fB)/bounce self.fR = self.fR + ((self.fR+max(np.sqrt(self.RX**2+self.RY**2)))/2.0-self.fR)/bounce self.fG = self.fG + ((self.fG+max(np.sqrt(self.GX**2+self.GY**2)))/2.0-self.fG)/bounce self.BX=self.BX/self.fB self.BY=self.BY/self.fB self.RX=self.RX/self.fR self.RY=self.RY/self.fR self.GX=self.GX/self.fG self.GY=self.GY/self.fG #################################### #LUX RENDERING CODE #################################### ol.loadIdentity3() ol.loadIdentity() # ol.color3(*(self.color_cycle())) ol.scale3((self.scale_factor,self.scale_factor,self.scale_factor)) theta_rot = 0.4*cos(1.7 * lux.time * self.ROT_RATE) + 0.6*cos(0.7 * lux.time * self.ROT_RATE) ol.rotate3Z(theta_rot) render_type = ol.POINTS current_hue_marker = self.writhe_current_hue current_hue_target = self.writhe_hue_target current_hue_step = self.writhe_hue_step # ol.color3(0.0,0.0,1.0) ol.begin(ol.POINTS) for i in range(self.BX.shape[0]): ol.color3(*(self.writhe_color_cycle())) ol.vertex3((self.BX[i], self.BY[i], -1)) ol.end() self.writhe_current_hue = current_hue_marker self.writhe_current_target = current_hue_target self.writhe_current_step = current_hue_step ol.begin(ol.POINTS) for i in range(self.BX.shape[0]): ol.color3(*(self.writhe_color_cycle())) ol.vertex3((-self.BX[i], self.BY[i], -1)) ol.end() self.writhe_current_hue = current_hue_marker self.writhe_current_target = current_hue_target self.writhe_current_step = current_hue_step ol.begin(ol.POINTS) for i in range(self.BX.shape[0]): ol.color3(*(self.writhe_color_cycle())) ol.vertex3((self.BX[i], -self.BY[i], -1)) ol.end() self.writhe_current_hue = current_hue_marker self.writhe_current_target = current_hue_target self.writhe_current_step = current_hue_step ol.begin(ol.POINTS) for i in range(self.BX.shape[0]): ol.color3(*(self.writhe_color_cycle())) ol.vertex3((-self.BX[i], -self.BY[i], -1)) ol.end()
def draw(self): theta = arange(0, 2 * pi, 2 * pi / self.N) # rotations in q-space mu = 0.01 std = 0.001 dth1 = random.gauss(mu, std) dth2 = random.gauss(mu, std) dth3 = random.gauss(mu, std) dth4 = random.gauss(mu, std) dth5 = random.gauss(mu, std) dth1b = random.gauss(mu, std) dth2b = random.gauss(mu, std) dth3b = random.gauss(mu, std) dth4b = random.gauss(mu, std) dth5b = random.gauss(mu, std) # dth1=self.dtheta*(1-2*(random.random()<self.cut)); # dth2=self.dtheta*(1-2*(random.random()<self.cut)); # dth3=self.dtheta*(1-2*(random.random()<self.cut)); # dth4=self.dtheta*(1-2*(random.random()<self.cut)); # dth5=self.dtheta*(1-2*(random.random()<self.cut)); # dth1b=self.dtheta*(1-2*(random.random()<self.cut)); # dth2b=self.dtheta*(1-2*(random.random()<self.cut)); # dth3b=self.dtheta*(1-2*(random.random()<self.cut)); # dth4b=self.dtheta*(1-2*(random.random()<self.cut)); # dth5b=self.dtheta*(1-2*(random.random()<self.cut)); self.th1 = self.th1 + dth1 self.th2 = self.th2 + dth2 self.th3 = self.th3 + dth3 self.th4 = self.th4 + dth4 self.th5 = self.th5 + dth5 self.th1b = self.th1b + dth1b self.th2b = self.th2b + dth2b self.th3b = self.th3b + dth3b self.th4b = self.th4b + dth4b self.th5b = self.th5b + dth5b c1 = self.m1 * cos(self.th1) s1 = self.m1 * sin(self.th1) c2 = self.m2 * cos(self.th2) s2 = self.m2 * sin(self.th2) c3 = self.m3 * cos(self.th3) s3 = self.m3 * sin(self.th3) c4 = self.m4 * cos(self.th4) s4 = self.m4 * sin(self.th4) c5 = self.m5 * cos(self.th5) s5 = self.m5 * sin(self.th5) X = c1 * cos(theta + self.th1b) + c2 * cos( 2 * theta + self.th2b) + c3 * cos(3 * theta + self.th3b) + c4 * cos( 4 * theta + self.th4b) + c5 * cos(5 * theta + self.th5b) Y = s1 * sin(theta + self.th1b) + s2 * sin( 2 * theta + self.th2b) + s3 * sin(3 * theta + self.th3b) + s4 * sin( 4 * theta + self.th4b) + s5 * sin(5 * theta + self.th5b) X = (X - X.mean()).astype("complex") Y = (Y - Y.mean()).astype("complex") s = arange(1, self.N + 1, 1) Xtemp = X**self.p1x * Y**self.p1y + 2 * s * 1j - self.N * 1j Ytemp = X**self.p2x * Y**self.p2y + 2 * s * 1j - self.N * 1j X = Xtemp.real Y = Ytemp.real X = tanh(2 * X) Y = tanh(2 * Y) ol.loadIdentity3() ol.loadIdentity() ol.color3(*(self.color_cycle())) render_type = ol.POINTS ol.begin(ol.POINTS) for i in range(X.shape[0]): ol.vertex3((X[i], Y[i], -1)) ol.vertex3((X[0], Y[0], -1)) ol.end() ol.begin(ol.POINTS) for i in range(X.shape[0]): ol.vertex3((-X[i], Y[i], -1)) ol.vertex3((-X[0], Y[0], -1)) ol.end() ol.begin(ol.POINTS) for i in range(X.shape[0]): ol.vertex3((0.7 * X[i], -0.7 * Y[i], -1)) ol.vertex3((0.7 * X[0], -0.7 * Y[0], -1)) ol.end() ol.begin(ol.POINTS) for i in range(X.shape[0]): ol.vertex3((-0.7 * X[i], -0.7 * Y[i], -1)) ol.vertex3((-0.7 * X[0], -0.7 * Y[0], -1)) ol.end()
def draw(self): self.i = self.i + 1.0 #inverse persistence length self.thetad = 0.25 * (1.0 + sin(2.0 * pi * self.i / 2000.0)) #RGB curliness offset offset = pi / 6.0 #RGB curly-straight cycle frequency crlstrt = 0.005 #RGB maximum curlyness curlmx = 0.2 theta0B = curlmx * cos(self.i * crlstrt) theta0R = curlmx * cos(self.i * crlstrt + offset) theta0G = curlmx * cos(self.i * crlstrt + 2.0 * offset) self.thetaB = self.thetaB + random.gauss(theta0B, self.thetad) self.thetaR = self.thetaR + random.gauss(theta0R, self.thetad) self.thetaG = self.thetaG + random.gauss(theta0G, self.thetad) self.BX = np.append(self.BX[1:], self.BX[-1] + self.dr * cos(self.thetaB)) self.BY = np.append(self.BY[1:], self.BY[-1] + self.dr * sin(self.thetaB)) self.RX = np.append(self.RX[1:], self.RX[-1] + self.dr * cos(self.thetaR)) self.RY = np.append(self.RY[1:], self.RY[-1] + self.dr * sin(self.thetaR)) self.GX = np.append(self.GX[1:], self.GX[-1] + self.dr * cos(self.thetaG)) self.GY = np.append(self.GY[1:], self.GY[-1] + self.dr * sin(self.thetaG)) # derivative roughness parameter # b=0.1; # if b != 0.0: # [Fx,Fy]=gradient([self.BX;self.RX;self.GX;self.BY;self.RY;self.GY]) # self.BX=b*Fx(4,:)+self.BX # self.RX=b*Fx(5,:)+self.RX # self.GX=b*Fx(6,:)+self.GX # self.BY=b*Fx(1,:)+self.BY # self.RY=b*Fx(2,:)+self.RY # self.GY=b*Fx(3,:)+self.GY #combine paths rmult = 0.0001 if 1: fmB = 0.5 fmG = 0.5 # self.BX=(self.BX+self.RX+(2*random.uniform(1,self.N)-1.0)*rmult)/2.0 self.BX = (self.BX + self.RX) / 2.0 self.BY = (self.BY + self.RY + (2 * random.uniform(1, self.N) - 1.0) * rmult) / 2.0 self.RX = (self.RX + self.GX + (2 * random.uniform(1, self.N) - 1.0) * rmult) / 2.0 self.RY = (self.RY + self.GY + (2 * random.uniform(1, self.N) - 1.0) * rmult) / 2.0 self.GX = (self.BX + self.GX + (2 * random.uniform(1, self.N) - 1.0) * rmult) / 2.0 self.GY = (self.BY + self.GY + (2 * random.uniform(1, self.N) - 1.0) * rmult) / 2.0 else: fmB = 1.0 fmG = 1.0 #spin frequency freq = 0.01 + random.gauss(0, 0.002) self.BX = cos(freq * fmB) * self.BX - sin(freq * fmB) * self.BY self.BY = sin(freq * fmB) * self.BX + cos(freq * fmB) * self.BY self.RX = cos(freq) * self.RX - sin(freq) * self.RY self.RY = sin(freq) * self.RX + cos(freq) * self.RY self.GX = cos(freq * fmG) * self.GX - sin(freq * fmG) * self.GY self.GY = sin(freq * fmG) * self.GX + cos(freq * fmG) * self.GY #centering self.BX = self.BX - self.BX.mean() self.BY = self.BY - self.BY.mean() self.RX = self.RX - self.RX.mean() self.RY = self.RY - self.RY.mean() self.GX = self.GX - self.GX.mean() self.GY = self.GY - self.GY.mean() #scaling and bouncy factor bounce = 5.0 self.fB = self.fB + ( (self.fB + max(np.sqrt(self.BX**2 + self.BY**2))) / 2.0 - self.fB) / bounce self.fR = self.fR + ( (self.fR + max(np.sqrt(self.RX**2 + self.RY**2))) / 2.0 - self.fR) / bounce self.fG = self.fG + ( (self.fG + max(np.sqrt(self.GX**2 + self.GY**2))) / 2.0 - self.fG) / bounce self.BX = self.BX / self.fB self.BY = self.BY / self.fB self.RX = self.RX / self.fR self.RY = self.RY / self.fR self.GX = self.GX / self.fG self.GY = self.GY / self.fG #################################### #LUX RENDERING CODE #################################### ol.loadIdentity3() ol.loadIdentity() # ol.color3(*(self.color_cycle())) ol.scale3((self.scale_factor, self.scale_factor, self.scale_factor)) theta_rot = 0.4 * cos(1.7 * lux.time * self.ROT_RATE) + 0.6 * cos( 0.7 * lux.time * self.ROT_RATE) ol.rotate3Z(theta_rot) render_type = ol.POINTS current_hue_marker = self.writhe_current_hue current_hue_target = self.writhe_hue_target current_hue_step = self.writhe_hue_step # ol.color3(0.0,0.0,1.0) ol.begin(ol.POINTS) for i in range(self.BX.shape[0]): ol.color3(*(self.writhe_color_cycle())) ol.vertex3((self.BX[i], self.BY[i], -1)) ol.end() self.writhe_current_hue = current_hue_marker self.writhe_current_target = current_hue_target self.writhe_current_step = current_hue_step ol.begin(ol.POINTS) for i in range(self.BX.shape[0]): ol.color3(*(self.writhe_color_cycle())) ol.vertex3((-self.BX[i], self.BY[i], -1)) ol.end() self.writhe_current_hue = current_hue_marker self.writhe_current_target = current_hue_target self.writhe_current_step = current_hue_step ol.begin(ol.POINTS) for i in range(self.BX.shape[0]): ol.color3(*(self.writhe_color_cycle())) ol.vertex3((self.BX[i], -self.BY[i], -1)) ol.end() self.writhe_current_hue = current_hue_marker self.writhe_current_target = current_hue_target self.writhe_current_step = current_hue_step ol.begin(ol.POINTS) for i in range(self.BX.shape[0]): ol.color3(*(self.writhe_color_cycle())) ol.vertex3((-self.BX[i], -self.BY[i], -1)) ol.end()
ol.translate3((0, 0, -3)) for i in range(2): ol.scale3((0.6, 0.6, 0.6)) ol.rotate3Z(time * pi * 0.1) ol.rotate3X(time * pi * 0.8) ol.rotate3Y(time * pi * 0.73) ol.begin(ol.LINESTRIP) ol.vertex3((-1, -1, -1), ol.C_WHITE) ol.vertex3((1, -1, -1), ol.C_WHITE) ol.vertex3((1, 1, -1), ol.C_WHITE) ol.vertex3((-1, 1, -1), ol.C_WHITE) ol.vertex3((-1, -1, -1), ol.C_WHITE) ol.vertex3((-1, -1, 1), ol.C_WHITE) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((1, 1, 1), ol.C_WHITE) ol.vertex3((-1, 1, 1), ol.C_WHITE) ol.vertex3((-1, -1, 1), ol.C_WHITE) ol.vertex3((1, -1, 1), ol.C_WHITE) ol.vertex3((1, 1, 1), ol.C_WHITE) ol.vertex3((1, 1, -1), ol.C_WHITE) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((1, -1, -1), ol.C_WHITE) ol.vertex3((1, -1, 1), ol.C_WHITE) ol.end()