private AM.Pen ToPen(BaseStyle style, Func<double, float> scale) { var lineCap = default(AM.PenLineCap); var dashStyle = default(AM.DashStyle); switch (style.LineCap) { case LineCap.Flat: lineCap = AM.PenLineCap.Flat; break; case LineCap.Square: lineCap = AM.PenLineCap.Square; break; case LineCap.Round: lineCap = AM.PenLineCap.Round; break; } if (style.Dashes != null) { dashStyle = new AM.DashStyle( ShapeStyle.ConvertDashesToDoubleArray(style.Dashes), style.DashOffset); } var pen = new AM.Pen( ToBrush(style.Stroke), scale(style.Thickness / State.ZoomX), dashStyle, lineCap, lineCap, lineCap); return pen; }
private Pen ToPen(BaseStyle style, Func<double, float> scale) { var pen = new Pen(ToColor(style.Stroke), (float)(style.Thickness / State.ZoomX)); switch (style.LineCap) { case Core2D.Style.LineCap.Flat: pen.StartCap = System.Drawing.Drawing2D.LineCap.Flat; pen.EndCap = System.Drawing.Drawing2D.LineCap.Flat; pen.DashCap = System.Drawing.Drawing2D.DashCap.Flat; break; case Core2D.Style.LineCap.Square: pen.StartCap = System.Drawing.Drawing2D.LineCap.Square; pen.EndCap = System.Drawing.Drawing2D.LineCap.Square; pen.DashCap = System.Drawing.Drawing2D.DashCap.Flat; break; case Core2D.Style.LineCap.Round: pen.StartCap = System.Drawing.Drawing2D.LineCap.Round; pen.EndCap = System.Drawing.Drawing2D.LineCap.Round; pen.DashCap = System.Drawing.Drawing2D.DashCap.Round; break; } if (style.Dashes != null) { // TODO: Convert to correct dash values. pen.DashPattern = ShapeStyle.ConvertDashesToFloatArray(style.Dashes); } pen.DashOffset = (float)style.DashOffset; return pen; }
private static Pen CreatePen(BaseStyle style, double thickness) { var brush = CreateBrush(style.Stroke); var pen = new Pen(brush, thickness); switch (style.LineCap) { case LineCap.Flat: pen.StartLineCap = PenLineCap.Flat; pen.EndLineCap = PenLineCap.Flat; pen.DashCap = PenLineCap.Flat; break; case LineCap.Square: pen.StartLineCap = PenLineCap.Square; pen.EndLineCap = PenLineCap.Square; pen.DashCap = PenLineCap.Square; break; case LineCap.Round: pen.StartLineCap = PenLineCap.Round; pen.EndLineCap = PenLineCap.Round; pen.DashCap = PenLineCap.Round; break; } pen.DashStyle = new DashStyle( ShapeStyle.ConvertDashesToDoubleArray(style.Dashes), style.DashOffset); pen.DashStyle.Offset = style.DashOffset; pen.Freeze(); return pen; }
private SKPaint ToSKPaintPen(BaseStyle style, Func<double, float> scale, double sourceDpi, double targetDpi) { var paint = new SKPaint(); paint.IsAntialias = _isAntialias; paint.IsStroke = true; paint.StrokeWidth = scale(style.Thickness * targetDpi / sourceDpi); paint.Color = ToSKColor(style.Stroke); switch (style.LineCap) { case LineCap.Flat: paint.StrokeCap = SKStrokeCap.Butt; break; case LineCap.Square: paint.StrokeCap = SKStrokeCap.Square; break; case LineCap.Round: paint.StrokeCap = SKStrokeCap.Round; break; } if (style.Dashes != null) { paint.PathEffect = SKPathEffect.CreateDash( BaseStyle.ConvertDashesToFloatArray(style.Dashes), (float)style.DashOffset); } return paint; }