private void DrawEntity(Graphics graphics, ProjectedCircle circle, CadColor?layerColor, Vector offset) { // TODO: handle rotation var width = circle.RadiusX * 2.0; var height = circle.RadiusY * 2.0; var topLeft = (Point)(circle.Center - new Point(circle.RadiusX, circle.RadiusX, 0.0) + offset); graphics.DrawEllipse(ColorToPen(GetDisplayColor(layerColor, circle.OriginalCircle.Color)), (float)topLeft.X, (float)topLeft.Y, (float)width, (float)height); }
public static ProjectedCircle Project(Circle circle, Layer layer, Matrix4 transform) { // find axis endpoints var rightVector = Vector.RightVectorFromNormal(circle.Normal); var upVector = circle.Normal.Cross(rightVector).Normalize(); var pt = transform.Transform(circle.Center + (rightVector * circle.Radius)); var qt = transform.Transform(circle.Center + (upVector * circle.Radius)); var m = transform.Transform(circle.Center); return(ProjectedCircle.FromConjugateDiameters(circle, layer, m, pt, qt)); }
private static XElement ToXElement(ProjectedCircle circle) { var xml = new XElement(SvgPlotter.Xmlns + "ellipse", new XAttribute("cx", circle.Center.X), new XAttribute("cy", circle.Center.Y), new XAttribute("rx", circle.RadiusX), new XAttribute("ry", circle.RadiusY), new XAttribute("fill-opacity", 0)); AddRotationTransform(xml, circle.Rotation, circle.Center); AddStrokeIfNotDefault(xml, circle.OriginalCircle.Color); return(xml); }
public static ProjectedArc Project(Arc arc, Layer layer, Matrix4 transform) { // find the containing circle var rightVector = Vector.RightVectorFromNormal(arc.Normal); var upVector = arc.Normal.Cross(rightVector).Normalize(); var pt = transform.Transform(arc.Center + (rightVector * arc.Radius)); var qt = transform.Transform(arc.Center + (upVector * arc.Radius)); var m = transform.Transform(arc.Center); var circle = ProjectedCircle.FromConjugateDiameters(null, layer, m, pt, qt); // find the new start and end angles var startPoint = transform.Transform(arc.EndPoint1); var endPoint = transform.Transform(arc.EndPoint2); var startAngle = (startPoint - circle.Center).ToAngle(); var endAngle = (endPoint - circle.Center).ToAngle(); return(new ProjectedArc(arc, layer, circle.Center, circle.RadiusX, circle.RadiusY, circle.Rotation, startAngle, endAngle, startPoint, endPoint)); }