static void test_flatten(void) { GpStatus status; GpPath *path; GpMatrix *m; status = GdipCreatePath(FillModeAlternate, &path); expect(Ok, status); status = GdipCreateMatrix(&m); expect(Ok, status); /* NULL arguments */ status = GdipFlattenPath(NULL, NULL, 0.0); expect(InvalidParameter, status); status = GdipFlattenPath(NULL, m, 0.0); expect(InvalidParameter, status); /* flatten empty path */ status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); status = GdipTransformPath(path, 0); expect(Ok, status); status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 50.0); expect(Ok, status); status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); ok_path(path, flattenellipse_path, sizeof(flattenellipse_path)/sizeof(path_test_t), TRUE); status = GdipResetPath(path); expect(Ok, status); status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 100.0); expect(Ok, status); status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); ok_path(path, flattenline_path, sizeof(flattenline_path)/sizeof(path_test_t), FALSE); status = GdipResetPath(path); expect(Ok, status); status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 50.0, 0.0, 90.0); expect(Ok, status); status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); ok_path(path, flattenarc_path, sizeof(flattenarc_path)/sizeof(path_test_t), TRUE); /* easy case - quater of a full circle */ status = GdipResetPath(path); expect(Ok, status); status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0); expect(Ok, status); status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); ok_path(path, flattenquater_path, sizeof(flattenquater_path)/sizeof(path_test_t), FALSE); GdipDeleteMatrix(m); GdipDeletePath(path); }
static void test_pathpath(void) { GpStatus status; GpPath* path1, *path2; GdipCreatePath(FillModeAlternate, &path2); GdipAddPathArc(path2, 100.0, 100.0, 500.0, 700.0, 95.0, 100.0); GdipCreatePath(FillModeAlternate, &path1); GdipAddPathArc(path1, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0); status = GdipAddPathPath(path1, path2, FALSE); expect(Ok, status); GdipAddPathArc(path1, 100.0, 100.0, 500.0, 700.0, -80.0, 100.0); status = GdipAddPathPath(path1, path2, TRUE); expect(Ok, status); ok_path(path1, pathpath_path, sizeof(pathpath_path)/sizeof(path_test_t), FALSE); GdipDeletePath(path1); GdipDeletePath(path2); }
static void test_arc(void) { GpStatus status; GpPath* path; GdipCreatePath(FillModeAlternate, &path); /* Exactly 90 degrees */ status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0); expect(Ok, status); /* Over 90 degrees */ status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0); expect(Ok, status); /* Negative start angle */ status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, -80.0, 100.0); expect(Ok, status); /* Negative sweep angle */ status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 80.0, -100.0); expect(Ok, status); /* More than a full revolution */ status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 50.0, -400.0); expect(Ok, status); /* 0 sweep angle */ status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 50.0, 0.0); expect(Ok, status); ok_path(path, arc_path, sizeof(arc_path)/sizeof(path_test_t), FALSE); GdipDeletePath(path); }
static void test_linei(void) { GpStatus status; GpPath *path; GdipCreatePath(FillModeAlternate, &path); status = GdipAddPathLineI(path, 5.0, 5.0, 6.0, 8.0); expect(Ok, status); GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, -80.0, 100.0); status = GdipAddPathLineI(path, 15.0, 15.0, 26.0, 28.0); expect(Ok, status); GdipClosePathFigure(path); status = GdipAddPathLineI(path, 35.0, 35.0, 36.0, 38.0); expect(Ok, status); ok_path(path, linei_path, sizeof(linei_path)/sizeof(path_test_t), FALSE); GdipDeletePath(path); }
GpStatus WINGDIPAPI GdipAddPathArcI(GpPath *path, INT x1, INT y1, INT x2, INT y2, REAL startAngle, REAL sweepAngle) { return GdipAddPathArc(path,(REAL)x1,(REAL)y1,(REAL)x2,(REAL)y2,startAngle,sweepAngle); }
static void test_worldbounds(void) { GpStatus status; GpPath *path; GpPen *pen; GpMatrix *matrix; GpRectF bounds; GpPointF line2_points[10]; int i; for(i = 0; i < 10; i ++){ line2_points[i].X = 200.0 + i * 50.0 * (i % 2); line2_points[i].Y = 200.0 + i * 50.0 * !(i % 2); } GdipCreatePen1((ARGB)0xdeadbeef, 20.0, UnitWorld, &pen); GdipSetPenEndCap(pen, LineCapSquareAnchor); GdipCreateMatrix2(1.5, 0.0, 1.0, 1.2, 10.4, 10.2, &matrix); GdipCreatePath(FillModeAlternate, &path); GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0); GdipAddPathLine2(path, &(line2_points[0]), 10); status = GdipGetPathWorldBounds(path, &bounds, NULL, NULL); expect(Ok, status); GdipDeletePath(path); expectf(200.0, bounds.X); expectf(200.0, bounds.Y); expectf(450.0, bounds.Width); expectf(600.0, bounds.Height); GdipCreatePath(FillModeAlternate, &path); GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0); GdipAddPathLine2(path, &(line2_points[0]), 10); status = GdipGetPathWorldBounds(path, &bounds, matrix, NULL); expect(Ok, status); GdipDeletePath(path); expectf(510.4, bounds.X); expectf(250.2, bounds.Y); expectf(1275.0, bounds.Width); expectf(720.0, bounds.Height); GdipCreatePath(FillModeAlternate, &path); GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0); GdipAddPathLine2(path, &(line2_points[0]), 10); status = GdipGetPathWorldBounds(path, &bounds, NULL, pen); expect(Ok, status); GdipDeletePath(path); expectf(100.0, bounds.X); expectf(100.0, bounds.Y); expectf(650.0, bounds.Width); expectf(800.0, bounds.Height); GdipCreatePath(FillModeAlternate, &path); GdipAddPathLine2(path, &(line2_points[0]), 2); status = GdipGetPathWorldBounds(path, &bounds, NULL, pen); expect(Ok, status); GdipDeletePath(path); expectf(156.0, bounds.X); expectf(156.0, bounds.Y); expectf(138.0, bounds.Width); expectf(88.0, bounds.Height); line2_points[2].X = 2 * line2_points[1].X - line2_points[0].X; line2_points[2].Y = 2 * line2_points[1].Y - line2_points[0].Y; GdipCreatePath(FillModeAlternate, &path); GdipAddPathLine2(path, &(line2_points[0]), 3); status = GdipGetPathWorldBounds(path, &bounds, NULL, pen); expect(Ok, status); GdipDeletePath(path); expectf(100.0, bounds.X); expectf(100.0, bounds.Y); expectf(300.0, bounds.Width); expectf(200.0, bounds.Height); GdipCreatePath(FillModeAlternate, &path); GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 45.0, 20.0); status = GdipGetPathWorldBounds(path, &bounds, NULL, pen); expect(Ok, status); GdipDeletePath(path); expectf(386.7, bounds.X); expectf(553.4, bounds.Y); expectf(266.8, bounds.Width); expectf(289.6, bounds.Height); GdipCreatePath(FillModeAlternate, &path); status = GdipGetPathWorldBounds(path, &bounds, matrix, pen); expect(Ok, status); GdipDeletePath(path); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); expectf(0.0, bounds.Width); expectf(0.0, bounds.Height); GdipCreatePath(FillModeAlternate, &path); GdipAddPathLine2(path, &(line2_points[0]), 2); status = GdipGetPathWorldBounds(path, &bounds, matrix, pen); expect(Ok, status); GdipDeletePath(path); todo_wine{ expectf(427.9, bounds.X); expectf(167.7, bounds.Y); expectf(239.9, bounds.Width); expectf(164.9, bounds.Height); } GdipDeleteMatrix(matrix); GdipCreateMatrix2(0.9, -0.5, -0.5, -1.2, 10.4, 10.2, &matrix); GdipCreatePath(FillModeAlternate, &path); GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0); GdipAddPathLine2(path, &(line2_points[0]), 10); status = GdipGetPathWorldBounds(path, &bounds, matrix, NULL); expect(Ok, status); GdipDeletePath(path); GdipDeleteMatrix(matrix); expectf(-209.6, bounds.X); expectf(-1274.8, bounds.Y); expectf(705.0, bounds.Width); expectf(945.0, bounds.Height); GdipDeletePen(pen); }