public void SetAndRealizeClipRect(XRect clipRect) { XGraphicsPath clipPath = new XGraphicsPath(); clipPath.AddRectangle(clipRect); RealizeClipPath(clipPath); }
public void Fill(XGraphics graphics, XBrush brush) { XGraphicsPath path = new XGraphicsPath { FillMode = XFillMode.Winding }; bool hasFigure = false; int ptIndex = 0; foreach (Command command in Commands) { switch (command) { case Command.MoveTo: if (hasFigure) { path.CloseFigure(); hasFigure = false; } ptIndex++; break; case Command.LineTo: path.AddLine(Points[ptIndex - 1], Points[ptIndex]); ptIndex += 1; hasFigure = true; break; case Command.CubicCurveTo: path.AddBezier(Points[ptIndex - 1], Points[ptIndex], Points[ptIndex + 1], Points[ptIndex + 2]); ptIndex += 3; hasFigure = true; break; case Command.CloseSubpath: if (hasFigure) { path.CloseFigure(); hasFigure = false; } break; case Command.Rectangle: path.AddRectangle(Points[ptIndex + 1].X, Points[ptIndex + 1].Y, Points[ptIndex].X, Points[ptIndex].Y); ptIndex += 2; path.CloseFigure(); hasFigure = false; break; } } if (hasFigure) { path.CloseFigure(); } graphics.DrawPath(brush, path); }
public void Stroke(XGraphics graphics, XPen pen) { XGraphicsPath path = new XGraphicsPath(); bool hasFigure = false; int ptIndex = 0; foreach (Command command in Commands) { switch (command) { case Command.MoveTo: if (hasFigure) { graphics.DrawPath(pen, path); path = new XGraphicsPath(); hasFigure = false; } ptIndex++; break; case Command.LineTo: path.AddLine(Points[ptIndex - 1], Points[ptIndex]); ptIndex += 1; hasFigure = true; break; case Command.CubicCurveTo: path.AddBezier(Points[ptIndex - 1], Points[ptIndex], Points[ptIndex + 1], Points[ptIndex + 2]); ptIndex += 3; hasFigure = true; break; case Command.CloseSubpath: if (hasFigure) { path.CloseFigure(); hasFigure = false; } graphics.DrawPath(pen, path); path = new XGraphicsPath(); break; case Command.Rectangle: path.AddRectangle(Points[ptIndex + 1].X, Points[ptIndex + 1].Y, Points[ptIndex].X, Points[ptIndex].Y); ptIndex += 2; path.CloseFigure(); hasFigure = false; break; } } graphics.DrawPath(pen, path); }
public override void AddRectangle(double x, double y, double width, double height) { // TODO: Do we need to update CurrentPathPoint here? CurrentPath.AddRectangle(x, y, width, height); }