/// <summary> /// A LineDash defines a non-continuous line. /// </summary> /// <param name="dashstyle">This sets the style of this LineDash</param> /// <param name="dots">This is the number of dots in this LineDash</param> /// <param name="dotLen">This is the length of a dot</param> /// <param name="dashes">This is the number of dashes</param> /// <param name="dashLen">This is the length of a single dash</param> /// <param name="distance">This is the distance between the dots</param> virtual public void SetLineDash(tud.mci.tangram.util.DashStyle dashstyle, short dots, int dotLen, short dashes, int dashLen, int distance) { try { LineDash dash = new LineDash((unoidl.com.sun.star.drawing.DashStyle)((int)dashstyle), dots, dotLen, dashes, dashLen, distance); int count = this.ChildCount; if (count > 0) // group object { var children = GetChilderen(); for (int i = 0; i < children.Count; i++) { OoShapeObserver child = children.ElementAt(i); if (child != null) { child.SetProperty("LineDash", dash); child.SetLineDash(dashstyle, dots, dotLen, dashes, dashLen, distance); } } } SetProperty("LineDash", dash); } catch (System.Exception ex) { Logger.Instance.Log(LogPriority.DEBUG, this, "[ERROR] Can't set line dash: " + ex); } }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); var rectFactory = CreateRectFactory(CornerRadius); if (!IsHidden(FillColor)) { FillColor.SetFill(); rectFactory(Bounds).Fill(); } if (LineThickness > 0 && !IsHidden(StrokeColor)) { StrokeColor.SetStroke(); var halfLineThickness = LineThickness * 0.5f; var path = rectFactory(CGRect.Inflate(Bounds, -halfLineThickness, -halfLineThickness)); path.LineWidth = LineThickness; if (LineDash.Length > 0) // The API doesn't expect an empty line dash array (for some reason) { path.SetLineDash(LineDash.Select(w => w * LineThickness).ToArray(), 0); } path.Stroke(); } }
/** * <summary>Creates a reusable instance.</summary> */ public Border( Document context, double width, LineDash pattern ) : this(context, width, StyleEnum.Dashed, pattern) { }
private static Pen GetStroke( ContentScanner.GraphicsState state ) { Pen stroke = new Pen( state.StrokeColorSpace.GetPaint(state.StrokeColor), (float)state.LineWidth ); { LineCap lineCap = state.LineCap.ToGdi(); stroke.SetLineCap(lineCap, lineCap, lineCap.ToDashCap()); stroke.LineJoin = state.LineJoin.ToGdi(); stroke.MiterLimit = (float)state.MiterLimit; LineDash lineDash = state.LineDash; double[] dashArray = lineDash.DashArray; if (dashArray.Length > 0) { stroke.DashPattern = ConvertUtils.ToFloatArray(dashArray); stroke.DashOffset = (float)lineDash.DashPhase; } } return(stroke); }
private Border(Document context, double width, StyleEnum style, LineDash pattern) : base(context, new PdfDictionary(new PdfName[] { PdfName.Type }, new PdfDirectObject[] { PdfName.Border })) { Width = width; Style = style; Pattern = pattern; }
public SetLineDash( LineDash lineDash ) : base(OperatorKeyword, (PdfDirectObject)new PdfArray()) { Value = lineDash; }
public Border( Document context, float width, StyleEnum style, LineDash pattern ) : this(context) { Width = width; Style = style; Pattern = pattern; }
internal override void WriteChanges(Pen newPen, MemoryStream stream, Resources resources) { if (!_dashPattern.Equals(newPen.DashPattern)) { IPDFPageOperation operation = new LineDash(newPen.DashPattern); operation.WriteBytes(stream); } if (!_lineCap.Equals(newPen.LineCap)) { IPDFPageOperation operation = new LineCap(newPen.LineCap); operation.WriteBytes(stream); } if (!_lineJoin.Equals(newPen.LineJoin)) { IPDFPageOperation operation = new LineJoin(newPen.LineJoin); operation.WriteBytes(stream); } if (!_miterLimit.Equals(newPen.MiterLimit)) { IPDFPageOperation operation = new MiterLimit(newPen.MiterLimit); operation.WriteBytes(stream); } if (!_opacity.Equals(newPen.Opacity / 100)) { PDFDictionary dict = new PDFDictionary(); dict.AddItem("CA", new PDFNumber(newPen.Opacity / 100)); string name = resources.AddResources(ResourceType.ExtGState, dict); IPDFPageOperation operation = new GraphicsState(name); operation.WriteBytes(stream); } if (!_width.Equals(newPen.Width)) { IPDFPageOperation operation = new Linewidth(newPen.Width); operation.WriteBytes(stream); } if (newPen is SolidPen) { if (!_color.Equals((newPen as SolidPen).Color)) { if ((newPen as SolidPen)._color is ColorICC) { (newPen as SolidPen)._color.Colorspace.WriteColorSpaceForStroking(stream, resources); } newPen.WriteParameters(stream, resources); } } else { newPen.WriteParameters(stream, resources); } }
public SVGContext(double width, double height, bool textToPaths, Dictionary <string, string> linkDestinations) { this.linkDestinations = linkDestinations; this.Width = width; this.Height = height; currentPath = new SVGPathObject(); currentFigure = new SVGFigure(); StrokeStyle = Colour.FromRgba(0, 0, 0, 0); FillStyle = Colour.FromRgb(0, 0, 0); LineWidth = 1; LineCap = LineCaps.Butt; LineJoin = LineJoins.Miter; _lineDash = new LineDash(0, 0, 0); Font = new Font(new FontFamily(FontFamily.StandardFontFamilies.Helvetica), 12); TextBaseline = TextBaselines.Top; _transform = new double[3, 3]; _transform[0, 0] = 1; _transform[1, 1] = 1; _transform[2, 2] = 1; states = new Stack <double[, ]>(); clipPaths = new Stack <string>(); clipPaths.Push(null); _currClipPath = null; UsedFontFamilies = new Dictionary <string, FontFamily>(); UsedChars = new Dictionary <string, HashSet <char> >(); Document = new XmlDocument(); Document.InsertBefore(Document.CreateXmlDeclaration("1.0", "UTF-8", null), Document.DocumentElement); currentElement = Document.CreateElement(null, "svg", SVGNamespace); currentElement.SetAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"); currentElement.SetAttribute("viewBox", "0 0 " + width.ToString(System.Globalization.CultureInfo.InvariantCulture) + " " + height.ToString(System.Globalization.CultureInfo.InvariantCulture)); currentElement.SetAttribute("version", "1.1"); Document.AppendChild(currentElement); this.TextToPaths = textToPaths; }
private static SKPaint GetStroke(GraphicsState state) { var stroke = state.StrokeColorSpace.GetPaint(state.StrokeColor, state.StrokeAlpha); stroke.Style = SKPaintStyle.Stroke; stroke.StrokeWidth = (float)state.LineWidth; stroke.StrokeCap = state.LineCap.ToSkia(); stroke.StrokeJoin = state.LineJoin.ToSkia(); stroke.StrokeMiter = (float)state.MiterLimit; LineDash lineDash = state.LineDash; lineDash.Apply(stroke); return(stroke); }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); StrokeColor.SetStroke(); var path = new NSBezierPath(); path.MoveTo(Start); path.LineTo(End); path.LineWidth = LineThickness; if (LineDash.Length > 0) { path.SetLineDash(LineDash.Select(w => w * LineThickness).ToArray(), 0); } path.Stroke(); }
/// <summary> /// Gets a LineDash defines a non-continuous line. /// </summary> /// <param name="dashstyle">This sets the style of this LineDash</param> /// <param name="dots">This is the number of dots in this LineDash</param> /// <param name="dotLen">This is the length of a dot</param> /// <param name="dashes">This is the number of dashes</param> /// <param name="dashLen">This is the length of a single dash</param> /// <param name="distance">This is the distance between the dots</param> /// <returns>true and false</returns> virtual public bool GetLineDash(out tud.mci.tangram.util.DashStyle dashstyle, out short dots, out int dotLen, out short dashes, out int dashLen, out int distance) { dashstyle = tud.mci.tangram.util.DashStyle.RECT; dots = dashes = 0; dotLen = dashLen = distance = 0; var ld = GetProperty("LineDash"); if (ld != null && ld is LineDash) { LineDash linedash = ((LineDash)ld); dashstyle = (tud.mci.tangram.util.DashStyle)((int)linedash.Style); dots = linedash.Dots; dotLen = linedash.DotLen; dashes = linedash.Dashes; dashLen = linedash.DashLen; distance = linedash.Distance; return(true); } return(false); }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); FillColor.SetFill(); NSBezierPath.FromOvalInRect(Bounds).Fill(); if (LineThickness > 0) { StrokeColor.SetStroke(); var halfLineThickness = LineThickness * 0.5f; var path = NSBezierPath.FromOvalInRect(CGRect.Inflate(Bounds, -halfLineThickness, -halfLineThickness)); path.LineWidth = LineThickness; if (LineDash.Length > 0) // The API doesn't expect an empty line dash array (for some reason) { path.SetLineDash(LineDash.Select(w => w * LineThickness).ToArray(), 0); } path.Stroke(); } }
/// <summary> /// Gets the internal name of the LineStyle property of the shape. /// </summary> /// <returns></returns> virtual public string GetLineStyleName() { if (LineStyle.Equals(tud.mci.tangram.util.LineStyle.SOLID)) { return("solid"); } else if (LineStyle.Equals(tud.mci.tangram.util.LineStyle.DASH)) { LineDash lineDash = GetProperty("LineDash") as LineDash; if (lineDash != null) { if (lineDash.Dots == 0) { return("dashed_line"); } else if (lineDash.Dots == 1) { return("dotted_line"); } } } return(""); }
/** * <summary>Creates a non-reusable instance.</summary> */ public Border(double width, LineDash pattern) : this(null, width, pattern) { }
public SetLineDash(LineDash lineDash) : base(OperatorKeyword, (PdfDirectObject) new PdfArray()) { Value = lineDash; }
/// <summary> /// A LineDash defines a non-continuous line. /// </summary> /// <param name="dashstyle">This sets the style of this LineDash</param> /// <param name="dots">This is the number of dots in this LineDash</param> /// <param name="dotLen">This is the length of a dot</param> /// <param name="dashes">This is the number of dashes</param> /// <param name="dashLen">This is the length of a single dash</param> /// <param name="distance">This is the distance between the dots</param> public void SetLineDash(tud.mci.tangram.util.DashStyle dashstyle, short dots, int dotLen, short dashes, int dashLen, int distance) { try { LineDash dash = new LineDash((unoidl.com.sun.star.drawing.DashStyle)((int)dashstyle), dots, dotLen, dashes, dashLen, distance); int count = this.ChildCount; if (count > 0) // group object { var children = GetChilderen(); for (int i = 0; i < children.Count; i++) { OoShapeObserver child = children.ElementAt(i); if (child != null) { child.SetProperty("LineDash", dash); child.SetLineDash(dashstyle, dots, dotLen, dashes, dashLen, distance); } } } SetProperty("LineDash", dash); } catch (System.Exception ex) { Logger.Instance.Log(LogPriority.DEBUG, this, "[ERROR] Can't set line dash: " + ex); } }