/* * Copyright (c) 2020 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. * */ #include #include #include "shared/view.h" #include using namespace Dali; using namespace Dali::Toolkit; namespace { 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"<