static void test_reverse(void) { GpStatus status; GpPath *path; GpPointF pts[7]; INT i; for(i = 0; i < 7; i++){ pts[i].X = i * 5.0 * (REAL)(i % 2); pts[i].Y = 50.0 - i * 5.0; } GdipCreatePath(FillModeAlternate, &path); /* NULL argument */ status = GdipReversePath(NULL); expect(InvalidParameter, status); /* empty path */ status = GdipReversePath(path); expect(Ok, status); GdipAddPathLine2(path, pts, 4); GdipClosePathFigure(path); GdipAddPathLine2(path, &(pts[4]), 3); status = GdipReversePath(path); expect(Ok, status); ok_path(path, reverse_path, sizeof(reverse_path)/sizeof(path_test_t), FALSE); GdipDeletePath(path); }
static void test_line2(void) { GpStatus status; GpPath* path; int i; GpPointF line2_points[9]; for(i = 0; i < 9; i ++){ line2_points[i].X = i * 5.0 * (REAL)(i % 2); line2_points[i].Y = 50.0 - i * 5.0; } GdipCreatePath(FillModeAlternate, &path); status = GdipAddPathLine2(path, line2_points, 3); expect(Ok, status); status = GdipAddPathLine2(path, &(line2_points[3]), 3); expect(Ok, status); status = GdipClosePathFigure(path); expect(Ok, status); status = GdipAddPathLine2(path, &(line2_points[6]), 3); expect(Ok, status); ok_path(path, line2_path, sizeof(line2_path)/sizeof(path_test_t), FALSE); GdipDeletePath(path); }
static void test_ellipse(void) { GpStatus status; GpPath *path; GpPointF points[2]; points[0].X = 7.0; points[0].Y = 11.0; points[1].X = 13.0; points[1].Y = 17.0; GdipCreatePath(FillModeAlternate, &path); status = GdipAddPathEllipse(path, 10.0, 100.0, 20.0, 50.5); expect(Ok, status); GdipAddPathLine2(path, points, 2); status = GdipAddPathEllipse(path, 10.0, 200.0, -5.0, -10.0); expect(Ok, status); GdipClosePathFigure(path); status = GdipAddPathEllipse(path, 10.0, 300.0, 0.0, 1.0); expect(Ok, status); ok_path(path, ellipse_path, sizeof(ellipse_path)/sizeof(path_test_t), FALSE); GdipDeletePath(path); }
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y, REAL width, REAL height) { GpPath *backup; GpPointF ptf[2]; GpStatus retstat; BOOL old_new; if(!path || width < 0.0 || height < 0.0) return InvalidParameter; /* make a backup copy of path data */ if((retstat = GdipClonePath(path, &backup)) != Ok) return retstat; /* rectangle should start as new path */ old_new = path->newfigure; path->newfigure = TRUE; if((retstat = GdipAddPathLine(path,x,y,x+width,y)) != Ok){ path->newfigure = old_new; goto fail; } ptf[0].X = x+width; ptf[0].Y = y+height; ptf[1].X = x; ptf[1].Y = y+height; if((retstat = GdipAddPathLine2(path,(GDIPCONST GpPointF*)&ptf,2)) != Ok) goto fail; path->pathdata.Types[path->pathdata.Count-1] |= PathPointTypeCloseSubpath; /* free backup */ GdipDeletePath(backup); return Ok; fail: /* reverting */ GdipDeletePath(path); GdipClonePath(backup, &path); GdipDeletePath(backup); return retstat; }
GpStatus WINGDIPAPI GdipAddPathLine2I(GpPath *path, GDIPCONST GpPoint *points, INT count) { GpPointF *pointsF; INT i; GpStatus stat; if(count <= 0) return InvalidParameter; pointsF = GdipAlloc(sizeof(GpPointF) * count); if(!pointsF) return OutOfMemory; for(i = 0;i < count; i++){ pointsF[i].X = (REAL)points[i].X; pointsF[i].Y = (REAL)points[i].Y; } stat = GdipAddPathLine2(path, pointsF, count); GdipFree(pointsF); return stat; }
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); }