def simple_add_scalar_resize(self, keep_center = True, intensity: str = "medium", smooth: Number = 0.08, start_value: Number = 1, custom: str = "" ) -> None: intensities = { "low": ma_scalar_resize_ic_low, "medium": ma_scalar_resize_ic_medium, "high": ma_scalar_resize_ic_high, "high-plus": ma_scalar_resize_ic_high_plus, "custom": custom } if intensity not in list(intensities.keys()): raise RuntimeError("Unhandled resize intensity [%s]" % intensity) interpolation_changer = intensities[intensity] self.add_module_resize( keep_center=keep_center, interpolation=MMVInterpolation({ "function": "remaining_approach", "aggressive": smooth, "start": start_value, }), interpolation_changer = interpolation_changer, )
def add_module_vignetting(self, minimum: Number, interpolation_changer, center_function_x, center_function_y, smooth: Number, start_value: Number, ) -> None: self.add_module({ "vignetting": { "object": MMVModifierVignetting( context=self.mmv.context, minimum=minimum, center_function_x=center_function_x, center_function_y=center_function_y, interpolation_changer=interpolation_changer, interpolation = MMVInterpolation({ "function": "remaining_approach", "aggressive": smooth, }), start_value=start_value, ), }, })
def simple_add_linear_blur(self, intensity: str = "medium", smooth: Number = 0.1, custom: str = "" ) -> None: intensities = { "low": ma_gaussian_blur_ic_low, "medium": ma_gaussian_blur_ic_medium, "high": ma_gaussian_blur_ic_high, "custom": custom } if not intensity in list(intensities.keys()): raise RuntimeError("Unhandled blur intensity [%s]" % intensity) interpolation_changer = intensities[intensity] self.add_module_blur( interpolation=MMVInterpolation({ "function": "remaining_approach", "aggressive": smooth, "start": 0, }), interpolation_changer=interpolation_changer, )
def ma_vignetting_ic_high( start_value: Number, interpolation: MMVInterpolation, average_audio_value: Number, width: Number, height: Number, ) -> None: change = (1200 / 720) * height interpolation.target_value = start_value - (change * average_audio_value)
def simple_add_path_modifier_shake(self, shake_max_distance: Number, x_smoothness: Number=0.01, y_smoothness: Number=0.02 ) -> None: self.object.animation[self.animation_index]["position"]["path"].append( MMVModifierShake( interpolation_x=MMVInterpolation({ "function": "remaining_approach", "aggressive": x_smoothness, }), interpolation_y=MMVInterpolation({ "function": "remaining_approach", "aggressive": y_smoothness, }), distance=shake_max_distance, ) )
def simple_add_visualizer_circle(self, minimum_bar_size: Number, width: Number, height: Number, mode: str = "symetric", responsiveness: Number = 0.25, pre_fft_smoothing: int = 2, pos_fft_smoothing: int = 0, subdivide:int = 2 ) -> None: self.add_module_visualizer( vis_type="circle", vis_mode=mode, width=width, height=height, minimum_bar_size=minimum_bar_size, interpolation=MMVInterpolation({ "function": "remaining_approach", "aggressive": responsiveness, }), pre_fft_smoothing=pre_fft_smoothing, pos_fft_smoothing=pos_fft_smoothing, subdivide=subdivide, )
def ma_scalar_resize_ic_high_plus(interpolation: MMVInterpolation, average_audio_value: Number) -> None: interpolation.target_value = 1 + average_audio_value * 4.4
def ma_scalar_resize_ic_medium(interpolation: MMVInterpolation, average_audio_value: Number) -> None: interpolation.target_value = 1 + average_audio_value * 2.5
def ma_gaussian_blur_ic_high(interpolation: MMVInterpolation, average_audio_value: Number) -> None: interpolation.target_value = average_audio_value * 20
def preset_bottom_mid_top(self): resolution_ratio_multiplier = self.mmv.context.resolution_ratio_multiplier particle = MMVImage(self.mmv) particle.image.load_from_path( self.mmv.utils.random_file_from_dir(self.mmv.context.assets + os.path.sep + "particles")) horizontal_randomness = int(50 * resolution_ratio_multiplier) vertical_randomness_min = self.mmv.context.height // 1.7 vertical_randomness_max = self.mmv.context.height // 2.3 x1 = random.randint(0, self.mmv.context.width) y1 = self.mmv.context.height x2 = x1 + random.randint(-horizontal_randomness, horizontal_randomness) y2 = y1 + random.randint(-vertical_randomness_min, -vertical_randomness_max) x3 = x2 + random.randint(-horizontal_randomness, horizontal_randomness) y3 = y2 + random.randint(-vertical_randomness_min, -vertical_randomness_max) particle_shake = MMVModifierShake( interpolation_x=MMVInterpolation({ "function": "remaining_approach", "aggressive": 0.01, "start": 0, }), interpolation_y=MMVInterpolation({ "function": "remaining_approach", "aggressive": 0.04, "start": 0, }), distance=18, mode=ModifierMode.OFFSET_VALUE, ) fast = 0.04 fade_intensity = random.uniform(0.1, 0.7) this_steps = random.randint(50, 100) particle.animation[0] = { "position": { "path": [ MMVModifierLine( start=(x1, y1), end=(x2, y2), interpolation_x=MMVInterpolation({ "function": "remaining_approach", "aggressive": fast, }), interpolation_y=MMVInterpolation({ "function": "remaining_approach", "aggressive": fast, }), mode=ModifierMode.OVERRIDE_VALUE_RESET_OFFSET, ), particle_shake ], }, "animation": { "steps": this_steps, }, "modules": { "fade": { "object": MMVModifierFade( interpolation=MMVInterpolation({ "function": "linear", "total_steps": 30, "start": 0, "end": fade_intensity, })) } } } this_steps = random.randint(150, 200) particle.animation[1] = { "position": { "path": [ MMVModifierLine( start=(x2, y2), end=(x3, y3), interpolation_x=MMVInterpolation({ "function": "remaining_approach", "aggressive": fast, }), interpolation_y=MMVInterpolation({ "function": "remaining_approach", "aggressive": fast, }), mode=ModifierMode.OVERRIDE_VALUE_RESET_OFFSET, ), particle_shake ], }, "animation": { "steps": this_steps }, "modules": { "fade": { "object": MMVModifierFade( interpolation=MMVInterpolation({ "function": "linear", "total_steps": 30, "start": fade_intensity, "end": 0, })) } } } particle.image.resize_by_ratio(random.uniform( 0.05 * resolution_ratio_multiplier, 0.15 * resolution_ratio_multiplier), override=True) return particle
def preset_middle_out(self): particle = MMVImage(self.mmv) particle.image.load_from_path( self.mmv.utils.random_file_from_dir(self.mmv.context.assets + os.path.sep + "particles")) horizontal_randomness = int(50 * resolution_ratio_multiplier) vertical_randomness_min = self.mmv.context.height // 1.7 vertical_randomness_max = self.mmv.context.height // 2.3 half_screen_x = self.mmv.context.width // 2 half_screen_y = self.mmv.context.height // 2 x1 = half_screen_x y1 = half_screen_y x2 = x1 + random.randint(-half_screen_x * 2, half_screen_x * 2) y2 = y1 + random.randint(-half_screen_y * 2, half_screen_y * 2) particle_shake = MMVModifierShake( interpolation_x=MMVInterpolation({ "function": "remaining_approach", "aggressive": 0.01, "start": 0, }), interpolation_y=MMVInterpolation({ "function": "remaining_approach", "aggressive": 0.04, "start": 0, }), distance=18, mode=ModifierMode.OFFSET_VALUE, ) fast = 0.05 fade_intensity = random.uniform(0.1, 0.7) this_steps = 2 particle.animation[0] = { "position": { "path": [ MMVModifierPoint( x=x1, y=y1, mode=ModifierMode.OVERRIDE_VALUE_RESET_OFFSET) ], }, "animation": { "steps": this_steps, }, "modules": { "fade": { "object": MMVModifierFade( interpolation=MMVInterpolation({ "function": "linear", "total_steps": 30, "start": 0, "end": fade_intensity, })) } } } this_steps = random.randint(50, 100) particle.animation[0] = { "position": { "path": [ MMVModifierLine( start=(x1, y1), end=(x2, y2), interpolation_x=MMVInterpolation({ "function": "remaining_approach", "aggressive": fast, }), interpolation_y=MMVInterpolation({ "function": "remaining_approach", "aggressive": fast, }), mode=ModifierMode.OVERRIDE_VALUE_RESET_OFFSET, ), particle_shake ], }, "animation": { "steps": this_steps, }, "modules": { "fade": { "object": MMVModifierFade( interpolation=MMVInterpolation({ "function": "linear", "total_steps": 30, "start": fade_intensity, "end": 0, })) } } } particle.image.resize_by_ratio(random.uniform( 0.1 * resolution_ratio_multiplier, 0.3 * resolution_ratio_multiplier), override=True) return particle