1 #ifndef __DALI_TOOLKIT_QUADRATIC_BEZIER_H__
2 #define __DALI_TOOLKIT_QUADRATIC_BEZIER_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/shader-effects/shader-effect.h>
30 * @brief QuadraticBezier is a custom shader to render quadratic bezier curves and bounded regions.
32 * Implementation based on the paper "Resolution Independent Curve Rendering using Programmable Graphics Hardware"
33 * by Charles Loop and Jim Blinn.
35 * The coordinates of the control points is passed to the shader via uniforms.
36 * aNormal attribute is used to pass the coefficients of each control point (xy coordinates) as well as the vertex ID (z coordinate).
37 * A quadratic curve should have as normal for the first control point (0.0,0.0), (0.5,0.0) for the second and (1.0,1.0) for the third.
38 * Triangles that do not contain curves should have coordinates (0.0,1.0) for each control point in order to be filled properly.
41 class DALI_IMPORT_API QuadraticBezier : public ShaderEffect
46 * @brief Create an uninitialized QuadraticBezier; this can be initialized with QuadraticBezier::New().
48 * Calling member functions with an uninitialized Dali::Object is not allowed.
55 * This is non-virtual since derived Handle types must not contain data or virtual methods.
60 * @brief Create an initialized QuadraticBezier.
62 * @param[in] pointCount The maximum number of vertices
63 * @param[in] filled Specify whether the the bounded region should be filled or not
64 * @return A handle to a newly allocated Dali resource.
66 static QuadraticBezier New(unsigned int pointCount, bool filled );
69 * @brief Set position coordinates for a point in the curve
71 * @param[in] index The index of the vertex
72 * @param[in] position The new position
74 void SetPoint( unsigned int index, const Vector3& position );
77 * @brief Set the width of the pathThis is only for not filled curves
79 * @param[in] width Width of the line in pixels
81 void SetLineWidth( float width );
84 * @brief Sets the color of the curve
86 * @param[in] color The new color
88 void SetColor( const Vector4& color );
91 * @brief Get the name of a the point property given its index
93 * @param[in] index Index of the vertex
94 * @return A std::string containing the property name
96 std::string GetPointPropertyName( unsigned int index ) const;
99 * @brief Get the name of the line width property
101 * @return A std::string containing the property name
103 std::string GetLineWidthPropertyName( ) const;
106 * @brief Get the name of the color property
108 * @return A std::string containing the property name
110 std::string GetColorPropertyName( ) const;
112 private: // Not intended for application developers
114 DALI_INTERNAL QuadraticBezier(ShaderEffect handle);
118 } // namespace Toolkit
122 #endif // __DALI_TOOLKIT_IMAGE_REGION_EFFECT_H__