From: Heeyong Song Date: Mon, 18 Jul 2022 09:32:15 +0000 (+0900) Subject: (Vector) Use dynamic property X-Git-Tag: dali_2.1.33~4 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-demo.git;a=commitdiff_plain;h=6c6724c3eef63a78918b2dd1c46e090934959438 (Vector) Use dynamic property Change-Id: I9bb4e4d44b2e9ad87214d054df82ddf047bd1c77 --- diff --git a/examples/animated-vector-images/animated-vector-images-example.cpp b/examples/animated-vector-images/animated-vector-images-example.cpp index d138483..9612c47 100644 --- a/examples/animated-vector-images/animated-vector-images-example.cpp +++ b/examples/animated-vector-images/animated-vector-images-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "shared/view.h" @@ -35,8 +36,8 @@ const char* TOOLBAR_IMAGE(DEMO_IMAGE_DIR "top-bar.png"); const char* APPLICATION_TITLE("Animated Vector Images"); const char* IMAGE_PATH[] = { + DEMO_IMAGE_DIR "done.json", DEMO_IMAGE_DIR "insta_camera.json", - DEMO_IMAGE_DIR "you're_in!.json", DEMO_IMAGE_DIR "jolly_walker.json"}; const unsigned int NUMBER_OF_IMAGES = 3; @@ -140,10 +141,80 @@ public: mTable.AddChild(mImageViews[x], TableView::CellPosition(CellPlacement::IMAGE, x)); } + DevelAnimatedVectorImageVisual::DynamicPropertyInfo info; + info.id = 1; + info.keyPath = "Shape Layer 1.Ellipse 1.Fill 1"; + info.property = static_cast(VectorAnimationRenderer::VectorProperty::FILL_COLOR); + info.callback = MakeCallback(this, &AnimatedVectorImageViewController::FillColorCallback); + + DevelControl::DoActionExtension(mImageViews[0], ImageView::Property::IMAGE, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info)); + + info.id = 2; + info.keyPath = "**"; + info.property = static_cast(VectorAnimationRenderer::VectorProperty::STROKE_COLOR); + info.callback = MakeCallback(this, &AnimatedVectorImageViewController::StrokeColorCallback); + + DevelControl::DoActionExtension(mImageViews[0], ImageView::Property::IMAGE, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info)); + + info.id = 3; + info.keyPath = "**"; + info.property = static_cast(VectorAnimationRenderer::VectorProperty::STROKE_WIDTH); + info.callback = MakeCallback(this, &AnimatedVectorImageViewController::StrokeWidthCallback); + + DevelControl::DoActionExtension(mImageViews[0], ImageView::Property::IMAGE, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info)); + + info.id = 4; + info.keyPath = "Shape Layer 2.Shape 1"; + info.property = static_cast(VectorAnimationRenderer::VectorProperty::TRANSFORM_ROTATION); + info.callback = MakeCallback(this, &AnimatedVectorImageViewController::TransformRotationCallback); + + DevelControl::DoActionExtension(mImageViews[0], ImageView::Property::IMAGE, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info)); + application.GetWindow().KeyEventSignal().Connect(this, &AnimatedVectorImageViewController::OnKeyEvent); } private: + Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber) + { + if(frameNumber < 60) + { + return Vector3(0, 0, 1); + } + else + { + return Vector3(1, 0, 0); + } + } + + Property::Value StrokeColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber) + { + if(frameNumber < 60) + { + return Vector3(1, 0, 1); + } + else + { + return Vector3(1, 1, 0); + } + } + + Property::Value StrokeWidthCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber) + { + if(frameNumber < 60) + { + return 2.0f; + } + else + { + return 5.0f; + } + } + + Property::Value TransformRotationCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber) + { + return frameNumber * 20.0f; + } + bool OnPlayButtonClicked(Button button) { unsigned int controlIndex = GetControlIndex(button); diff --git a/resources/images/done.json b/resources/images/done.json new file mode 100644 index 0000000..a4b1196 --- /dev/null +++ b/resources/images/done.json @@ -0,0 +1 @@ +{"v":"4.11.1","fr":29.9700012207031,"ip":0,"op":76.0000030955435,"w":70,"h":70,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[35,35,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":33,"s":[0,0,100],"e":[120,120,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":46,"s":[120,120,100],"e":[100,100,100]},{"t":52.0000021180034}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[-7,1.438],[-2.656,5.781],[7.422,-4.297]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","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":3,"ix":5},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"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":"Shape 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"n":["0p667_1_0p333_0"],"t":33,"s":[0],"e":[100]},{"t":52.0000021180034}],"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":450.000018328876,"st":0,"bm":0},{"ddd":0,"ind":2,"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":[35,35,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":18,"s":[0,0,100],"e":[120,120,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":33,"s":[120,120,100],"e":[80,80,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":41,"s":[80,80,100],"e":[110,110,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":49,"s":[110,110,100],"e":[100,100,100]},{"t":52.0000021180034}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[13.015,0],[0,-13.015],[-13.015,0],[0,13.015]],"o":[[-13.015,0],[0,13.015],[13.015,0],[0,-13.015]],"v":[[0,-23.566],[-23.566,0],[0,23.566],[23.566,0]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.898039215686,0.898039215686,0.898039215686,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":0,"ix":5},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.760784313725,0.2,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[105.535,105.535],"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":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":450.000018328876,"st":0,"bm":0}]} \ No newline at end of file