Ejemplo n.º 1
0
        private static AM.IPen ToPen(this Paint paint)
        {
            var brush    = ToBrush(paint.Shader);
            var lineCap  = paint.StrokeCap.ToPenLineCap();
            var lineJoin = paint.StrokeJoin.ToPenLineJoin();

            var dashStyle = default(AM.IDashStyle);

            if (paint.PathEffect is DashPathEffect dashPathEffect && dashPathEffect.Intervals != null)
            {
                var dashes = new List <double>();
                foreach (var interval in dashPathEffect.Intervals)
                {
                    dashes.Add(interval / paint.StrokeWidth);
                }
                var offset = dashPathEffect.Phase / paint.StrokeWidth;
                dashStyle = new AM.DashStyle(dashes, offset);
            }

            return(new AM.Pen()
            {
                Brush = brush,
                Thickness = paint.StrokeWidth,
                LineCap = lineCap,
                LineJoin = lineJoin,
                MiterLimit = paint.StrokeMiter,
                DashStyle = dashStyle
            });
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
        }