Skip to content

Commit

Permalink
[NUI] Added trim paths props
Browse files Browse the repository at this point in the history
  • Loading branch information
JoogabYun committed Aug 22, 2024
1 parent 4b76c14 commit 1fc4659
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 4 deletions.
16 changes: 15 additions & 1 deletion src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,19 @@ public enum VectorProperty
/// Transform opacity of the Layer and Group object, Type of float
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
TransformOpacity
TransformOpacity,

/// <summary>
/// Trim Start property of Shape object, Type of float, Value range of [0..100]
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
TrimStart,

/// <summary>
/// Trim End property of Shape object, Type of float, Type of <see cref="Vector2"/>, Value range of [0..100]
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
TrimEnd
};

// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
Expand Down Expand Up @@ -1437,6 +1449,7 @@ static internal void RootCallback(int id, int returnType, uint frameNumber, ref
case (int)(VectorProperty.TransformAnchor):
case (int)(VectorProperty.TransformPosition):
case (int)(VectorProperty.TransformScale):
case (int)(VectorProperty.TrimEnd):
Vector2 tmpVector2 = new Vector2(-1, -1);
if ((ret != null) && ret.Get(tmpVector2))
{
Expand All @@ -1450,6 +1463,7 @@ static internal void RootCallback(int id, int returnType, uint frameNumber, ref
case (int)(VectorProperty.StrokeWidth):
case (int)(VectorProperty.TransformRotation):
case (int)(VectorProperty.TransformOpacity):
case (int)(VectorProperty.TrimStart):
float tmpFloat = -1;
if ((ret != null) && ret.Get(out tmpFloat))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public void Activate()
bool OnTick(object sender, Timer.TickEventArgs e)
{
bool ret = false;
//ret = Test1();
ret = Test1();
//ret = Test2();
ret = Test3();
// ret = Test3();
return ret;
}

Expand Down Expand Up @@ -132,7 +132,7 @@ void ForceFullGC()
void MakeAll()
{
tlog.Debug(tag, $"MakeAll() start");
int width = (int)(root.Size.Width / NUM_OF_VIEW);
int width = (int)(root.Size.Width / (NUM_OF_VIEW + 2));
for (int i = 0; i < NUM_OF_VIEW; i++)
{
var lav = new LottieAnimationView();
Expand Down Expand Up @@ -179,6 +179,42 @@ void MakeAll()
}
lav.Play();
}

{
var lav = new LottieAnimationView();
lav.Size2D = new Size2D(width, width);
lav.URL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "30.json";
lav.LoopCount = -1;
lav.BackgroundColor = Color.Black;
root.Add(lav);
lav.Play();
}
{
var lav = new LottieAnimationView();
lav.Size2D = new Size2D(width, width);
lav.URL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "100.json";
lav.LoopCount = -1;
lav.BackgroundColor = Color.Black;
root.Add(lav);

LottieAnimationViewDynamicProperty pro = new LottieAnimationViewDynamicProperty
{
// KeyPath = "**",
KeyPath = "Shape Layer 1.Trim Paths 1",
Property = LottieAnimationView.VectorProperty.TrimEnd,
Callback = new Tizen.NUI.BaseComponents.LottieAnimationView.DynamicPropertyCallbackType(OnTrimEnd),
};
lav.DoActionExtension(pro);
LottieAnimationViewDynamicProperty pro1 = new LottieAnimationViewDynamicProperty
{
// KeyPath = "**",
KeyPath = "Shape Layer 1.Trim Paths 1",
Property = LottieAnimationView.VectorProperty.TrimStart,
Callback = new Tizen.NUI.BaseComponents.LottieAnimationView.DynamicPropertyCallbackType(OnTrimStart),
};
lav.DoActionExtension(pro1);
lav.Play();
}
tlog.Debug(tag, $"MakeAll() end");
}

Expand Down Expand Up @@ -260,6 +296,20 @@ private PropertyValue OnTransformRotation(int returnType, uint frameNumber)
return new PropertyValue(frameNumber * 20.0f);
}

private PropertyValue OnTrimEnd(int returnType, uint frameNumber)
{
tlog.Debug(tag, $"OnTrimEnd() returnType={returnType} frameNumber={frameNumber}");

return new PropertyValue(new Vector2(0.0f, 30.0f));
}

private PropertyValue OnTrimStart(int returnType, uint frameNumber)
{
tlog.Debug(tag, $"OnTrimStart() returnType={returnType} frameNumber={frameNumber}");

return new PropertyValue(0.0f);
}

public void Deactivate()
{
root.Unparent();
Expand Down
1 change: 1 addition & 0 deletions test/Tizen.NUI.Samples/Tizen.NUI.Samples/res/100.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"5.8.1","fr":60,"ip":0,"op":61,"w":1920,"h":1080,"nm":"100","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[960,540,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[640,640],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":64,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,2],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.4],"y":[1]},"o":{"x":[0.33],"y":[0]},"t":0,"s":[0]},{"t":30,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":6000,"st":0,"bm":0}],"markers":[]}
1 change: 1 addition & 0 deletions test/Tizen.NUI.Samples/Tizen.NUI.Samples/res/30.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"5.8.1","fr":60,"ip":0,"op":61,"w":1920,"h":1080,"nm":"30","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[960,540,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[640,640],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":64,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,2],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.4],"y":[1]},"o":{"x":[0.33],"y":[0]},"t":0,"s":[0]},{"t":30,"s":[30]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":6000,"st":0,"bm":0}],"markers":[]}

0 comments on commit 1fc4659

Please sign in to comment.