1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PARTICLE_EFFECTOR_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PARTICLE_EFFECTOR_H 18 19 #include "rs_render_particle.h" 20 namespace OHOS { 21 namespace Rosen { 22 23 class RSRenderParticleEffector { 24 public: 25 RSRenderParticleEffector(const std::shared_ptr<ParticleRenderParams> particleParams); 26 27 void UpdateProperty(const std::shared_ptr<RSRenderParticle>& particle, float deltaTime, int64_t activeTime); 28 void UpdateAccelerate(const std::shared_ptr<RSRenderParticle>& particle, float deltaTime, int64_t activeTime); 29 void UpdateAccelerationAngle( 30 const std::shared_ptr<RSRenderParticle>& particle, float deltaTime, int64_t activeTime); 31 void UpdateAccelerationValue( 32 const std::shared_ptr<RSRenderParticle>& particle, float deltaTime, int64_t activeTime); 33 void UpdateColor(const std::shared_ptr<RSRenderParticle>& particle, float deltaTime, int64_t activeTime); 34 Color UpdateColorRandom(const std::shared_ptr<RSRenderParticle>& particle, float deltaTime, Color color); 35 int16_t CalculateRedInt( 36 const std::shared_ptr<RSRenderParticle>& particle, int16_t redInt, float redF, float redSpeed, float deltaTime); 37 int16_t CalculateGreenInt(const std::shared_ptr<RSRenderParticle>& particle, int16_t greenInt, float greenF, 38 float greenSpeed, float deltaTime); 39 int16_t CalculateBlueInt(const std::shared_ptr<RSRenderParticle>& particle, int16_t blueInt, float blueF, 40 float blueSpeed, float deltaTime); 41 int16_t CalculateAlphaInt(const std::shared_ptr<RSRenderParticle>& particle, int16_t alphaInt, float alphaF, 42 float alphaSpeed, float deltaTime); 43 Color UpdateColorCurve(int64_t activeTime, Color color); 44 void UpdateOpacity(const std::shared_ptr<RSRenderParticle>& particle, float deltaTime, int64_t activeTime); 45 void UpdateScale(const std::shared_ptr<RSRenderParticle>& particle, float deltaTime, int64_t activeTime); 46 void UpdateSpin(const std::shared_ptr<RSRenderParticle>& particle, float deltaTime, int64_t activeTime); 47 // Apply effector to particle 48 void ApplyEffectorToParticle(const std::shared_ptr<RSRenderParticle>& particle, int64_t deltaTime); 49 50 template<typename T> 51 T GenerateValue(T startValue, T endValue, int startTime, int endTime, int currentTime, 52 std::shared_ptr<RSInterpolator> interpolator); 53 float GenerateValue(float startValue, float endValue, int startTime, int endTime, int currentTime); 54 55 private: 56 std::shared_ptr<ParticleRenderParams> particleParams_; 57 }; 58 59 } // namespace Rosen 60 } // namespace OHOS 61 62 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PARTICLE_EFFECTOR_H 63