X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fanimated-shapes%2Fanimated-shapes-example.cpp;h=2960f473d7c67d58f6ecdf8d8b441ea28f92211b;hb=2e182925204bf3ef9f2a36cbfbf998e79fbafaf5;hp=b7a5a72e3da17e4266243ff17f2917f38a0863af;hpb=adcf034d27ea710963e681f19026dafc422c3a44;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/animated-shapes/animated-shapes-example.cpp b/examples/animated-shapes/animated-shapes-example.cpp index b7a5a72..2960f47 100644 --- a/examples/animated-shapes/animated-shapes-example.cpp +++ b/examples/animated-shapes/animated-shapes-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -17,15 +17,71 @@ #include #include +#include "shared/view.h" + +#include using namespace Dali; +using namespace Dali::Toolkit; namespace { -const char* BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-gradient.jpg" ); +const char* APPLICATION_TITLE("Animated Shapes"); + +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER +( + attribute mediump vec3 aCoefficient; + uniform mediump mat4 uMvpMatrix; + uniform mediump vec3 uPosition[MAX_POINT_COUNT]; + varying lowp vec2 vCoefficient; + void main() + { + int vertexId = int(aCoefficient.z); + gl_Position = uMvpMatrix * vec4(uPosition[vertexId], 1.0); + + vCoefficient = aCoefficient.xy; + } +); + +// Fragment shader. +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER +( + uniform lowp vec4 uColor; + varying lowp vec2 vCoefficient; + void main() + { + lowp float C = (vCoefficient.x*vCoefficient.x-vCoefficient.y); + lowp float Cdx = dFdx(C); + lowp float Cdy = dFdy(C); + + lowp float distance = float(C / sqrt(Cdx*Cdx + Cdy*Cdy)); + lowp float alpha = 0.5 - distance; + gl_FragColor = vec4( uColor.rgb, uColor.a * alpha ); + } +); + +Shader CreateShader( unsigned int pointCount ) +{ + std::ostringstream vertexShader; + vertexShader << "#define MAX_POINT_COUNT "<< pointCount << "\n"<