示例#1
0
base_image = pygame.image.load("res/sunflowers1.jpg")

# Zoom in on a position within a larger image slowly
# Zoom back out
# Repeat with a new position

old_image = Surface(display_size)
while True:
	# Zoom in and out again
	pos = (random(), random())
	
	steps = 100
	for x in chain(
			tween(easeInOutCubic, 0, steps*0.6, steps, True, False), 
			tween(easeInOutCubic, steps*0.6, 0, steps, True, False)):
		
		zoom = x / float(steps);
		frame = get_window_at_pos (
			smoothscale(base_image, 
				(
					int(round((base_image.get_width()-display_size[0]) * zoom + display_size[0])), 
					int(round((base_image.get_height()-display_size[1]) * zoom + display_size[1]))
				)),
			pos)

		cans.drawSurface(frame)
		cans.update()
		for event in pygame.event.get():
			if event.type==QUIT:
				sys.exit(0)
		time.sleep(1/float(steps))
示例#2
0
		for y in range (0, display_size[1]):
			# Show either gold or a random green
			rand_color = Color(0, 0, 0, 0)
			if (random() > 0.7):
				rand_color.hsla = (50, 100, 50, 100)
			else:
				# Green
				brightness = 18
				if (random() > 0.4):
					brightness = 28
				rand_color.hsla = (88 + (104 - 88) * random(), 100, brightness, 100)
			
			new_image.set_at((x, y), rand_color)
	
	# Fade onto old image
	for alpha in range (0, 256, 12):
		intermediate_image = old_image.copy()
		new_image.set_alpha(alpha)
		intermediate_image.blit(new_image, (0, 0))
		cans.drawSurface(intermediate_image)
		
		cans.update()
		for event in pygame.event.get():
			if event.type==QUIT:
				sys.exit(0)
		time.sleep(0.02)
		
	time.sleep(0.12)
	
	new_image.set_alpha(255)
	old_image = new_image
示例#3
0
			# Show either gold or a random green
			rand_color = Color(0, 0, 0, 0)
			if (random() > 0.9):
				rand_color.hsla = (50, 100, 50, 100)
			else:
				# Green
				brightness = 10
				if (random() > 0.4):
					brightness = 28
				rand_color.hsla = (88 + (104 - 88) * random(), 100, brightness, 100)
			
			new_image.set_at((x, y), rand_color)
	
	# Fade onto old image
	steps = 30
	for alpha in tween(easeInOutSine, 0,255,steps,True,False):
		intermediate_image = old_image.copy()
		new_image.set_alpha(alpha)
		intermediate_image.blit(new_image, (0, 0))
		cans.drawSurface(smoothscale(intermediate_image, (display_size[0]*2, display_size[1]*2)))
		
		cans.update()
		for event in pygame.event.get():
			if event.type==QUIT:
				sys.exit(0)
		time.sleep(0.9/steps)
		
	#time.sleep(0.12)
	
	new_image.set_alpha(255)
	old_image = new_image
示例#4
0
文件: cgol.py 项目: fenceFoil/canopto
	new_texture = None
	old_texture = Surface(display_size)
	old_texture.fill(Color(0, 0, 0))
	remaining_frames = None
	while (remaining_frames == None) or (remaining_frames > 0):
		# Render a new frame
		new_texture = Surface(display_size)
		new_texture.fill(Color(0, 0, 0))
		new_texture.blit(frame_to_surface(curr_frame, cell_color), (0, 0))
		
		# Fade onto old frame
		for alpha in range (0, 256, 12):
			intermediate_image = old_texture.copy()
			new_texture.set_alpha(alpha)
			intermediate_image.blit(new_texture, (0, 0))
			cans.drawSurface(intermediate_image)
			
			cans.update()
			for event in pygame.event.get():
				if event.type==QUIT:
					sys.exit(0)
			time.sleep(0.02 * ratio_living_cells(curr_frame))
		
		cans.drawSurface(new_texture)
		cans.update()
				
		time.sleep(1.1 * ratio_living_cells(curr_frame))
		
		# Log previous frame into last frame and the history
		history.append(curr_frame)
		last_frame = curr_frame
示例#5
0
# Repeat forever

colors = [Color(0, 0, 0, 255), Color(0, 255, 255, 0)]
curr_color = 0
cycle_fwd = True
while True:
	new_image = Surface(display_size)
	new_image.fill(colors[curr_color])
	
	hue = colors[1].hsla[0]
	if (cycle_fwd):
		hue = (hue + 2)
		if (hue >= 360):
			cycle_fwd = False
			hue = 359
	else:
		hue = hue - 2
		if (hue < 0):
			hue = 0
			cycle_fwd = True
	colors[1].hsla = (hue, 100, 50, 100)
	
	cans.drawSurface(new_image)
		
	cans.update()
	for event in pygame.event.get():
		if event.type==QUIT:
			sys.exit(0)
	time.sleep(0.06)
	
	curr_color = (curr_color+1) % len(colors)