diff options
Diffstat (limited to 'xfa/fxgraphics/cfx_path_generator.cpp')
-rw-r--r-- | xfa/fxgraphics/cfx_path_generator.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/xfa/fxgraphics/cfx_path_generator.cpp b/xfa/fxgraphics/cfx_path_generator.cpp index f2dc182b55..aadaa85ad0 100644 --- a/xfa/fxgraphics/cfx_path_generator.cpp +++ b/xfa/fxgraphics/cfx_path_generator.cpp @@ -8,15 +8,9 @@ #include "core/fxge/include/cfx_pathdata.h" -CFX_PathGenerator::CFX_PathGenerator() : m_pPathData(nullptr) {} +CFX_PathGenerator::CFX_PathGenerator() : m_pPathData(new CFX_PathData) {} -void CFX_PathGenerator::Create() { - m_pPathData = new CFX_PathData; -} - -CFX_PathGenerator::~CFX_PathGenerator() { - delete m_pPathData; -} +CFX_PathGenerator::~CFX_PathGenerator() {} void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { if (pPathData && pPathData->GetPointCount() > 0) { @@ -25,6 +19,7 @@ void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { AddPathData(pPoints, nCount); } } + void CFX_PathGenerator::AddPathData(FX_PATHPOINT* pPoints, int nCount) { if (pPoints && nCount > 0) { int nOldCount = m_pPathData->GetPointCount(); @@ -34,14 +29,17 @@ void CFX_PathGenerator::AddPathData(FX_PATHPOINT* pPoints, int nCount) { sizeof(FX_PATHPOINT) * nCount); } } + void CFX_PathGenerator::MoveTo(FX_FLOAT x, FX_FLOAT y) { m_pPathData->AddPointCount(1); m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_MOVETO); } + void CFX_PathGenerator::LineTo(FX_FLOAT x, FX_FLOAT y) { m_pPathData->AddPointCount(1); m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_LINETO); } + void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, FX_FLOAT ctrl_y1, FX_FLOAT ctrl_x2, @@ -54,6 +52,7 @@ void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, m_pPathData->SetPoint(old_count + 1, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); m_pPathData->SetPoint(old_count + 2, to_x, to_y, FXPT_BEZIERTO); } + void CFX_PathGenerator::Close() { if (m_pPathData->GetPointCount() > 0) { int index = m_pPathData->GetPointCount() - 1; @@ -61,6 +60,7 @@ void CFX_PathGenerator::Close() { pPoints[index].m_Flag |= FXPT_CLOSEFIGURE; } } + void CFX_PathGenerator::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, @@ -70,6 +70,7 @@ void CFX_PathGenerator::AddLine(FX_FLOAT x1, m_pPathData->SetPoint(old_count, x1, y1, FXPT_MOVETO); m_pPathData->SetPoint(old_count + 1, x2, y2, FXPT_LINETO); } + void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, FX_FLOAT start_y, FX_FLOAT ctrl_x1, @@ -85,18 +86,21 @@ void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, m_pPathData->SetPoint(old_count + 2, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); m_pPathData->SetPoint(old_count + 3, end_x, end_y, FXPT_BEZIERTO); } + void CFX_PathGenerator::AddRectangle(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) { m_pPathData->AppendRect(x1, y1, x2, y2); } + void CFX_PathGenerator::AddEllipse(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, FX_FLOAT height) { AddArc(x, y, width, height, 0, FX_PI * 2); } + void CFX_PathGenerator::ArcTo(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, @@ -127,6 +131,7 @@ void CFX_PathGenerator::ArcTo(FX_FLOAT x, bezier_y = y + (height * FXSYS_sin(start_angle + sweep_angle)); m_pPathData->SetPoint(old_count + 2, bezier_x, bezier_y, FXPT_BEZIERTO); } + void CFX_PathGenerator::AddArc(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, @@ -178,6 +183,7 @@ void CFX_PathGenerator::AddArc(FX_FLOAT x, start_angle += local_sweep; } while (!done); } + void CFX_PathGenerator::AddPie(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, |