From 586db76f7e87f7ea15558c546dc50ac67251f1ed Mon Sep 17 00:00:00 2001 From: Agnelo Vaz Date: Fri, 1 Apr 2016 16:04:16 +0100 Subject: [PATCH] Gradient Renderer example property names updated GradientRenderer property names changed in dali-toolkit so reflected here stopOffset nolonger set in code as uses defaults gradient json script added Change-Id: I1412be7fe7d7abeaee847a49dfcdacba806d3efd --- examples/gradients/gradients-example.cpp | 28 ++++++++++++----------- resources/scripts/gradient.json | 38 +++++++++++++++++++++++++++++++ resources/style/demo-theme.json.in | 9 ++++---- resources/style/mobile/demo-theme.json.in | 9 ++++---- 4 files changed, 61 insertions(+), 23 deletions(-) create mode 100644 resources/scripts/gradient.json diff --git a/examples/gradients/gradients-example.cpp b/examples/gradients/gradients-example.cpp index 48e3d97..88d64e1 100644 --- a/examples/gradients/gradients-example.cpp +++ b/examples/gradients/gradients-example.cpp @@ -80,20 +80,22 @@ public: // ---- Gradient for background mGradientMap.Insert("rendererType", "gradient"); + Property::Array stopOffsets; stopOffsets.PushBack( 0.0f ); stopOffsets.PushBack( 0.3f ); stopOffsets.PushBack( 0.6f ); stopOffsets.PushBack( 0.8f ); - stopOffsets.PushBack( 1.f ); - mGradientMap.Insert("gradientStopOffset", stopOffsets); + stopOffsets.PushBack( 1.0f ); + mGradientMap.Insert("stopOffset", stopOffsets ); + Property::Array stopColors; stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 255.f )/255.f ); stopColors.PushBack( Vector4( 196.f, 198.f, 71.f, 122.f )/255.f ); stopColors.PushBack( Vector4( 214.f, 37.f, 139.f, 191.f )/255.f ); stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 150.f )/255.f ); stopColors.PushBack( Color::YELLOW ); - mGradientMap.Insert("gradientStopColor", stopColors); + mGradientMap.Insert("stopColor", stopColors); OnChangeIconClicked( changeButton ); } @@ -106,30 +108,30 @@ public: { case 0: // linear gradient with units as objectBoundingBox { - gradientMap.Insert("gradientStartPosition", Vector2( 0.5f, 0.5f )); - gradientMap.Insert("gradientEndPosition", Vector2( -0.5f, -0.5f )); + gradientMap.Insert("startPosition", Vector2( 0.5f, 0.5f )); + gradientMap.Insert("endPosition", Vector2( -0.5f, -0.5f )); break; } case 1: // linear gradient with units as userSpaceOnUse { Vector2 halfStageSize = Stage::GetCurrent().GetSize()*0.5f; - gradientMap.Insert("gradientStartPosition", halfStageSize); - gradientMap.Insert("gradientEndPosition", -halfStageSize ); - gradientMap.Insert("gradientUnits", "userSpace"); + gradientMap.Insert("startPosition", halfStageSize); + gradientMap.Insert("endPosition", -halfStageSize ); + gradientMap.Insert("units", "userSpace"); break; } case 2: // radial gradient with units as objectBoundingBox { - gradientMap.Insert("gradientCenter", Vector2(0.5f, 0.5f)); - gradientMap.Insert("gradientRadius", 1.414f); + gradientMap.Insert("center", Vector2(0.5f, 0.5f)); + gradientMap.Insert("radius", 1.414f); break; } default: // radial gradient with units as userSpaceOnUse { Vector2 stageSize = Stage::GetCurrent().GetSize(); - gradientMap.Insert("gradientCenter", stageSize*0.5f); - gradientMap.Insert("gradientRadius", stageSize.Length()); - gradientMap.Insert("gradientUnits", "userSpace"); + gradientMap.Insert("center", stageSize*0.5f); + gradientMap.Insert("radius", stageSize.Length()); + gradientMap.Insert("units", "userSpace"); break; } } diff --git a/resources/scripts/gradient.json b/resources/scripts/gradient.json new file mode 100644 index 0000000..fe2cc21 --- /dev/null +++ b/resources/scripts/gradient.json @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +{ + // a tree of actors + "stage": [{ + "type": "Control", + "size": [400,600,1], + "parentOrigin": "CENTER", + "anchorPoint": "CENTER", + "background": { + "rendererType" : "gradient", + "startPosition" : [-0.5, -0.5], + "endPosition": [0.5,0.5], + "stopColor" : [ + [1,0,0,1], + [1,0.25,0,1], + [1,0.5,0,1], + [1,0.75,0,1], + [1,1,0,1] + ], + "stopOffset" : [ 0, 0.25, 0.5, 0.75, 1.0 ] + } + }] +} diff --git a/resources/style/demo-theme.json.in b/resources/style/demo-theme.json.in index 8b8eef1..3288d77 100644 --- a/resources/style/demo-theme.json.in +++ b/resources/style/demo-theme.json.in @@ -70,11 +70,10 @@ "background": { "rendererType": "gradient", - "gradientCenter": [240, 400], - "gradientRadius": 932, - "gradientUnits": "userSpace", - "gradientStopColor": [[0.247,0.38,0.52,1.0],[0.055,0.18,0.286,1.0]], - "gradientStopOffset":[0.0,1.0] + "center": [240, 400], + "radius": 932, + "units": "userSpace", + "stopColor": [[0.247,0.38,0.52,1.0],[0.055,0.18,0.286,1.0]] } } } diff --git a/resources/style/mobile/demo-theme.json.in b/resources/style/mobile/demo-theme.json.in index 79f9803..dd4cc59 100644 --- a/resources/style/mobile/demo-theme.json.in +++ b/resources/style/mobile/demo-theme.json.in @@ -83,11 +83,10 @@ "background": { "rendererType": "gradient", - "gradientCenter": [360, 640], - "gradientRadius": 1468, - "gradientUnits": "userSpace", - "gradientStopColor": [[0.247,0.38,0.52,1.0],[0.055,0.18,0.286,1.0]], - "gradientStopOffset":[0.0,1.0] + "center": [360, 640], + "radius": 1468, + "units": "userSpace", + "stopColor": [[0.247,0.38,0.52,1.0],[0.055,0.18,0.286,1.0]] } } } -- 2.7.4