video recorder request; points; apply motion overflow
This commit is contained in:
parent
334cb21762
commit
dca094220b
|
@ -124,10 +124,10 @@ class Account:
|
||||||
def get_current_interval(self):
|
def get_current_interval(self):
|
||||||
return self.interval[self.interval_index]
|
return self.interval[self.interval_index]
|
||||||
|
|
||||||
def increment_interval_index(self):
|
def increment_interval_index(self, increment=1):
|
||||||
index = self.interval_index + 1
|
index = self.interval_index + increment
|
||||||
if index >= len(self.interval):
|
while index >= len(self.interval):
|
||||||
index = 0
|
index -= len(self.interval)
|
||||||
self.interval_index = index
|
self.interval_index = index
|
||||||
|
|
||||||
def reset_interval(self):
|
def reset_interval(self):
|
||||||
|
|
|
@ -94,6 +94,7 @@ class Configuration(RawConfigParser):
|
||||||
set_option(section, "file-extension", "png", False)
|
set_option(section, "file-extension", "png", False)
|
||||||
section = "video-recordings"
|
section = "video-recordings"
|
||||||
add_section(section)
|
add_section(section)
|
||||||
|
set_option(section, "enable", "no", False)
|
||||||
set_option(section, "rel-path", "vids", False)
|
set_option(section, "rel-path", "vids", False)
|
||||||
set_option(section, "directory-name-format", "%Y%m%d%H%M%S", False)
|
set_option(section, "directory-name-format", "%Y%m%d%H%M%S", False)
|
||||||
set_option(section, "file-extension", "png", False)
|
set_option(section, "file-extension", "png", False)
|
||||||
|
@ -388,7 +389,9 @@ class TypeDeclarations(dict):
|
||||||
|
|
||||||
"video-recordings": {"path": ["rel-path", "path"],
|
"video-recordings": {"path": ["rel-path", "path"],
|
||||||
|
|
||||||
"int": "framerate"},
|
"int": "framerate",
|
||||||
|
|
||||||
|
"bool": "enable"},
|
||||||
|
|
||||||
"setup": {"list": ["classifiers", "resource-search-path",
|
"setup": {"list": ["classifiers", "resource-search-path",
|
||||||
"requirements", "data-exclude",
|
"requirements", "data-exclude",
|
||||||
|
|
|
@ -54,7 +54,8 @@ class Game(GameChild):
|
||||||
self.update()
|
self.update()
|
||||||
else:
|
else:
|
||||||
self.interpolator.gui.update()
|
self.interpolator.gui.update()
|
||||||
self.video_recorder.update()
|
if self.video_recorder.requested:
|
||||||
|
self.video_recorder.update()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.mainloop.run()
|
self.mainloop.run()
|
||||||
|
|
|
@ -123,3 +123,4 @@ class Note(Samples):
|
||||||
self.fadeout(fadeout)
|
self.fadeout(fadeout)
|
||||||
if channel and panning:
|
if channel and panning:
|
||||||
channel.set_volume(*panning)
|
channel.set_volume(*panning)
|
||||||
|
return channel
|
||||||
|
|
|
@ -2,7 +2,6 @@ from os import listdir
|
||||||
from os.path import isfile, join
|
from os.path import isfile, join
|
||||||
from sys import exc_info, stdout
|
from sys import exc_info, stdout
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from traceback import print_exc, print_stack
|
|
||||||
|
|
||||||
from pygame import Color, Rect, Surface
|
from pygame import Color, Rect, Surface
|
||||||
from pygame.image import load
|
from pygame.image import load
|
||||||
|
@ -237,6 +236,11 @@ class Location(Rect):
|
||||||
def reset_motion_overflow(self):
|
def reset_motion_overflow(self):
|
||||||
self.motion_overflow.place_at_origin()
|
self.motion_overflow.place_at_origin()
|
||||||
|
|
||||||
|
def apply_motion_overflow(self, coordinates=None):
|
||||||
|
if coordinates is None:
|
||||||
|
coordinates = self.topleft
|
||||||
|
return self.motion_overflow + coordinates
|
||||||
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
self.hidden = True
|
self.hidden = True
|
||||||
|
|
||||||
|
@ -379,13 +383,14 @@ class Frameset:
|
||||||
if len(self.order) > 1:
|
if len(self.order) > 1:
|
||||||
self.increment_index()
|
self.increment_index()
|
||||||
|
|
||||||
def increment_index(self):
|
def increment_index(self, increment=None):
|
||||||
increment = 1 if not self.reversed else -1
|
if increment is None:
|
||||||
|
increment = 1 if not self.reversed else -1
|
||||||
index = self.current_index + increment
|
index = self.current_index + increment
|
||||||
if index < 0:
|
while index < 0:
|
||||||
index = self.length() - 1
|
index += self.length()
|
||||||
elif index >= self.length():
|
while index >= self.length():
|
||||||
index = 0
|
index -= self.length()
|
||||||
self.current_index = index
|
self.current_index = index
|
||||||
|
|
||||||
def length(self):
|
def length(self):
|
||||||
|
|
|
@ -12,11 +12,17 @@ class VideoRecorder(GameChild):
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
GameChild.__init__(self, parent)
|
GameChild.__init__(self, parent)
|
||||||
self.display_surface = self.get_display_surface()
|
self.set_requested()
|
||||||
self.delegate = self.get_delegate()
|
if self.requested:
|
||||||
self.load_configuration()
|
self.display_surface = self.get_display_surface()
|
||||||
self.reset()
|
self.delegate = self.get_delegate()
|
||||||
self.subscribe(self.respond)
|
self.load_configuration()
|
||||||
|
self.reset()
|
||||||
|
self.subscribe(self.respond)
|
||||||
|
|
||||||
|
def set_requested(self):
|
||||||
|
self.requested = self.get_configuration("video-recordings")["enable"] \
|
||||||
|
or self.check_command_line("-enable-video")
|
||||||
|
|
||||||
def load_configuration(self):
|
def load_configuration(self):
|
||||||
config = self.get_configuration("video-recordings")
|
config = self.get_configuration("video-recordings")
|
||||||
|
|
|
@ -1,7 +1,30 @@
|
||||||
from math import sin, cos, atan2
|
from math import sin, cos, atan2, radians
|
||||||
|
|
||||||
def get_step(start, end, speed):
|
def get_step(start, end, speed):
|
||||||
x0, y0 = start
|
x0, y0 = start
|
||||||
x1, y1 = end
|
x1, y1 = end
|
||||||
angle = atan2(x1 - x0, y1 - y0)
|
angle = atan2(x1 - x0, y1 - y0)
|
||||||
return speed * sin(angle), speed * cos(angle)
|
return speed * sin(angle), speed * cos(angle)
|
||||||
|
|
||||||
|
def get_endpoint(start, angle, magnitude):
|
||||||
|
x0, y0 = start
|
||||||
|
angle = radians(angle)
|
||||||
|
return x0 + sin(angle) * magnitude, y0 - cos(angle) * magnitude
|
||||||
|
|
||||||
|
def rotate_2d(point, center, angle, translate_angle=True):
|
||||||
|
if translate_angle:
|
||||||
|
angle = radians(angle)
|
||||||
|
x, y = point
|
||||||
|
cx, cy = center
|
||||||
|
return cos(angle) * (x - cx) - sin(angle) * (y - cy) + cx, \
|
||||||
|
sin(angle) * (x - cx) + cos(angle) * (y - cy) + cy
|
||||||
|
|
||||||
|
def get_points_on_circle(center, radius, count, offset=0):
|
||||||
|
angle_step = 360.0 / count
|
||||||
|
points = []
|
||||||
|
current_angle = 0
|
||||||
|
for _ in xrange(count):
|
||||||
|
points.append(rotate_2d((center[0], center[1] - radius), center,
|
||||||
|
current_angle + offset))
|
||||||
|
current_angle += angle_step
|
||||||
|
return points
|
||||||
|
|
Loading…
Reference in New Issue