CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
graphics_path.h
1
2#ifndef _aspose_drawing_drawing2d_graphics_path_h_
3#define _aspose_drawing_drawing2d_graphics_path_h_
4
5#include "system/object.h"
6#include "system/enum_helpers.h"
7#include "drawing/pen.h"
8#include "drawing/point.h"
9#include "drawing/point_f.h"
10#include "drawing/rectangle.h"
11#include "drawing/rectangle_f.h"
12#include "drawing/font_family.h"
13#include "drawing/string_format.h"
14#include "drawing/drawing2d/matrix.h"
15#include "drawing/drawing2d/fill_mode.h"
16#include "drawing/drawing2d/path_data.h"
17#include "drawing/drawing2d/path_point_type.h"
18
19#include <memory>
20
21#ifdef ASPOSECPPLIB_BEING_BUILT
22#include <core/SkPath.h>
23#endif
24
26ASPOSECPP_3RD_PARTY_CLASS(SkPath);
28ASPOSECPP_3RD_PARTY_CLASS(SkMatrix);
30ASPOSECPP_3RD_PARTY_STRUCT(SkRect);
32ASPOSECPP_3RD_PARTY_TYPEDEF(SkScalar, float);
33
34
35namespace System { namespace Drawing { class Graphics; } }
36namespace System { namespace Drawing { class Region; } }
37namespace System { namespace Drawing { namespace Details { namespace Skia { class SkiaData; } } } }
38
39namespace System { namespace Drawing { namespace Drawing2D {
40
41namespace Detail {
43 enum class FigureType {
45 Unknown = (0x0),
47 Line = (0x01 << 0),
49 Bezier = (0x01 << 1),
51 Arc = (0x01 << 2),
53 Ellipse = (0x01 << 3),
55 Pie = (0x01 << 4),
57 Rectangle = (0x01 << 5),
59 Polygon = (0x01 << 6),
61 Curve = (0x01 << 7),
63 String = (0x01 << 8)
64 };
65
68 DECLARE_ENUM_OPERATORS(System::Drawing::Drawing2D::Detail::FigureType);
70 DECLARE_USING_GLOBAL_OPERATORS
72}
73
74class PathGradientBrush;
79class ASPOSECPP_SHARED_CLASS GraphicsPath : public Object
80{
81public:
85 ASPOSECPP_SHARED_API GraphicsPath(FillMode fillMode = FillMode::Alternate);
91 ASPOSECPP_SHARED_API GraphicsPath(const ArrayPtr<Point>& pts, const ArrayPtr<uint8_t>& types, FillMode fillMode = FillMode::Alternate);
97 ASPOSECPP_SHARED_API GraphicsPath(const ArrayPtr<PointF>& pts, const ArrayPtr<uint8_t>& types, FillMode fillMode = FillMode::Alternate);
98
99 ASPOSECPP_SHARED_API GraphicsPath(const SkPath& path);
100
102 ASPOSECPP_SHARED_API ~GraphicsPath();
103
106 ASPOSECPP_SHARED_API SharedPtr<PathData> get_PathData();
109 ASPOSECPP_SHARED_API ArrayPtr<uint8_t> get_PathTypes() const;
111 ASPOSECPP_SHARED_API ArrayPtr<PointF> get_PathPoints() const;
113 ASPOSECPP_SHARED_API int get_PointCount() const;
115 ASPOSECPP_SHARED_API void Reverse();
116
118 ASPOSECPP_SHARED_API FillMode get_FillMode();
121 ASPOSECPP_SHARED_API void set_FillMode(FillMode mode);
122
128 ASPOSECPP_SHARED_API void AddBezier(const Point& pt1, const Point& pt2, const Point& pt3, const Point& pt4);
134 ASPOSECPP_SHARED_API void AddBezier(const PointF& pt1, const PointF& pt2, const PointF& pt3, const PointF& pt4);
144 ASPOSECPP_SHARED_API void AddBezier(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
154 ASPOSECPP_SHARED_API void AddBezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
157 ASPOSECPP_SHARED_API void AddBeziers(const ArrayPtr<Point>& points);
160 ASPOSECPP_SHARED_API void AddBeziers(const ArrayPtr<PointF>& points);
161
165 ASPOSECPP_SHARED_API void AddLine(const Point& pt1, const Point& pt2);
169 ASPOSECPP_SHARED_API void AddLine(const PointF& pt1, const PointF& pt2);
175 ASPOSECPP_SHARED_API void AddLine(int x1, int y1, int x2, int y2);
181 ASPOSECPP_SHARED_API void AddLine(float x1, float y1, float x2, float y2);
182
185 ASPOSECPP_SHARED_API void AddLines(const ArrayPtr<PointF>& points);
188 ASPOSECPP_SHARED_API void AddLines(const ArrayPtr<Point>& points);
189
197 ASPOSECPP_SHARED_API void AddString(const String& text, const SharedPtr<FontFamily>& family, int style, float emSize, Point origin,
198 const SharedPtr<StringFormat>& stringFormat);
206 ASPOSECPP_SHARED_API void AddString(const String& text, const SharedPtr<FontFamily>& family, int style, float emSize, PointF origin,
207 const SharedPtr<StringFormat>& stringFormat);
215 ASPOSECPP_SHARED_API void AddString(const String& text, const SharedPtr<FontFamily>& family, int style, float emSize, Rectangle layoutRect,
216 const SharedPtr<StringFormat>& stringFormat);
224 ASPOSECPP_SHARED_API void AddString(const String& text, const SharedPtr<FontFamily>& family, int style, float emSize, RectangleF layoutRect,
225 const SharedPtr<StringFormat>& stringFormat);
226
234 ASPOSECPP_SHARED_API void AddArc(float x, float y, float width, float height, float startAngle, float sweepAngle);
242 ASPOSECPP_SHARED_API void AddArc(int x, int y, int width, int height, float startAngle, float sweepAngle);
247 ASPOSECPP_SHARED_API void AddArc(const RectangleF& rect, float startAngle, float sweepAngle);
252 ASPOSECPP_SHARED_API void AddArc(const Rectangle& rect, float startAngle, float sweepAngle);
253
259 ASPOSECPP_SHARED_API void AddEllipse(float x, float y, float width, float height);
265 ASPOSECPP_SHARED_API void AddEllipse(int x, int y, int width, int height);
268 ASPOSECPP_SHARED_API void AddEllipse(const RectangleF &rect);
271 ASPOSECPP_SHARED_API void AddEllipse(const Rectangle &rect);
272
280 ASPOSECPP_SHARED_API void AddPie(float x, float y, float width, float height, float startAngle, float sweepAngle);
288 ASPOSECPP_SHARED_API void AddPie(int x, int y, int width, int height, float startAngle, float sweepAngle);
293 ASPOSECPP_SHARED_API void AddPie(const Rectangle& rect, float startAngle, float sweepAngle);
294
300 ASPOSECPP_SHARED_API void AddPath(const SharedPtr<GraphicsPath>& path, bool connect);
301
304 ASPOSECPP_SHARED_API void AddRectangle(const Rectangle& rect);
307 ASPOSECPP_SHARED_API void AddRectangle(const RectangleF& rect);
308
311 ASPOSECPP_SHARED_API void AddRectangles(const ArrayPtr<Rectangle>& rects);
314 ASPOSECPP_SHARED_API void AddRectangles(const ArrayPtr<RectangleF>& rects);
315
318 ASPOSECPP_SHARED_API void AddPolygon(const ArrayPtr<PointF>& points);
319
322 ASPOSECPP_SHARED_API void AddPolygon(const ArrayPtr<Point>& points);
323
327 ASPOSECPP_SHARED_API void AddCurve(const ArrayPtr<PointF>& points, float tension = 0.5);
331 ASPOSECPP_SHARED_API void AddCurve(const ArrayPtr<Point>& points, float tension = 0.5);
337 ASPOSECPP_SHARED_API void AddCurve(const ArrayPtr<PointF>& points, int offset, int number_of_segments, float tension);
343 ASPOSECPP_SHARED_API void AddCurve(const ArrayPtr<Point>& points, int offset, int number_of_segments, float tension);
344
348 ASPOSECPP_SHARED_API void AddClosedCurve(const ArrayPtr<PointF>& points, float tension = 0.5);
352 ASPOSECPP_SHARED_API void AddClosedCurve(const ArrayPtr<Point>& points, float tension = 0.5);
353
355 ASPOSECPP_SHARED_API void StartFigure();
357 ASPOSECPP_SHARED_API void CloseFigure();
359 ASPOSECPP_SHARED_API void CloseAllFigures();
360
365 ASPOSECPP_SHARED_API RectangleF GetBounds(const MatrixPtr& matrix = nullptr, const SharedPtr<Pen>& pen = nullptr) const;
366
368 ASPOSECPP_SHARED_API PointF GetLastPoint() const;
369
371 ASPOSECPP_SHARED_API void Reset();
372
375 ASPOSECPP_SHARED_API void Transform(const MatrixPtr& matrix);
376 ASPOSECPP_SHARED_API void Transform(const SkMatrix& matrix);
377
380 ASPOSECPP_SHARED_API void Flatten();
384 ASPOSECPP_SHARED_API void Flatten(const MatrixPtr& matrix);
388 ASPOSECPP_SHARED_API void Flatten(const MatrixPtr& matrix, float flatness);
389
392 ASPOSECPP_SHARED_API void Widen(const SharedPtr<Pen>& pen);
393
396 ASPOSECPP_SHARED_API bool IsVisible(const PointF& point);
400 ASPOSECPP_SHARED_API bool IsVisible(float x, float y);
404 ASPOSECPP_SHARED_API bool IsOutlineVisible(const PointF& point, const SharedPtr<Pen>& pen);
405
408 virtual ASPOSECPP_SHARED_API SharedPtr<GraphicsPath> Clone();
410 void Dispose() { };
411
415 Detail::FigureType GetFigureFlags() { return m_figure_flags; }
418 ASPOSECPP_SHARED_API void SetMarkers();
419
420protected:
422 friend class CustomLineCap;
423 friend class PathGradientBrush;
424 friend class Details::Skia::SkiaData;
425
427 std::shared_ptr<SkPath> m_sk_path;
429 bool m_figure_started = true;
432 Detail::FigureType m_figure_flags = Detail::FigureType::Unknown;
433
443 ASPOSECPP_SHARED_API void AddBezierImpl(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3, SkScalar x4, SkScalar y4);
449 ASPOSECPP_SHARED_API void AddLineImpl(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2);
457 ASPOSECPP_SHARED_API void AddArcImpl(SkScalar left, SkScalar top, SkScalar width, SkScalar height, SkScalar startAngle, SkScalar sweepAngle);
463 ASPOSECPP_SHARED_API void AddEllipseImpl(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
471 ASPOSECPP_SHARED_API void AddPieImpl(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, SkScalar startAngle, SkScalar sweepAngle);
479 ASPOSECPP_SHARED_API void AddStringImpl(const String & text, const SharedPtr<FontFamily>& family, int style, float emSize, SkRect layoutRect, const SharedPtr<StringFormat>& stringFormat);
480
484 std::shared_ptr<SkPath> GetSkPath(const SharedPtr<Pen>& pen, const SkMatrix& matrix);
485
489 ASPOSECPP_SHARED_API ArrayPtr<uint8_t> get_PathTypesImpl(bool forceClose) const;
490
493 ASPOSECPP_SHARED_API ArrayPtr<uint8_t> get_PathTypesImpl() const;
494
498 static ASPOSECPP_SHARED_API SkPath ConvertCurves(const SkPath& source);
499
503 static ASPOSECPP_SHARED_API bool NeedConvertCurves(const SkPath& source);
504
505private:
507 bool IsClosedPath() const;
509 std::shared_ptr<SkPath> GetFlattenPath() const;
510};
511
512}}}
514DECLARE_USING_ENUM_OPERATORS(System::Drawing::Drawing2D::Detail);
515
516
517#endif // _aspose_drawing_drawing2d_graphics_path_h_
Represents a user-defined line cap. Objects of this class should only be allocated using System::Make...
Definition: custom_line_cap.h:40
Represents a set of connected lines and curves. Objects of this class should only be allocated using ...
Definition: graphics_path.h:80
ArrayPtr< uint8_t > get_PathTypes() const
Returns an array that contains values that indicate the types of the points that make up a path repre...
void CloseAllFigures()
Closes all open figures and starts a new one.
void AddLineImpl(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
Adds the specified line to the path represented by the current object.
void AddBezierImpl(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3, SkScalar x4, SkScalar y4)
Adds the specified cubic Bezier curve to the path represented by the current object.
void AddBeziers(const ArrayPtr< PointF > &points)
Adds a sequence of connected cubic Bezier curves to the current figure.
void AddArc(int x, int y, int width, int height, float startAngle, float sweepAngle)
Adds the specified elliptical arc to the path represented by the current object.
void Dispose()
Releases all operating system resources acquired by the current object.
Definition: graphics_path.h:410
void AddCurve(const ArrayPtr< Point > &points, int offset, int number_of_segments, float tension)
Adds the specified curve to the path represented by the current object.
void AddLine(float x1, float y1, float x2, float y2)
Adds the specified line to the path represented by the current object.
std::shared_ptr< SkPath > m_sk_path
The underlying SkPath object that contains the information about the path.
Definition: graphics_path.h:427
void Flatten(const MatrixPtr &matrix, float flatness)
Flattens each curve in the path by converting them into a series of connected lines.
FillMode get_FillMode()
Returns the fill mode of the current object.
void AddPolygon(const ArrayPtr< PointF > &points)
Adds the specified polygon to the path represented by the current object.
void AddPieImpl(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, SkScalar startAngle, SkScalar sweepAngle)
Adds the specified outline of the pie shape to the path represented by the current object.
void AddCurve(const ArrayPtr< PointF > &points, int offset, int number_of_segments, float tension)
Adds the specified curve to the path represented by the current object.
void AddLine(const PointF &pt1, const PointF &pt2)
Adds the specified line to the path represented by the current object.
static SkPath ConvertCurves(const SkPath &source)
Converts path curves into the ones available in .NET engine so translated code can work with them.
void AddArc(float x, float y, float width, float height, float startAngle, float sweepAngle)
Adds the specified elliptical arc to the path represented by the current object.
static bool NeedConvertCurves(const SkPath &source)
Check if ConvertCurves should be applied to source.
void AddArcImpl(SkScalar left, SkScalar top, SkScalar width, SkScalar height, SkScalar startAngle, SkScalar sweepAngle)
Adds the specified elliptical arc to the path represented by the current object.
void Flatten(const MatrixPtr &matrix)
Flattens each curve in the path by converting them into a series of connected lines....
GraphicsPath(const ArrayPtr< Point > &pts, const ArrayPtr< uint8_t > &types, FillMode fillMode=FillMode::Alternate)
Constructs a new instance of GraphicsPath object that represents the specified path.
void AddEllipse(int x, int y, int width, int height)
Adds the specified ellipse to the path represented by the current object.
void AddPolygon(const ArrayPtr< Point > &points)
Adds the specified polygon to the path represented by the current object.
void set_FillMode(FillMode mode)
Sets the fill mode of the current object.
void AddBezier(const Point &pt1, const Point &pt2, const Point &pt3, const Point &pt4)
Adds the specified cubic Bezier curve to the path represented by the current object.
void AddBezier(const PointF &pt1, const PointF &pt2, const PointF &pt3, const PointF &pt4)
Adds the specified cubic Bezier curve to the path represented by the current object.
virtual SharedPtr< GraphicsPath > Clone()
Creates a copy of the current object.
void AddLine(const Point &pt1, const Point &pt2)
Adds the specified line to the path represented by the current object.
RectangleF GetBounds(const MatrixPtr &matrix=nullptr, const SharedPtr< Pen > &pen=nullptr) const
Returns a RectangleF object that represents a rectangle that bounds the path represented by the curre...
void AddStringImpl(const String &text, const SharedPtr< FontFamily > &family, int style, float emSize, SkRect layoutRect, const SharedPtr< StringFormat > &stringFormat)
Adds a string of text to the path represented by the current object.
void AddPath(const SharedPtr< GraphicsPath > &path, bool connect)
Adds the specified path to the path represented by the current object.
std::shared_ptr< SkPath > GetSkPath(const SharedPtr< Pen > &pen, const SkMatrix &matrix)
Returns a processed SkPath.
void AddLines(const ArrayPtr< Point > &points)
Adds the specified series of connected line segments to the path represented by the current object.
void AddBeziers(const ArrayPtr< Point > &points)
Adds a sequence of connected cubic Bezier curves to the current figure.
void AddString(const String &text, const SharedPtr< FontFamily > &family, int style, float emSize, Rectangle layoutRect, const SharedPtr< StringFormat > &stringFormat)
Adds a string of text to the path represented by the current object.
void AddPie(const Rectangle &rect, float startAngle, float sweepAngle)
Adds the specified outline of the pie shape to the path represented by the current object.
ArrayPtr< uint8_t > get_PathTypesImpl(bool forceClose) const
Returns an array that contains values that indicate the types of the points that make up a path repre...
void AddString(const String &text, const SharedPtr< FontFamily > &family, int style, float emSize, RectangleF layoutRect, const SharedPtr< StringFormat > &stringFormat)
Adds a string of text to the path represented by the current object.
bool IsOutlineVisible(const PointF &point, const SharedPtr< Pen > &pen)
Indicates whether the specified point is contained within (under) the outline of this GraphicsPath wh...
void AddCurve(const ArrayPtr< PointF > &points, float tension=0.5)
Adds the specified curve to the path represented by the current object.
void AddArc(const Rectangle &rect, float startAngle, float sweepAngle)
Adds the specified elliptical arc to the path represented by the current object.
bool IsVisible(const PointF &point)
Determines if the specified point is contained within the path represented by the current object.
void AddArc(const RectangleF &rect, float startAngle, float sweepAngle)
Adds the specified elliptical arc to the path represented by the current object.
ArrayPtr< uint8_t > get_PathTypesImpl() const
Returns an array that contains values that indicate the types of the points that make up a path repre...
void AddBezier(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
Adds the specified cubic Bezier curve to the path represented by the current object.
void AddString(const String &text, const SharedPtr< FontFamily > &family, int style, float emSize, Point origin, const SharedPtr< StringFormat > &stringFormat)
Adds a string of text to the path represented by the current object.
void AddLines(const ArrayPtr< PointF > &points)
Adds the specified series of connected line segments to the path represented by the current object.
void Transform(const SkMatrix &matrix)
void AddRectangles(const ArrayPtr< Rectangle > &rects)
Adds the specified series of rectangles to the path represented by the current object.
void AddBezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
Adds the specified cubic Bezier curve to the path represented by the current object.
void Widen(const SharedPtr< Pen > &pen)
Replaces this path with an outline around the original path.
void AddCurve(const ArrayPtr< Point > &points, float tension=0.5)
Adds the specified curve to the path represented by the current object.
void AddString(const String &text, const SharedPtr< FontFamily > &family, int style, float emSize, PointF origin, const SharedPtr< StringFormat > &stringFormat)
Adds a string of text to the path represented by the current object.
void AddPie(float x, float y, float width, float height, float startAngle, float sweepAngle)
Adds the specified outline of the pie shape to the path represented by the current object.
GraphicsPath(const ArrayPtr< PointF > &pts, const ArrayPtr< uint8_t > &types, FillMode fillMode=FillMode::Alternate)
Constructs a new instance of GraphicsPath object that represents the specified path.
void AddPie(int x, int y, int width, int height, float startAngle, float sweepAngle)
Adds the specified outline of the pie shape to the path represented by the current object.
Detail::FigureType GetFigureFlags()
Returns a value which is a bitwise combination of Detail::FigureType values that indicates what types...
Definition: graphics_path.h:415
void AddRectangle(const Rectangle &rect)
Adds the specified rectangle to the path represented by the current object.
void AddClosedCurve(const ArrayPtr< PointF > &points, float tension=0.5)
Adds the specified closed curve to the path represented by the current object.
PointF GetLastPoint() const
Returns a PointF object representing the last point in the path.
void Transform(const MatrixPtr &matrix)
Transforms the path represented by the current object by applying the specified transform matrix to i...
void AddEllipse(const Rectangle &rect)
Adds the specified ellipse to the path represented by the current object.
void Reverse()
Reverses the order of points in the PathPoints array of this GraphicsPath.
void AddEllipse(float x, float y, float width, float height)
Adds the specified ellipse to the path represented by the current object.
void AddLine(int x1, int y1, int x2, int y2)
Adds the specified line to the path represented by the current object.
void AddEllipseImpl(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
Adds the specified ellipse to the path represented by the current object.
void Flatten()
Flattens each curve in the path by converting them into a series of connected lines....
int get_PointCount() const
Returns the number of points in the path represented by the current object.
void StartFigure()
Starts a new figure.
bool IsVisible(float x, float y)
Determines if the specified point is contained within the path represented by the current object.
GraphicsPath(FillMode fillMode=FillMode::Alternate)
Constructs a new instance of GraphicsPath class with the specified fill mode.
void Reset()
Empties the path by removing all points from it.
void AddRectangles(const ArrayPtr< RectangleF > &rects)
Adds the specified series of rectangles to the path represented by the current object.
void CloseFigure()
Closes the current figure and starts a new one.
void AddEllipse(const RectangleF &rect)
Adds the specified ellipse to the path represented by the current object.
ArrayPtr< PointF > get_PathPoints() const
Returns an array that contains points that make up a path represented by the current object.
void AddClosedCurve(const ArrayPtr< Point > &points, float tension=0.5)
Adds the specified closed curve to the path represented by the current object.
SharedPtr< PathData > get_PathData()
Returns a PathData object containing the points that make up a path represented by the current object...
void AddRectangle(const RectangleF &rect)
Adds the specified rectangle to the path represented by the current object.
Represents a brush that fills the interior of a GraphicsPath object with a gradient....
Definition: path_gradient_brush.h:39
Represents a drawing surface. Objects of this class should only be allocated using System::MakeObject...
Definition: graphics.h:68
Represents a pair of single-precision floating point X and Y coordinates of a point on a 2-dimensiona...
Definition: point_f.h:14
Represents a pair of integer X and Y coordinates of a point on a 2-dimensional plane....
Definition: point.h:15
Represents a rectangular area of an image defined as single-precision floating point X and Y coordina...
Definition: rectangle_f.h:15
Represents a rectangular area of an image defined as integer X and Y coordinates of its upper left co...
Definition: rectangle.h:19
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
FillMode
Specifies how to fill the interior of a closed path.
Definition: fill_mode.h:9
Definition: db_command.h:9