[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
public static extern bool AddCubicTo(global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2, float jarg3, float jarg4, float jarg5, float jarg6, float jarg7);
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Shape_AddPath")]
+ [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
+ public static extern void AddPath(global::System.Runtime.InteropServices.HandleRef pShape, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)] BaseComponents.VectorGraphics.PathCommands.PathCommandType[] commands, uint commandCount, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)] float[] points, uint pointCount);
+
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Shape_Close")]
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
public static extern bool Close(global::System.Runtime.InteropServices.HandleRef jarg1);
--- /dev/null
+/*
+* Copyright(c) 2021 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.
+*
+*/
+
+using System;
+using System.ComponentModel;
+
+namespace Tizen.NUI.BaseComponents.VectorGraphics
+{
+ /// <summary>
+ /// Data class that contains information about a list of path commands.
+ /// For each command from the commands array, an appropriate number of points in points array should be specified.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class PathCommands
+ {
+ private PathCommandType[] commands; //The array of commands.
+ private uint commandCount; //The number of commands.
+ private float[] points; //The array of points.
+ private uint pointCount; //The number of points.
+
+ /// <summary>
+ /// Initialize PathCommands.
+ /// </summary>
+ /// <param name="commands">The array of commands.</param>
+ /// <param name="commandCount">The number of commands.</param>
+ /// <param name="points">The array of points.</param>
+ /// <param name="pointCount">The number of points.</param>
+ /// <exception cref="ArgumentNullException"> Thrown when commands or points are null. </exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public PathCommands(PathCommandType[] commands, uint commandCount, float[] points, uint pointCount)
+ {
+ if (commands == null)
+ {
+ throw new ArgumentNullException(nameof(commands));
+ }
+ if (points == null)
+ {
+ throw new ArgumentNullException(nameof(points));
+ }
+ this.commands = commands;
+ this.commandCount = commandCount;
+ this.points = points;
+ this.pointCount = pointCount;
+ }
+
+ /// <summary>
+ /// 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).
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum PathCommandType
+ {
+ /// <summary>
+ /// Ends the current sub-path and connects it with its initial point. This command doesn't expect any points.
+ /// </summary>
+ Close = 0,
+ /// <summary>
+ /// Sets a new initial point of the sub-path and a new current point. This command expects 1 point: the starting position.
+ /// </summary>
+ MoveTo,
+ /// <summary>
+ /// 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.
+ /// </summary>
+ LineTo,
+ /// <summary>
+ /// 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.
+ /// </summary>
+ CubicTo
+ }
+
+ /// <summary>
+ /// The commands array.
+ /// </summary>
+ /// <returns>The array of commands.</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public PathCommandType[] GetCommands()
+ {
+ return commands;
+ }
+
+ /// <summary>
+ /// The number of commands.
+ /// </summary>
+ /// <returns>The number of commands.</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public uint GetCommandCount()
+ {
+ return commandCount;
+ }
+
+ /// <summary>
+ /// The points array
+ /// </summary>
+ /// <returns>The array of points.</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public float[] GetPoints()
+ {
+ return points;
+ }
+
+ /// <summary>
+ /// The number of points.
+ /// </summary>
+ /// <returns>The number of points.</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public uint GetPointCount()
+ {
+ return pointCount;
+ }
+ }
+}
+
Interop.Shape.SetFillGradient(BaseHandle.getCPtr(this), BaseHandle.getCPtr(value));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
fillGradient = value;
- }
+ }
}
}
Interop.Shape.SetStrokeGradient(BaseHandle.getCPtr(this), BaseHandle.getCPtr(value));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
strokeGradient = value;
- }
+ }
}
}
return ret;
}
+
+ /// <summary>
+ /// Appends a given sub-path to the path.
+ /// The current point value is set to the last point from the sub-path.
+ /// @note The interface is designed for optimal path setting if the caller has a completed path commands already.
+ /// </summary>
+ /// <param name="pathCommands">The command object that contain sub-path information. (This command information is copied internally.)</param>
+ /// <exception cref="ArgumentNullException"> Thrown when pathCommands is null. </exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void AddPath(PathCommands pathCommands)
+ {
+ if (pathCommands == null)
+ {
+ throw new ArgumentNullException(nameof(pathCommands));
+ }
+
+ Interop.Shape.AddPath(BaseHandle.getCPtr(this), pathCommands.GetCommands(), pathCommands.GetCommandCount(), pathCommands.GetPoints(), pathCommands.GetPointCount());
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
/// <summary>
/// Closes the current subpath by drawing a line to the beginning of the
/// subpath, automatically starting a new path. The current point of the
FillRule = Shape.FillRuleType.EvenOdd,
StrokeJoin = Shape.StrokeJoinType.Round,
};
+
shape.Scale(0.5f);
shape.Translate(350.0f, 300.0f);
- shape.AddMoveTo(0.0f, -160.0f);
- shape.AddLineTo(125.0f, 160.0f);
- shape.AddLineTo(-180.0f, -45.0f);
- shape.AddLineTo(180.0f, -45.0f);
- shape.AddLineTo(-125.0f, 160.0f);
- shape.Close();
+
+ shape.AddPath(new PathCommands(new PathCommands.PathCommandType[] { PathCommands.PathCommandType.MoveTo,
+ PathCommands.PathCommandType.LineTo,
+ PathCommands.PathCommandType.LineTo,
+ PathCommands.PathCommandType.LineTo,
+ PathCommands.PathCommandType.LineTo,
+ PathCommands.PathCommandType.Close },
+ 6,
+ new float[] {0.0f, -160.0f,
+ 125.0f, 160.0f,
+ -180.0f, -45.0f,
+ 180.0f, -45.0f,
+ -125.0f, 160.0f },
+ 10));
canvasView.AddDrawable(shape);
group2.AddDrawable(circleShape);
canvasView.AddDrawable(group2);
- Picture picture = new Picture();
+ Picture picture = new Picture();
picture.Load(CommonResource.GetDaliResourcePath() + "DaliDemo/Kid1.svg");
picture.SetSize(new Size2D(150, 150));
picture.Translate(300.0f, 550.0f);