public void Stroke_LineCapTest() { StrokeStyle target = new StrokeStyle(); //Default LineCaps expected = PDFStyleConst.DefaultLineCaps; Assert.AreEqual(expected, target.LineCap); //Set value expected = LineCaps.Projecting; LineCaps actual; target.LineCap = expected; actual = target.LineCap; Assert.AreEqual(expected, actual); // Change Value expected = LineCaps.Round; target.LineCap = expected; actual = target.LineCap; Assert.AreEqual(expected, actual); //Remove value expected = PDFStyleConst.DefaultLineCaps; target.RemoveLineCap(); actual = target.LineCap; Assert.AreEqual(expected, actual); }
public static bool TryParseLineCap(string val, out LineCaps cap) { bool result; switch (val) { case ("butt"): cap = LineCaps.Butt; result = true; break; case ("round"): cap = LineCaps.Round; result = true; break; case ("square"): cap = LineCaps.Square; result = true; break; default: cap = LineCaps.Butt; result = false; break; } return(result); }
public void LineCaps_Test() { PDFPen target = PDFPen.Create(PDFColors.Aqua, 1); LineCaps expected = LineCaps.Butt; LineCaps actual = target.LineCaps; Assert.AreEqual(expected, actual); target.LineCaps = LineCaps.Projecting; actual = target.LineCaps; Assert.AreEqual(actual, LineCaps.Projecting); }
protected bool DoConvertLineCap(StyleBase style, object value, out LineCaps cap) { if (null == value) { cap = LineCaps.Butt; return(false); } else if (value is LineCaps c) { cap = c; return(true); } else if (TryParseLineCap(value.ToString(), out cap)) { return(true); } else { return(false); } }
public void RenderLineCap(LineCaps linecap) { PDFNumber cap = (PDFNumber)(int)linecap; Writer.WriteOpCodeS(PDFOpCode.GraphLineCap, cap); }
/// <summary> /// Creates a wireframe from a collection of <see cref="Element3D"/>s. /// </summary> /// <param name="object3D">The collection of <see cref="Element3D"/>s. <see cref="Line3DElement"/>s and <see cref="Point3DElement"/>s are ignored.</param> /// <param name="colour">The colour of the <see cref="Line3DElement"/>s returned by this method.</param> /// <param name="thickness">The thickness of the <see cref="Line3DElement"/>s returned by this method.</param> /// <param name="lineCap">The line cap of the <see cref="Line3DElement"/>s returned by this method.</param> /// <param name="lineDash">The line dash of the <see cref="Line3DElement"/>s returned by this method.</param> /// <param name="tag">A tag that will be applied to the <see cref="Line3DElement"/>s returned by this method.</param> /// <param name="zIndex">A z-index that will be applied to the <see cref="Line3DElement"/>s returned by this method.</param> /// <returns>A list of <see cref="Line3DElement"/>s that constitute the wireframe.</returns> public static List <Element3D> CreateWireframe(IEnumerable <Element3D> object3D, Colour colour, double thickness = 1, LineCaps lineCap = LineCaps.Butt, LineDash?lineDash = null, string tag = null, int zIndex = 0) { List <Element3D> tbr = new List <Element3D>(); List <Point3D[]> addedLines = new List <Point3D[]>(); void addLine(Point3D p1, Point3D p2) { for (int i = 0; i < addedLines.Count; i++) { if ((addedLines[i][0].Equals(p1, 1e-4) && addedLines[i][1].Equals(p2, 1e-4)) || (addedLines[i][0].Equals(p2, 1e-4) && addedLines[i][1].Equals(p1, 1e-4))) { return; } } tbr.Add(new Line3DElement(p1, p2) { Colour = colour, Thickness = thickness, LineCap = lineCap, LineDash = lineDash ?? LineDash.SolidLine, Tag = tag, ZIndex = zIndex }); addedLines.Add(new Point3D[] { p1, p2 }); } foreach (Element3D element in object3D) { if (element is Triangle3DElement triangle) { addLine(triangle.Point1, triangle.Point2); addLine(triangle.Point2, triangle.Point3); addLine(triangle.Point3, triangle.Point1); } } return(tbr); }