diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-06-25 10:45:48 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-06-28 03:15:08 +0200 |
commit | 80eb3fd393dd6d67f931c03b261b2558c7198da2 (patch) | |
tree | 49d4437af42942f3dee68c39b858e5d8762bf0cc /basegfx/test | |
parent | 3aa02e11e489c0f82024f5e323d6b63b4dcc3193 (diff) |
add appendQuadraticBezierSegment to B2DPolygon
This adds a convenience method to B2DPolygon to add a quadratic
bezier segment, which converts its one control point to two
control points of a cubic bezier segment.
The SVG path import is also modified to use this new method
instead of converting inside the importer itself.
Change-Id: I96e9b306066d9ccf2542b17a117db01fa235f405
Reviewed-on: https://gerrit.libreoffice.org/74809
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'basegfx/test')
-rw-r--r-- | basegfx/test/B2DPolygonTest.cxx | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/basegfx/test/B2DPolygonTest.cxx b/basegfx/test/B2DPolygonTest.cxx index 0bb3f15dfdbe..581108b960a5 100644 --- a/basegfx/test/B2DPolygonTest.cxx +++ b/basegfx/test/B2DPolygonTest.cxx @@ -29,7 +29,7 @@ namespace basegfx class b2dpolygon : public CppUnit::TestFixture { public: - void testBasics() + void testCubicBezier() { B2DPolygon aPoly; @@ -78,12 +78,29 @@ public: aPoly.getB2DPoint(1)); } + void testQuadraticBezier() + { + B2DPolygon aPoly; + + aPoly.appendQuadraticBezierSegment(B2DPoint(0, 0), B2DPoint(3, 3)); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("polygon size is wrong", sal_uInt32(1), aPoly.count()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("first polygon point wrong", B2DPoint(3, 3), + aPoly.getB2DPoint(0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("first control point wrong", B2DPoint(1, 1), + aPoly.getPrevControlPoint(0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("second control point wrong", B2DPoint(3, 3), + aPoly.getNextControlPoint(0)); + CPPUNIT_ASSERT_MESSAGE("next control point not used", !aPoly.isNextControlPointUsed(0)); + } + // Change the following lines only, if you add, remove or rename // member functions of the current class, // because these macros are need by auto register mechanism. CPPUNIT_TEST_SUITE(b2dpolygon); - CPPUNIT_TEST(testBasics); + CPPUNIT_TEST(testCubicBezier); + CPPUNIT_TEST(testQuadraticBezier); CPPUNIT_TEST_SUITE_END(); }; // class b2dpolygon |