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() 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): 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() 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): 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() 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): 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): 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): 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() 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): 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): 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): 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()
while True: ol.loadIdentity3() ol.loadIdentity() font = ol.getDefaultFont() s = "Hi!" w = ol.getStringWidth(font, 0.2, s) ol.drawString(font, (-w / 2, 0.1), 0.2, ol.C_WHITE, s) ol.perspective(60, 1, 1, 100) 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)
font = ol.getDefaultFont() s = "Hi!" w = ol.getStringWidth(font, 0.2, s) ol.drawString(font, (-w/2,0.1), 0.2, ol.C_WHITE, s) ol.perspective(60, 1, 1, 100) ol.translate3((0, 0, -3)) for i in range(2): if (i == 1): ol.color3(1.0,0.0,0.0); else: ol.color3(0.0,1.0,0.0); 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.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))