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::vector<std::shared_ptr<RSRenderParticle>> activeParticles); 26 27 Vector4<int16_t> CalculateColorInt(const std::shared_ptr<RSRenderParticle>& particle, Vector4<int16_t> colorInt, 28 Vector4<float> colorF, Vector4<float> colorSpeed, float deltaTime); 29 30 float UpdateCurveValue( 31 const std::vector<std::shared_ptr<ChangeInOverLife<float>>>& valChangeOverLife, int64_t activeTime); 32 33 Color UpdateColorCurveValue( 34 const std::vector<std::shared_ptr<ChangeInOverLife<Color>>>& valChangeOverLife, int64_t activeTime); 35 36 void UpdateColor(float deltaTime); 37 38 void UpdateOpacity(float deltaTime); 39 40 void UpdateScale(float deltaTime); 41 42 void UpdateSpin(float deltaTime); 43 44 void UpdateAccelerationAngle(float deltaTime); 45 46 void UpdateAccelerationValue(float deltaTime); 47 48 void UpdatePosition(float deltaTime); 49 50 void UpdateActiveTime(int64_t deltaTime); 51 52 // Apply effector to particle 53 void ApplyEffectorToParticle(int64_t deltaTime); 54 55 void Update(const std::vector<std::shared_ptr<RSRenderParticle>>& activeParticles, int64_t deltaTime); 56 57 private: 58 std::vector<std::shared_ptr<RSRenderParticle>> activeParticles_; 59 }; 60 61 } // namespace Rosen 62 } // namespace OHOS 63 64 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PARTICLE_EFFECTOR_H 65