def __init__(self, screen): Mode.__init__(self, screen) #create a loading screen Loading(screen) self.loading = True #border color self.surface.fill((0, 0, 0)) screen.blit(self.surface, (0, 0)) #create border at top and bottom self.game_dimension = (screen.get_size()[0], screen.get_size()[1] * 0.75) self.game_surface = pygame.Surface(self.game_dimension) #MUST BE FIXED self.stage = Stage(self.game_dimension) self.stage.load_stage('Intro') self.map = self.stage.rooms[0] #133442__klankbeeld__horror-ambience-11.wav pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096) self.fade = Fade(screen, 'in', 3) #add player self.player = Player(self.map.spawn_x, self.map.spawn_y, self.map.entity) self.map.entity.append(self.player) self.shade = Shade(self.player, 0, self.fade.surface) #test self.loading = False self.next_before = True
def extended_fade_in(self, segment, duration): """Add a fade-in to a segment that extends the beginning of the segment. :param segment: Segment to fade in :type segment: :py:class:`radiotool.composer.Segment` :param duration: Duration of fade-in (in seconds) :returns: The fade that has been added to the composition :rtype: :py:class:`Fade` """ dur = int(duration * segment.track.samplerate) if segment.start - dur >= 0: segment.start -= dur else: raise Exception("Cannot create fade-in that extends " "past the track's beginning") if segment.comp_location - dur >= 0: segment.comp_location -= dur else: raise Exception( "Cannot create fade-in the extends past the score's beginning") segment.duration += dur f = Fade(segment.track, segment.comp_location_in_seconds, duration, 0.0, 1.0) self.add_dynamic(f) return f
def fade_in(self, segment, duration, fade_type="linear"): """Adds a fade in to a segment in the composition :param segment: Segment to fade in to :type segment: :py:class:`radiotool.composer.Segment` :param duration: Duration of fade-in (in seconds) :type duration: float :returns: The fade that has been added to the composition :rtype: :py:class:`Fade` """ f = Fade(segment.track, segment.comp_location_in_seconds, duration, 0.0, 1.0, fade_type=fade_type) self.add_dynamic(f) return f
def process(infile, day, timeid): try: page = Image.open(os.path.join('base', 'Calendar_2014.png')) except IOError: print "Cannot open calendar page base" return photo_size = (A4_WIDTH * 3 / 4, A4_HEIGHT * 3 / 8) fade = Fade() photo = fade.apply_mask(infile, photo_size) photo_left = (A4_WIDTH - photo_size[0]) / 2 photo_top = 520 photo_right = photo_left + photo_size[0] photo_bottom = photo_top + photo_size[1] photo_rect = (photo_left, photo_top, photo_right, photo_bottom) page.paste(photo, photo_rect) create_title(page, (A4_WIDTH, A4_HEIGHT), photo_rect, day, timeid) tools.mkdir_p(os.path.join('png', day)) png_file = os.path.join('png', day, '{}.jpg'.format(timeid)) page.save(png_file, quality=75) tools.print_image(png_file)
def __init__(self, screen): Mode.__init__(self, screen) #create a loading screen Loading(screen) #now do all the intial stuff self.surface.fill((0, 0, 0)) screen.blit(self.surface, (0, 0)) #create border at top and bottom game_dimension = (screen.get_size()[0], screen.get_size()[1] * 0.75) self.game_surface = pygame.Surface(game_dimension) self.stage = Stage(game_dimension) self.stage.load_stage('round_1') self.map = self.stage.rooms[0] self.fade = Fade(screen, 'in', 3) #add player self.player = Player(self.map.spawn_x, self.map.spawn_y, self.map.entity) self.map.entity.append(self.player)
def extended_fade_out(self, segment, duration): """Add a fade-out to a segment that extends the beginning of the segment. :param segment: Segment to fade out :type segment: :py:class:`radiotool.composer.Segment` :param duration: Duration of fade-out (in seconds) :returns: The fade that has been added to the composition :rtype: :py:class:`Fade` """ dur = int(duration * segment.track.samplerate) if segment.start + segment.duration + dur <\ segment.track.duration: segment.duration += dur else: raise Exception( "Cannot create fade-out that extends past the track's end") score_loc_in_seconds = segment.comp_location_in_seconds +\ segment.duration_in_seconds - duration f = Fade(segment.track, score_loc_in_seconds, duration, 1.0, 0.0) self.add_dynamic(f) return f
def fade_out(self, segment, duration, fade_type="linear"): """Adds a fade out to a segment in the composition :param segment: Segment to fade out :type segment: :py:class:`radiotool.composer.Segment` :param duration: Duration of fade-out (in seconds) :type duration: float :returns: The fade that has been added to the composition :rtype: :py:class:`Fade` """ score_loc_in_seconds = segment.comp_location_in_seconds +\ segment.duration_in_seconds - duration f = Fade(segment.track, score_loc_in_seconds, duration, 1.0, 0.0, fade_type=fade_type) # bug fixing... perhaps f.comp_location = segment.comp_location + segment.duration -\ int(duration * segment.track.samplerate) self.add_dynamic(f) return f
def add_music_cue(self, track, comp_cue, song_cue, duration=6.0, padding_before=12.0, padding_after=12.0): """Add a music cue to the composition. This doesn't do any audio analysis, it just aligns a specified point in the track (presumably music) with a location in the composition. See UnderScore_ for a visualization of what this is doing to the music track. .. _UnderScore: http://vis.berkeley.edu/papers/underscore/ :param track: Track to align in the composition :type track: :py:class:`radiotool.composer.Track` :param float comp_cue: Location in composition to align music cue (in seconds) :param float song_cue: Location in the music track to align with the composition cue (in seconds) :param float duration: Duration of music after the song cue before the music starts to fade out (in seconds) :param float padding_before: Duration of music playing softly before the music cue/composition cue (in seconds) :param float padding_after: Duration of music playing softly after the music cue/composition cue (in seconds) """ self.tracks.add(track) pre_fade = 3 post_fade = 3 if padding_before + pre_fade > song_cue: padding_before = song_cue - pre_fade if padding_before + pre_fade > score_cue: padding_before = score_cue - pre_fade s = Segment( track, score_cue - padding_before - pre_fade, song_cue - padding_before - pre_fade, pre_fade + padding_before + duration + padding_after + post_fade) self.add_segment(s) d = [] dyn_adj = 1 track.current_frame = 0 d.append( Fade(track, score_cue - padding_before - pre_fade, pre_fade, 0, .1 * dyn_adj, fade_type="linear")) d.append( Fade(track, score_cue - padding_before, padding_before, .1 * dyn_adj, .4 * dyn_adj, fade_type="exponential")) d.append(Volume(track, score_cue, duration, .4 * dyn_adj)) d.append( Fade(track, score_cue + duration, padding_after, .4 * dyn_adj, 0, fade_type="exponential")) d.append( Fade(track, score_cue + duration + padding_after, post_fade, .1 * dyn_adj, 0, fade_type="linear")) self.add_dynamics(d)