1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.systemui.surfaceeffects.turbulencenoise 17 18 import android.graphics.BlendMode 19 import android.graphics.Color 20 21 /** Turbulence noise animation configuration. */ 22 data class TurbulenceNoiseAnimationConfig( 23 /** The number of grids that is used to generate noise. */ 24 val gridCount: Float = DEFAULT_NOISE_GRID_COUNT, 25 26 /** Multiplier for the noise luma matte. Increase this for brighter effects. */ 27 val luminosityMultiplier: Float = DEFAULT_LUMINOSITY_MULTIPLIER, 28 29 /** 30 * Noise move speed variables. 31 * 32 * Its sign determines the direction; magnitude determines the speed. <ul> 33 * 34 * ``` 35 * <li> [noiseMoveSpeedX] positive: right to left; negative: left to right. 36 * <li> [noiseMoveSpeedY] positive: bottom to top; negative: top to bottom. 37 * <li> [noiseMoveSpeedZ] its sign doesn't matter much, as it moves in Z direction. Use it 38 * to add turbulence in place. 39 * ``` 40 * 41 * </ul> 42 */ 43 val noiseMoveSpeedX: Float = 0f, 44 val noiseMoveSpeedY: Float = 0f, 45 val noiseMoveSpeedZ: Float = DEFAULT_NOISE_SPEED_Z, 46 47 /** Color of the effect. */ 48 var color: Int = DEFAULT_COLOR, 49 /** Background color of the effect. */ 50 val backgroundColor: Int = DEFAULT_BACKGROUND_COLOR, 51 val opacity: Int = DEFAULT_OPACITY, 52 val width: Float = 0f, 53 val height: Float = 0f, 54 val maxDuration: Float = DEFAULT_MAX_DURATION_IN_MILLIS, 55 val easeInDuration: Float = DEFAULT_EASING_DURATION_IN_MILLIS, 56 val easeOutDuration: Float = DEFAULT_EASING_DURATION_IN_MILLIS, 57 val pixelDensity: Float = 1f, 58 val blendMode: BlendMode = DEFAULT_BLEND_MODE, 59 val onAnimationEnd: Runnable? = null 60 ) { 61 companion object { 62 const val DEFAULT_MAX_DURATION_IN_MILLIS = 30_000f // Max 30 sec 63 const val DEFAULT_EASING_DURATION_IN_MILLIS = 750f 64 const val DEFAULT_LUMINOSITY_MULTIPLIER = 1f 65 const val DEFAULT_NOISE_GRID_COUNT = 1.2f 66 const val DEFAULT_NOISE_SPEED_Z = 0.3f 67 const val DEFAULT_OPACITY = 150 // full opacity is 255. 68 const val DEFAULT_COLOR = Color.WHITE 69 const val DEFAULT_BACKGROUND_COLOR = Color.BLACK 70 val DEFAULT_BLEND_MODE = BlendMode.SRC_OVER 71 } 72 } 73