reed@android.com | 5e5adfd | 2009-03-07 03:39:23 +0000 | [diff] [blame] | 1 | #include "Test.h" |
| 2 | #include "SkPathMeasure.h" |
| 3 | |
| 4 | static void TestPathMeasure(skiatest::Reporter* reporter) { |
| 5 | SkPath path; |
| 6 | |
| 7 | path.moveTo(0, 0); |
| 8 | path.lineTo(SK_Scalar1, 0); |
| 9 | path.lineTo(SK_Scalar1, SK_Scalar1); |
| 10 | path.lineTo(0, SK_Scalar1); |
| 11 | |
| 12 | SkPathMeasure meas(path, true); |
| 13 | SkScalar length = meas.getLength(); |
| 14 | SkASSERT(length == SK_Scalar1*4); |
| 15 | |
| 16 | path.reset(); |
| 17 | path.moveTo(0, 0); |
| 18 | path.lineTo(SK_Scalar1*3, SK_Scalar1*4); |
| 19 | meas.setPath(&path, false); |
| 20 | length = meas.getLength(); |
| 21 | REPORTER_ASSERT(reporter, length == SK_Scalar1*5); |
| 22 | |
| 23 | path.reset(); |
| 24 | path.addCircle(0, 0, SK_Scalar1); |
| 25 | meas.setPath(&path, true); |
| 26 | length = meas.getLength(); |
| 27 | // SkDebugf("circle arc-length = %g\n", length); |
| 28 | |
| 29 | for (int i = 0; i < 8; i++) { |
| 30 | SkScalar d = length * i / 8; |
| 31 | SkPoint p; |
| 32 | SkVector v; |
| 33 | meas.getPosTan(d, &p, &v); |
| 34 | #if 0 |
| 35 | SkDebugf("circle arc-length=%g, pos[%g %g] tan[%g %g]\n", |
| 36 | d, p.fX, p.fY, v.fX, v.fY); |
| 37 | #endif |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | #include "TestClassDef.h" |
| 42 | DEFINE_TESTCLASS("PathMeasure", PathMeasureTestClass, TestPathMeasure) |