/// <summary> /// Draws this object to the <see cref="T:EscherTiler.Graphics.IGraphics" /> provided. /// </summary> /// <param name="graphics">The graphics object to use to draw this object.</param> public override void Draw(IGraphics graphics) { if (_resourceManager == null) { throw new ObjectDisposedException(nameof(ShapeController)); } graphics.ResourceManager = _resourceManager; foreach (Shape shape in Shapes) { using (IGraphicsPath path = graphics.CreatePath()) { bool first = true; foreach (Vertex vertex in shape.Vertices) { if (first) { path.Start(vertex.Location); } else { path.AddLine(vertex.Location); } first = false; } path.End(); graphics.DrawPath(path); } } }
/// <summary> /// Populates the graphics path given from this tile. /// </summary> /// <param name="path">The path.</param> public void PopulateGraphicsPath([NotNull] IGraphicsPath path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } bool first = true; Matrix3x2 lastTransform = Matrix3x2.Identity; Edge lastEdge = null; foreach (EdgePartShape partShape in PartShapes) { Matrix3x2 edgeTransform = partShape.Edge == lastEdge ? lastTransform : partShape.GetLineTransform() * Transform; lastTransform = edgeTransform; lastEdge = partShape.Edge; IEnumerable <ILine> lines = partShape.Lines; foreach (ILine line in partShape.Part.IsClockwise ? lines : lines.Reverse()) { if (first) { first = false; path.Start(Vector2.Transform(partShape.Part.IsClockwise ? line.Start : line.End, edgeTransform)); } line.AddToPath(path, edgeTransform, !partShape.Part.IsClockwise); } } path.End(); }