Adds an API that adds a large path information.
The PathCommands structure has a PathCommandType array, a Point array
and the number of each array.
ex)
//Prepare Path Commands
Dali::CanvasRenderer::Shape::PathCommandType commands[11];
commands[0] = Dali::CanvasRenderer::Shape::PathCommandType::MOVE_TO;
commands[1] = Dali::CanvasRenderer::Shape::PathCommandType::LINE_TO;
commands[2] = Dali::CanvasRenderer::Shape::PathCommandType::LINE_TO;
commands[3] = Dali::CanvasRenderer::Shape::PathCommandType::LINE_TO;
commands[4] = Dali::CanvasRenderer::Shape::PathCommandType::LINE_TO;
commands[5] = Dali::CanvasRenderer::Shape::PathCommandType::LINE_TO;
commands[6] = Dali::CanvasRenderer::Shape::PathCommandType::LINE_TO;
commands[7] = Dali::CanvasRenderer::Shape::PathCommandType::LINE_TO;
commands[8] = Dali::CanvasRenderer::Shape::PathCommandType::LINE_TO;
commands[9] = Dali::CanvasRenderer::Shape::PathCommandType::LINE_TO;
commands[10] = Dali::CanvasRenderer::Shape::PathCommandType::CLOSE;
//Prepare Path Points
float points[20] = {-1.0f, -165.0f,
53.0f, -56.0f,
174.0f, -39.0f,
87.0f, 45.0f,
107.0f, 166.0f,
-1.0f, 110.0f,
-103.0f, 166.0f,
-88.0f, 46.0f,
-174.0f, -38.0f,
-54.0f, -56.0f};
Dali::CanvasRenderer::Shape::PathCommands starPath = { commands, 11, points, 20 };
Dali::CanvasRenderer::Shape star = Dali::CanvasRenderer::Shape::New();
star.AddPath(starPath);
mCanvasView.AddDrawable(star);
Change-Id: I36cea22b1e80bfe2182cdb7fb2a8e262523c2a4f
return GetImplementation(*this).AddCubicTo(controlPoint1, controlPoint2, endPoint);
}
+bool CanvasRenderer::Shape::AddPath(PathCommands& pathCommand)
+{
+ return GetImplementation(*this).AddPath(pathCommand);
+}
+
bool CanvasRenderer::Shape::Close()
{
return GetImplementation(*this).Close();
EVEN_ODD ///< Draw a horizontal line from the point to a location outside the shape, and count the number of intersections. If the number of intersections is an odd number, the point is inside the shape.
};
+ /**
+ * @brief Enumeration specifying the values of the path commands.
+ * Not to be confused with the path commands from the svg path element (like M, L, Q, H and many others).
+ */
+ enum class PathCommandType
+ {
+ CLOSE = 0, ///< Ends the current sub-path and connects it with its initial point. This command doesn't expect any points.
+ MOVE_TO, ///< Sets a new initial point of the sub-path and a new current point. This command expects 1 point: the starting position.
+ LINE_TO, ///< Draws a line from the current point to the given point and sets a new value of the current point. This command expects 1 point: the end-position of the line.
+ CUBIC_TO ///< Draws a cubic Bezier curve from the current point to the given point using two given control points and sets a new value of the current point. This command expects 3 points: the 1st control-point, the 2nd control-point, the end-point of the curve.
+ };
+
+ /**
+ * @brief Structure that contains information about a list of path commands.
+ * For each command from the mCommands array, an appropriate number of points in mPoints array should be specified.
+ */
+ struct PathCommands
+ {
+ PathCommandType* mCommands; ///< Set of each PathComand.
+ uint32_t mCommandCount; ///< The number of command array.
+ float* mPoints; ///< Set of each Point
+ uint32_t mPointCount; ///< The number of point array.
+ };
+
public:
/**
* @brief Append the given rectangle with rounded corner to the path.
bool AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint);
/**
+ * @brief Appends a given sub-path to the path.
+ * The current point value is set to the last point from the sub-path.
+ * @param[in] pathCommand The command object that contain sub-path information. (This command information is copied internally.)
+ * @return Returns True when it's successful. False otherwise.
+ * @note The interface is designed for optimal path setting if the caller has a completed path commands already.
+ *
+ */
+ bool AddPath(PathCommands& pathCommand);
+
+ /**
* @brief Closes the current subpath by drawing a line to the beginning of the
* subpath, automatically starting a new path. The current point of the
* new path is (0, 0).
return false;
}
+bool Shape::AddPath(Dali::CanvasRenderer::Shape::PathCommands& pathCommand)
+{
+ return false;
+}
+
bool Shape::Close()
{
return false;
virtual bool AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint);
/**
+ * @copydoc Dali::CanvasRenderer::Shape::AddPath()
+ */
+ virtual bool AddPath(Dali::CanvasRenderer::Shape::PathCommands& pathCommand);
+
+ /**
* @copydoc Dali::CanvasRenderer::Shape::Close()
*/
virtual bool Close();
return false;
}
+bool ShapeGeneric::AddPath(Dali::CanvasRenderer::Shape::PathCommands& pathCommand)
+{
+ return false;
+}
+
bool ShapeGeneric::Close()
{
return false;
bool AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint) override;
/**
+ * @copydoc Dali::CanvasRenderer::Shape::AddPath()
+ */
+ bool AddPath(Dali::CanvasRenderer::Shape::PathCommands& pathCommand) override;
+
+ /**
* @copydoc Dali::CanvasRenderer::Shape::Close()
*/
bool Close() override;
#endif
}
+bool ShapeTizen::AddPath(Dali::CanvasRenderer::Shape::PathCommands& pathCommand)
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->appendPath(reinterpret_cast<const tvg::PathCommand*>(pathCommand.mCommands), pathCommand.mCommandCount, static_cast<const tvg::Point*>((void*)pathCommand.mPoints), pathCommand.mPointCount) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("AddPath() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
bool ShapeTizen::Close()
{
#ifdef THORVG_SUPPORT
bool AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint) override;
/**
+ * @copydoc Dali::CanvasRenderer::Shape::AddPath()
+ */
+ bool AddPath(Dali::CanvasRenderer::Shape::PathCommands& pathCommand) override;
+
+ /**
* @copydoc Dali::CanvasRenderer::Shape::Close()
*/
bool Close() override;
#endif
}
+bool ShapeUbuntu::AddPath(Dali::CanvasRenderer::Shape::PathCommands& pathCommand)
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->appendPath(reinterpret_cast<const tvg::PathCommand*>(pathCommand.mCommands), pathCommand.mCommandCount, static_cast<const tvg::Point*>((void*)pathCommand.mPoints), pathCommand.mPointCount) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("AddPath() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
bool ShapeUbuntu::Close()
{
#ifdef THORVG_SUPPORT
bool AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint) override;
/**
+ * @copydoc Dali::CanvasRenderer::Shape::AddPath()
+ */
+ bool AddPath(Dali::CanvasRenderer::Shape::PathCommands& pathCommand) override;
+
+ /**
* @copydoc Dali::CanvasRenderer::Shape::Close()
*/
bool Close() override;