MCPcopy Create free account
hub / github.com/SpartanJ/eepp / tweenProperty

Method tweenProperty

src/eepp/ui/css/stylesheetpropertyanimation.cpp:27–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27void StyleSheetPropertyAnimation::tweenProperty( UIWidget* widget, const Float& normalizedProgress,
28 const PropertyDefinition* property,
29 const std::string& startValue,
30 const std::string& endValue,
31 const Ease::Interpolation& timingFunction,
32 const std::vector<double> timingFunctionParameters,
33 const Uint32& propertyIndex, const bool& isDone ) {
34 switch ( property->getType() ) {
35 case PropertyType::NumberFloat:
36 case PropertyType::NumberInt: {
37 Float start = widget->convertLength( startValue, 0 );
38 Float end = widget->convertLength( endValue, 0 );
39 Float value = easingFn( timingFunction, timingFunctionParameters, normalizedProgress,
40 start, end - start, 1.f );
41 if ( property->getType() == PropertyType::NumberFloat ) {
42 widget->applyProperty(
43 StyleSheetProperty( property, String::fromFloat( value ), propertyIndex ) );
44 } else {
45 widget->applyProperty( StyleSheetProperty(
46 property, String::format( "%d", static_cast<int>( value ) ), propertyIndex ) );
47 }
48 break;
49 }
50 case PropertyType::Color: {
51 Color startColor( startValue );
52 Color endColor( endValue );
53 if ( startColor.getValue() == 0 ) {
54 startColor = endColor;
55 startColor.a = 0;
56 }
57 if ( endColor.getValue() == 0 ) {
58 endColor = startColor;
59 endColor.a = 0;
60 }
61 Float progress =
62 easingFn( timingFunction, timingFunctionParameters, normalizedProgress, 0, 1, 1.f );
63 Color resColor( startColor );
64 resColor.r = static_cast<Uint8>( eemin(
65 static_cast<Int32>( startColor.r + ( endColor.r - startColor.r ) * progress ),
66 255 ) );
67 resColor.g = static_cast<Uint8>( eemin(
68 static_cast<Int32>( startColor.g + ( endColor.g - startColor.g ) * progress ),
69 255 ) );
70 resColor.b = static_cast<Uint8>( eemin(
71 static_cast<Int32>( startColor.b + ( endColor.b - startColor.b ) * progress ),
72 255 ) );
73 resColor.a = static_cast<Uint8>( eemin(
74 static_cast<Int32>( startColor.a + ( endColor.a - startColor.a ) * progress ),
75 255 ) );
76 widget->applyProperty(
77 StyleSheetProperty( property, resColor.toHexString(), propertyIndex ) );
78 break;
79 }
80 case PropertyType::NumberLength: {
81 Float containerLength = widget->getPropertyRelativeTargetContainerLength(
82 property->getRelativeTarget(), 0.f, propertyIndex );
83 Float start = widget->convertLength( startValue, containerLength );
84 Float end = widget->convertLength( endValue, containerLength );

Callers

nothing calls this directly

Calls 14

easingFnFunction · 0.85
formatFunction · 0.85
eeminFunction · 0.85
convertLengthMethod · 0.80
asVector2fMethod · 0.80
calcDrawableSizeMethod · 0.80
getBackgroundMethod · 0.80
getForegroundMethod · 0.80
getTypeMethod · 0.45
applyPropertyMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected