Пример #1
0
        public void ConvertDashesToFloatArray_Should_Not_Throw()
        {
            var dashes = "0 A";
            var target = BaseStyle.ConvertDashesToFloatArray(dashes);

            Assert.Null(target);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public void ConvertDashesToFloatArray_Should_Return_Dashes_Float_Array()
        {
            var dashes   = "2 2 0 2 0 2";
            var expected = new float[] { 2.0f, 2.0f, 0.0f, 2.0f, 0.0f, 2.0f };

            var target = BaseStyle.ConvertDashesToFloatArray(dashes);

            Assert.Equal(expected, target);
        }
Пример #4
0
 private SKPaint ToSKPaintPen(BaseStyle style, Func <double, float> scale, double sourceDpi, double targetDpi)
 {
     return(new SKPaint()
     {
         IsAntialias = _isAntialias,
         IsStroke = true,
         StrokeWidth = scale(style.Thickness * targetDpi / sourceDpi),
         Color = ToSKColor(style.Stroke),
         StrokeCap = ToStrokeCap(style),
         PathEffect = style.Dashes != null?SKPathEffect.CreateDash(BaseStyle.ConvertDashesToFloatArray(style.Dashes), (float)style.DashOffset) : null
     });
 }