Exemplo n.º 1
0
 protected virtual void onPenLineJoinChanged(PenLineJoin join)
 {
     if (penLineJoinChanged != null)
     {
         penLineJoinChanged(join);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///     Returns whether or not an enumeration instance a valid value.
        ///     This method is designed to be used with ValidateValueCallback, and thus
        ///     matches it's prototype.
        /// </summary>
        /// <param name="valueObject">
        ///     Enumeration value to validate.
        /// </param>
        /// <returns> 'true' if the enumeration contains a valid value, 'false' otherwise. </returns>
        public static bool IsPenLineJoinValid(object valueObject)
        {
            PenLineJoin value = (PenLineJoin)valueObject;

            return((value == PenLineJoin.Miter) ||
                   (value == PenLineJoin.Bevel) ||
                   (value == PenLineJoin.Round));
        }
Exemplo n.º 3
0
        private MIL_PEN_JOIN GetInternalJoinType(PenLineJoin join)
        {
            Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Miter == MIL_PEN_JOIN.MilPenJoinMiter);
            Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Bevel == MIL_PEN_JOIN.MilPenJoinBevel);
            Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Round == MIL_PEN_JOIN.MilPenJoinRound);

            return((MIL_PEN_JOIN)join);
        }
Exemplo n.º 4
0
        private static void OnStrokeLineJoinChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            LineIndicatorBase indicator = d as LineIndicatorBase;
            PenLineJoin       newValue  = (PenLineJoin)e.NewValue;

            indicator.renderer.strokeShape.StrokeLineJoin = newValue;

            indicator.OnStrokeLineJoinChanged(newValue);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pen"/> class.
 /// </summary>
 /// <param name="color">The stroke color.</param>
 /// <param name="thickness">The stroke thickness.</param>
 /// <param name="dashStyle">The dash style.</param>
 /// <param name="lineCap">Specifies the type of graphic shape to use on both ends of a line.</param>
 /// <param name="lineJoin">The line join.</param>
 /// <param name="miterLimit">The miter limit.</param>
 public Pen(
     uint color,
     double thickness     = 1.0,
     DashStyle dashStyle  = null,
     PenLineCap lineCap   = PenLineCap.Flat,
     PenLineJoin lineJoin = PenLineJoin.Miter,
     double miterLimit    = 10.0) : this(new SolidColorBrush(color), thickness, dashStyle, lineCap, lineJoin, miterLimit)
 {
 }
Exemplo n.º 6
0
 public static T Shape <T>(this T shape, Stretch aspect, Brush fill, Brush stroke,
                           DoubleCollection doubleCollection, double offSet,
                           PenLineCap penLineCap, PenLineJoin penLineJoin, double strokeThickness) where T : Shape
 {
     return(shape.Aspect(aspect).Fill(fill)
            .Stroke(stroke).StrokeDashArray(doubleCollection)
            .StrokeDashOffset(offSet).StrokeLineCap(penLineCap)
            .StrokeLineJoin(penLineJoin).StrokeThickness(strokeThickness));
 }
Exemplo n.º 7
0
 public StrokeStyle()
 {
     Thickness    = 1;
     StrokeColor  = Brushes.Black;
     DashStyle    = null;
     DashCap      = PenLineCap.Flat;
     StartLineCap = PenLineCap.Flat;
     EndLineCap   = PenLineCap.Flat;
     LineJoin     = PenLineJoin.Miter;
 }
Exemplo n.º 8
0
        public static d2.LineJoin ToGdiPlus(this PenLineJoin me)
        {
            switch (me)
            {
            case PenLineJoin.Bevel: return(d2.LineJoin.Bevel);

            case PenLineJoin.Round: return(d2.LineJoin.Round);
            }
            return(d2.LineJoin.Miter);
        }
Exemplo n.º 9
0
        /// <inheritdoc/>
        public void DrawPolygon(IList <Point> points, Color fillColor, Color strokeColor,
                                double thickness, PenLineJoin lineJoin, ICollection <double> dashArray, double dashOffset, bool aliased, bool isHitTestVisible)
        {
            var polygon = Create <Polygon>(isHitTestVisible);

            polygon.Fill = GetBrush(fillColor);
            SetStroke(polygon, strokeColor, thickness, lineJoin, dashArray, dashOffset, false);

            polygon.Points = ToPointCollection(points, aliased);
        }
Exemplo n.º 10
0
 public StrokeStyle(Brush strokeColor, double thickness, PenLineCap startLineCap, PenLineCap endLineCap,
                    PenLineJoin lineJoin)
     : this()
 {
     StrokeColor  = strokeColor;
     Thickness    = thickness;
     StartLineCap = startLineCap;
     EndLineCap   = endLineCap;
     LineJoin     = lineJoin;
 }
Exemplo n.º 11
0
        /// <inheritdoc/>
        public void DrawLine(Point p1, Point p2, Color strokeColor,
                             double thickness, PenLineJoin lineJoin, ICollection <double> dashArray, double dashOffset, bool aliased, bool isHitTestVisible)
        {
            var line = Create <Line>(isHitTestVisible);

            SetStroke(line, strokeColor, thickness, lineJoin, dashArray, dashOffset, aliased);
            line.X1 = p1.X;
            line.Y1 = p1.Y;
            line.X2 = p2.X;
            line.Y2 = p2.Y;
        }
Exemplo n.º 12
0
 public CanvasStyle(CanvasPath path, Brush fill, Brush stroke, double strokeWidth, PenLineJoin strokeLineJoin,
                    PenLineCap lineCap, float strokeMiterLimit, double globalAlpha)
 {
     _path = path;
     _fill = fill;
     _stroke = stroke;
     _strokeWidth = strokeWidth;
     _strokeLineJoin = strokeLineJoin;
     _lineCap = lineCap;
     _globalAlpha = globalAlpha;
     _strokeMiterLimit = strokeMiterLimit;
 }
Exemplo n.º 13
0
 public StrokeStyle(Brush strokeColor, double thickness, PenLineCap startLineCap, PenLineCap endLineCap,
                    PenLineJoin lineJoin, DashStyle dashStyle, PenLineCap dashCap)
     : this()
 {
     StrokeColor  = strokeColor;
     Thickness    = thickness;
     StartLineCap = startLineCap;
     EndLineCap   = endLineCap;
     LineJoin     = lineJoin;
     DashStyle    = dashStyle;
     DashCap      = dashCap;
 }
Exemplo n.º 14
0
        void RenderCore(DrawingContext context, IBrush background, IBrush borderBrush, BoxShadows boxShadows,
                        double borderDashOffset, PenLineCap borderLineCap, PenLineJoin borderLineJoin,
                        AvaloniaList <double> borderDashArray)
        {
            if (_useComplexRendering)
            {
                var backgroundGeometry = _backgroundGeometryCache;
                if (backgroundGeometry != null)
                {
                    context.DrawGeometry(background, null, backgroundGeometry);
                }

                var borderGeometry = _borderGeometryCache;
                if (borderGeometry != null)
                {
                    context.DrawGeometry(borderBrush, null, borderGeometry);
                }
            }
            else
            {
                var  borderThickness = _borderThickness.Top;
                IPen pen             = null;


                ImmutableDashStyle?dashStyle = null;

                if (borderDashArray != null && borderDashArray.Count > 0)
                {
                    dashStyle = new ImmutableDashStyle(borderDashArray, borderDashOffset);
                }

                if (borderBrush != null && borderThickness > 0)
                {
                    pen = new ImmutablePen(
                        borderBrush.ToImmutable(),
                        borderThickness,
                        dashStyle,
                        borderLineCap,
                        borderLineJoin);
                }


                var rect = new Rect(_size);
                if (!MathUtilities.IsZero(borderThickness))
                {
                    rect = rect.Deflate(borderThickness * 0.5);
                }
                var rrect = new RoundedRect(rect, _cornerRadius.TopLeft, _cornerRadius.TopRight,
                                            _cornerRadius.BottomRight, _cornerRadius.BottomLeft);

                context.PlatformImpl.DrawRectangle(background, pen, rrect, boxShadows);
            }
        }
Exemplo n.º 15
0
        /// <inheritdoc/>
        public void DrawRectangle(Rect rect, Color fillColor, Color strokeColor,
                                  double thickness, PenLineJoin lineJoin, ICollection <double> dashArray, double dashOffset, bool isHitTestVisible)
        {
            var rectangle = Create <Rectangle>(isHitTestVisible, rect.Left, rect.Top);

            rectangle.Fill = GetBrush(fillColor);
            SetStroke(rectangle, strokeColor, thickness, lineJoin, dashArray, dashOffset, false);

            rectangle.Height = rect.Height;
            rectangle.Width  = rect.Width;
            Canvas.SetLeft(rectangle, rect.Left);
            Canvas.SetTop(rectangle, rect.Top);
        }
Exemplo n.º 16
0
        /// <inheritdoc/>
        public void DrawPolyline(IList <Point> points, Color strokeColor,
                                 double thickness, PenLineJoin lineJoin, ICollection <double> dashArray, double dashOffset, bool aliased, bool isHitTestVisible)
        {
            if (thickness < BalancedLineDrawingThicknessLimit)
            {
                DrawPolylineBalanced(points, strokeColor, thickness, lineJoin, dashArray, aliased, isHitTestVisible);
            }

            var polyline = Create <Polyline>(isHitTestVisible);

            SetStroke(polyline, strokeColor, thickness, lineJoin, dashArray, dashOffset, aliased);
            polyline.Points = ToPointCollection(points, aliased);
        }
Exemplo n.º 17
0
 public PenX3D WithLineJoin(PenLineJoin lineJoin)
 {
     if (!(lineJoin == _lineJoin))
     {
         var result = (PenX3D)MemberwiseClone();
         result._lineJoin = lineJoin;
         return(result);
     }
     else
     {
         return(this);
     }
 }
Exemplo n.º 18
0
 public static Pen GetPen(double thickness, PenLineJoin lineJoin = PenLineJoin.Bevel)
 {
     if (lineJoin == PenLineJoin.Bevel)
     {
         return(GetPen(bevelLock, bevelPens, thickness, lineJoin));
     }
     else if (lineJoin == PenLineJoin.Miter)
     {
         return(GetPen(miterLock, miterPens, thickness, lineJoin));
     }
     else
     {
         return(GetPen(roundLock, roundPens, thickness, lineJoin));
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pen"/> class.
 /// </summary>
 /// <param name="brush">The brush used to draw.</param>
 /// <param name="thickness">The stroke thickness.</param>
 /// <param name="dashStyle">The dash style.</param>
 /// <param name="lineCap">The line cap.</param>
 /// <param name="lineJoin">The line join.</param>
 /// <param name="miterLimit">The miter limit.</param>
 public Pen(
     IBrush brush,
     double thickness     = 1.0,
     DashStyle dashStyle  = null,
     PenLineCap lineCap   = PenLineCap.Flat,
     PenLineJoin lineJoin = PenLineJoin.Miter,
     double miterLimit    = 10.0)
 {
     Brush      = brush;
     Thickness  = thickness;
     LineCap    = lineCap;
     LineJoin   = lineJoin;
     MiterLimit = miterLimit;
     DashStyle  = dashStyle;
 }
Exemplo n.º 20
0
 public static Pen GetPen(double thickness, PenLineJoin lineJoin = PenLineJoin.Bevel)
 {
     if (lineJoin == PenLineJoin.Bevel)
     {
         return GetPen(bevelLock, bevelPens, thickness, lineJoin);
     }
     else if (lineJoin == PenLineJoin.Miter)
     {
         return GetPen(miterLock, miterPens, thickness, lineJoin);
     }
     else
     {
         return GetPen(roundLock, roundPens, thickness, lineJoin);
     }
 }
Exemplo n.º 21
0
 static Pen GetPen(object lockObj, Dictionary<double, Pen> penDictionary, double thickness, PenLineJoin lineJoin, Brush brush=null)
 {
     lock (lockObj)
     {
         thickness = Math.Round(thickness, 1);
         if (!penDictionary.ContainsKey(thickness))
         {
             Pen pen = new Pen(brush ?? Brushes.Black, thickness);
             pen.LineJoin = lineJoin;
             pen.Freeze();
             penDictionary.Add(thickness, pen);
         }
         return penDictionary[thickness];
     }
 }
Exemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pen"/> class.
 /// </summary>
 /// <param name="color">The stroke color.</param>
 /// <param name="thickness">The stroke thickness.</param>
 public Pen(
     uint color,
     double thickness      = 1.0,
     DashStyle dashStyle   = null, PenLineCap dashCap = PenLineCap.Flat, PenLineCap startLineCap          = PenLineCap.Flat,
     PenLineCap endLineCap = PenLineCap.Flat, PenLineJoin lineJoin = PenLineJoin.Miter, double miterLimit = 10.0)
 {
     Brush        = new SolidColorBrush(color);
     Thickness    = thickness;
     StartLineCap = startLineCap;
     EndLineCap   = endLineCap;
     LineJoin     = lineJoin;
     MiterLimit   = miterLimit;
     DashStyle    = dashStyle;
     DashCap      = dashCap;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pen"/> class.
 /// </summary>
 /// <param name="brush">The brush used to draw.</param>
 /// <param name="thickness">The stroke thickness.</param>
 public Pen(
     Brush brush,
     double thickness      = 1.0,
     DashStyle dashStyle   = null, PenLineCap dashCap = PenLineCap.Flat, PenLineCap startLineCap          = PenLineCap.Flat,
     PenLineCap endLineCap = PenLineCap.Flat, PenLineJoin lineJoin = PenLineJoin.Miter, double miterLimit = 10.0)
 {
     Brush        = brush;
     Thickness    = thickness;
     StartLineCap = startLineCap;
     EndLineCap   = endLineCap;
     LineJoin     = lineJoin;
     MiterLimit   = miterLimit;
     DashStyle    = dashStyle;
     DashCap      = dashCap;
 }
Exemplo n.º 24
0
        public static void DrawLine(this DrawingContext drawingContext, Point[] points, double width, Color color, PenLineCap startCap,
                                    PenLineCap endCap, PenLineJoin lineJoin, DashStyle dashStyle)
        {
            var pen = new Pen(new SolidColorBrush(color), width)
            {
                DashStyle    = dashStyle,
                LineJoin     = lineJoin,
                StartLineCap = PenLineCap.Round,
                EndLineCap   = PenLineCap.Round
            };

            for (var i = 1; i < points.Length; i++)
            {
                drawingContext.DrawLine(pen, points[i - 1], points[i]);
            }
        }
Exemplo n.º 25
0
 public void Render(DrawingContext context,
                    Size finalSize, Thickness borderThickness, CornerRadius cornerRadius,
                    IBrush background, IBrush borderBrush, BoxShadows boxShadows, double borderDashOffset = 0,
                    PenLineCap borderLineCap = PenLineCap.Flat, PenLineJoin borderLineJoin = PenLineJoin.Miter,
                    AvaloniaList <double> borderDashArray = null)
 {
     if (_size != finalSize ||
         _borderThickness != borderThickness ||
         _cornerRadius != cornerRadius ||
         !_initialized)
     {
         Update(finalSize, borderThickness, cornerRadius);
     }
     RenderCore(context, background, borderBrush, boxShadows, borderDashOffset, borderLineCap, borderLineJoin,
                borderDashArray);
 }
Exemplo n.º 26
0
        void SetStrokeLineJoin()
        {
            PenLineJoin winLineJoin = Element.StrokeLineJoin;
            CGLineJoin  iosLineJoin = CGLineJoin.Miter;

            switch (winLineJoin)
            {
            case PenLineJoin.Miter: iosLineJoin = CGLineJoin.Miter; break;

            case PenLineJoin.Bevel: iosLineJoin = CGLineJoin.Bevel; break;

            case PenLineJoin.Round: iosLineJoin = CGLineJoin.Round; break;
            }

            Control.DrawingLayer.SetStrokeLineJoin(iosLineJoin);
        }
Exemplo n.º 27
0
        /// <inheritdoc/>
        public void DrawEllipse(Point point, Size size, Color fillColor, Color strokeColor,
                                double thickness, PenLineJoin lineJoin, ICollection <double> dashArray, double dashOffset, bool isHitTestVisible)
        {
            point.Offset(-size.Width / 2, -size.Height / 2);
            var rect = new Rect(point, size);

            var ellipse = Create <Ellipse>(isHitTestVisible, rect.Left, rect.Top);

            ellipse.Fill = GetBrush(fillColor);
            SetStroke(ellipse, strokeColor, thickness, lineJoin, dashArray, dashOffset, false);

            ellipse.Height = rect.Height;
            ellipse.Width  = rect.Width;
            Canvas.SetLeft(ellipse, rect.Left);
            Canvas.SetTop(ellipse, rect.Top);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Pen"/> class.
        /// </summary>
        /// <param name="brush">The brush used to draw.</param>
        /// <param name="thickness">The stroke thickness.</param>
        /// <param name="dashStyle">The dash style.</param>
        /// <param name="lineCap">The line cap.</param>
        /// <param name="lineJoin">The line join.</param>
        /// <param name="miterLimit">The miter limit.</param>
        public ImmutablePen(
            IBrush brush,
            double thickness             = 1.0,
            ImmutableDashStyle dashStyle = null,
            PenLineCap lineCap           = PenLineCap.Flat,
            PenLineJoin lineJoin         = PenLineJoin.Miter,
            double miterLimit            = 10.0)
        {
            Debug.Assert(!(brush is IMutableBrush));

            Brush      = brush;
            Thickness  = thickness;
            LineCap    = lineCap;
            LineJoin   = lineJoin;
            MiterLimit = miterLimit;
            DashStyle  = dashStyle;
        }
        public static SKStrokeJoin ToSkia(this PenLineJoin penLinejoin)
        {
            switch (penLinejoin)
            {
            case PenLineJoin.Miter:
                return(SKStrokeJoin.Mitter);

            case PenLineJoin.Bevel:
                return(SKStrokeJoin.Bevel);

            case PenLineJoin.Round:
                return(SKStrokeJoin.Round);

            default:
                throw new ArgumentOutOfRangeException(nameof(penLinejoin), penLinejoin, null);
            }
        }
Exemplo n.º 30
0
        public static sd.LineJoin ToDx(this PenLineJoin lineJoin)
        {
            switch (lineJoin)
            {
            case PenLineJoin.Miter:
                return(sd.LineJoin.MiterOrBevel);

            case PenLineJoin.Bevel:
                return(sd.LineJoin.Bevel);

            case PenLineJoin.Round:
                return(sd.LineJoin.Round);

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 31
0
        private void SetStroke([NotNull] Shape shape, Color color, double thickness, PenLineJoin lineJoin, ICollection <double> dashArray, double dashOffset, bool aliased)
        {
            shape.Stroke          = GetBrush(color);
            shape.StrokeThickness = thickness;
            shape.StrokeLineJoin  = lineJoin;
            if (dashArray != null)
            {
                shape.StrokeDashArray  = new DoubleCollection(dashArray);
                shape.StrokeDashOffset = dashOffset;
            }

            if (aliased)
            {
                shape.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
                shape.SnapsToDevicePixels = true;
            }
        }
Exemplo n.º 32
0
        public static ag.Paint.Join ToAndroid(this PenLineJoin value)
        {
            switch (value)
            {
            case PenLineJoin.Miter:
                return(ag.Paint.Join.Miter);

            case PenLineJoin.Bevel:
                return(ag.Paint.Join.Bevel);

            case PenLineJoin.Round:
                return(ag.Paint.Join.Round);

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 33
0
        public static swm.PenLineJoin ToWpf(this PenLineJoin value)
        {
            switch (value)
            {
            case PenLineJoin.Miter:
                return(swm.PenLineJoin.Miter);

            case PenLineJoin.Bevel:
                return(swm.PenLineJoin.Bevel);

            case PenLineJoin.Round:
                return(swm.PenLineJoin.Round);

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pen"/> class.
 /// </summary>
 /// <param name="color">The stroke color.</param>
 /// <param name="thickness">The stroke thickness.</param>
 /// <param name="dashStyle">The dash style.</param>
 /// <param name="dashCap">The dash cap.</param>
 /// <param name="startLineCap">The start line cap.</param>
 /// <param name="endLineCap">The end line cap.</param>
 /// <param name="lineJoin">The line join.</param>
 /// <param name="miterLimit">The miter limit.</param>
 public Pen(
     uint color, 
     double thickness = 1.0,
     DashStyle dashStyle = null, 
     PenLineCap dashCap = PenLineCap.Flat, 
     PenLineCap startLineCap = PenLineCap.Flat,
     PenLineCap endLineCap = PenLineCap.Flat, 
     PenLineJoin lineJoin = PenLineJoin.Miter, 
     double miterLimit = 10.0)
 {
     Brush = new SolidColorBrush(color);
     Thickness = thickness;
     StartLineCap = startLineCap;
     EndLineCap = endLineCap;
     LineJoin = lineJoin;
     MiterLimit = miterLimit;
     DashStyle = dashStyle;
     DashCap = dashCap;
 }
Exemplo n.º 35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pen"/> class.
 /// </summary>
 /// <param name="brush">The brush used to draw.</param>
 /// <param name="thickness">The stroke thickness.</param>
 /// <param name="dashStyle">The dash style.</param>
 /// <param name="dashCap">The dash cap.</param>
 /// <param name="startLineCap">The start line cap.</param>
 /// <param name="endLineCap">The end line cap.</param>
 /// <param name="lineJoin">The line join.</param>
 /// <param name="miterLimit">The miter limit.</param>
 public Pen(
     Brush brush, 
     double thickness = 1.0,
     DashStyle dashStyle = null, 
     PenLineCap dashCap = PenLineCap.Flat, 
     PenLineCap startLineCap = PenLineCap.Flat, 
     PenLineCap endLineCap = PenLineCap.Flat, 
     PenLineJoin lineJoin = PenLineJoin.Miter, 
     double miterLimit = 10.0)
 {
     Brush = brush;
     Thickness = thickness;
     DashCap = dashCap;
     StartLineCap = startLineCap;
     EndLineCap = endLineCap;
     LineJoin = lineJoin;
     MiterLimit = miterLimit;
     DashStyle = dashStyle;
 }
Exemplo n.º 36
0
        /// <summary>
        /// Pen - Initializes the brush from the parameters.
        /// </summary>
        /// <param name="brush"> The Pen's Brush. </param>
        /// <param name="thickness"> The Pen's thickness. </param>
        /// <param name="startLineCap"> The PenLineCap which applies to the start of the stroke. </param>
        /// <param name="endLineCap"> The PenLineCap which applies to the end of the stroke. </param>
        /// <param name="dashCap"> The PenDashCap which applies to the ends of each dash. </param>
        /// <param name="lineJoin"> The PenLineJoin. </param>
        /// <param name="miterLimit"> The miter limit. </param>
        /// <param name="dashStyle"> The dash style. </param>
        internal Pen(
            Brush brush,
            double thickness,
            PenLineCap startLineCap,
            PenLineCap endLineCap,
            PenLineCap dashCap,
            PenLineJoin lineJoin,
            double miterLimit,
            DashStyle dashStyle)
        {
            Thickness = thickness;
            StartLineCap = startLineCap;
            EndLineCap = endLineCap;
            DashCap = dashCap;
            LineJoin = lineJoin;
            MiterLimit = miterLimit;

            Brush = brush;
            DashStyle = dashStyle;
        }
Exemplo n.º 37
0
		public void SetLineJoin(Pen widget, PenLineJoin lineJoin)
		{
			throw new NotImplementedException();
		}
Exemplo n.º 38
0
 public StrokeStyle(Brush strokeColor, double thickness, PenLineCap startLineCap, PenLineCap endLineCap,
     PenLineJoin lineJoin, DashStyle dashStyle, PenLineCap dashCap)
     : this()
 {
     StrokeColor = strokeColor;
     Thickness = thickness;
     StartLineCap = startLineCap;
     EndLineCap = endLineCap;
     LineJoin = lineJoin;
     DashStyle = dashStyle;
     DashCap = dashCap;
 }
Exemplo n.º 39
0
        private MIL_PEN_JOIN GetInternalJoinType(PenLineJoin join)
        {
            Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Miter == MIL_PEN_JOIN.MilPenJoinMiter);
            Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Bevel == MIL_PEN_JOIN.MilPenJoinBevel);
            Debug.Assert((MIL_PEN_JOIN)PenLineJoin.Round == MIL_PEN_JOIN.MilPenJoinRound);

            return (MIL_PEN_JOIN)join;
        }
Exemplo n.º 40
0
 public void DrawPolygons(IList<IList<Point>> polygons, Color fill, Color stroke, double thickness = 1, double[] dashArray = null, PenLineJoin lineJoin = PenLineJoin.Miter, bool aliased = false)
 {
     foreach (var p in polygons)
         this.DrawPolygon(p, fill, stroke, thickness, dashArray, lineJoin, aliased);
 }
Exemplo n.º 41
0
		public void SetLineJoin(Pen widget, PenLineJoin lineJoin)
		{
			widget.ToPenData().LineJoin = lineJoin;
		}
Exemplo n.º 42
0
		public PenX3D WithLineJoin(PenLineJoin lineJoin)
		{
			if (!(lineJoin == _lineJoin))
			{
				var result = (PenX3D)this.MemberwiseClone();
				result._lineJoin = lineJoin;
				return result;
			}
			else
			{
				return this;
			}
		}
 public static void DrawCircles(this IDrawingContext renderer, IList<Point> points, double radius, Color fillColor, Color strokeColor,
     double thickness = 1.0, PenLineJoin lineJoin = PenLineJoin.Miter, ICollection<double> dashArray = null, double dashOffset = 0, bool isHitTestVisible = false)
 {
     renderer.DrawEllipses(points, radius, radius, fillColor, strokeColor, thickness, lineJoin, dashArray, dashOffset, isHitTestVisible);
 }
Exemplo n.º 44
0
 public StrokeStyle(Brush strokeColor, double thickness, PenLineJoin lineJoin)
     : this()
 {
     StrokeColor = strokeColor;
     Thickness = thickness;
     LineJoin = lineJoin;
 }
Exemplo n.º 45
0
		public void SetLineJoin (Pen widget, PenLineJoin lineJoin)
		{
			((swm.Pen)widget.ControlObject).LineJoin = lineJoin.ToWpf ();
		}
Exemplo n.º 46
0
		public void SetLineJoin(Pen widget, PenLineJoin lineJoin)
		{
			widget.ToAndroid().StrokeJoin = lineJoin.ToAndroid();
		}
Exemplo n.º 47
0
		/// <summary>
		/// Initialization that is needed only once per straigth line (not once per dash).
		/// </summary>
		/// <param name="crossSection">The cross section of the pen that is used to draw the line.</param>
		/// <param name="thickness1">Thickness1 of the pen.</param>
		/// <param name="thickness2">Thickness2 of the pen.</param>
		/// <param name="lineJoin">The LineJoin property of the pen.</param>
		/// <param name="miterLimit">The MiterLimit property of the pen.</param>
		/// <param name="startCap">The start cap to be used for this polyline segment.</param>
		/// <param name="endCap">The end cap to be used for this polyline segment.</param>
		public void Initialize(
		ICrossSectionOfLine crossSection,
		double thickness1,
		double thickness2,
		PenLineJoin lineJoin,
		double miterLimit,
		ILineCap startCap,
		ILineCap endCap)
		{
			this._crossSection = crossSection;
			this._crossSectionVertexCount = crossSection.NumberOfVertices;
			this._crossSectionNormalCount = crossSection.NumberOfNormals;
			this._crossSectionMaximalDistanceFromCenter = _crossSection.GetMaximalDistanceFromCenter();
			this._crossSectionPartsTriangleIndices = new Dictionary<Tuple<int, int>, int[]>();
			this._lineJoin = lineJoin;
			this._miterLimit = miterLimit;
			this._miterLimitDotThreshold = Math.Cos(Math.PI - 2 * Math.Asin(1 / miterLimit));

			this._dashStartCap = startCap;
			this._dashStartCapBaseInsetAbsolute = null == _dashStartCap ? 0 : _dashStartCap.GetAbsoluteBaseInset(thickness1, thickness2);
			this._dashEndCap = endCap;
			this._dashEndCapBaseInsetAbsolute = null == _dashEndCap ? 0 : _dashEndCap.GetAbsoluteBaseInset(thickness1, thickness2);

			_positionsTransformedStartCurrent = new PointD3D[_crossSectionVertexCount];
			_positionsTransformedEndCurrent = new PointD3D[_crossSectionVertexCount];
			_positionsTransformedStartNext = new PointD3D[_crossSectionVertexCount];
			_normalsTransformedCurrent = new VectorD3D[_crossSectionNormalCount];
			_normalsTransformedNext = new VectorD3D[_crossSectionNormalCount];
			_crossSectionRotatedVertices = new VectorD2D[_crossSectionVertexCount];
			_startCapCOS = new PolylinePointD3DAsClass();
			_endCapCOS = new PolylinePointD3DAsClass();
		}
Exemplo n.º 48
0
		public void SetLineJoin (Pen widget, PenLineJoin lineJoin)
		{
			((PenObject)widget.ControlObject).LineJoin = lineJoin.ToCairo ();
		}
Exemplo n.º 49
0
 public StrokeStyle(Brush strokeColor, double thickness, PenLineCap startLineCap, PenLineCap endLineCap,
     PenLineJoin lineJoin)
     : this()
 {
     StrokeColor = strokeColor;
     Thickness = thickness;
     StartLineCap = startLineCap;
     EndLineCap = endLineCap;
     LineJoin = lineJoin;
 }
Exemplo n.º 50
0
    /// <summary>
    /// Converts the graphics path to an array of vertices using TriangleList.
    /// </summary>
    /// <param name="points">The points of the line.</param>
    /// <param name="thickness">The thickness of the line.</param>
    /// <param name="close">True if we should connect the first and last point.</param>
    /// <param name="zCoord">Z coordinate of the returned vertices.</param>
    /// <param name="lineJoin">The PenLineJoin to use.</param>
    /// <param name="verts">The generated verts.</param>
    public static void TriangulateStroke_TriangleList(PointF[] points, float thickness, bool close, float zCoord, PenLineJoin lineJoin, out PositionColoredTextured[] verts)
    {
      verts = null;
      PointF[] pathPoints = AdjustPoints(points);

      if (pathPoints.Length <= 0)
        return;

      int pointCount;
      if (close)
        pointCount = pathPoints.Length;
      else
        pointCount = pathPoints.Length - 1;

      int pointsLength = pathPoints.Length;
      List<PositionColoredTextured> vertList = new List<PositionColoredTextured>();

      PointF[] lastLine = new PointF[] { PointF.Empty, PointF.Empty };
      if (close)
        GetLastLine(pathPoints, out lastLine);

      for (int i = 0; i < pointCount; i++)
      {
        PointF currentPoint = pathPoints[i];
        PointF nextPoint = GetNextPoint(pathPoints, i, pointsLength);

        PointF movedCurrent = PointF.Empty;
        PointF movedNext = PointF.Empty;

        MoveVector(currentPoint, nextPoint, thickness, ref movedCurrent, ref movedNext);

        if (lastLine[0] != PointF.Empty && lastLine[1] != PointF.Empty)
        {
          // We move the original line by the needed thickness.
          PointF movedLast0 = PointF.Empty;
          PointF movedLast1 = PointF.Empty;
          MoveVector(lastLine[0], lastLine[1], thickness, ref movedLast0, ref movedLast1);

          // StrokeLineJoin implementation
          switch (lineJoin)
          {
            case PenLineJoin.Round:
            // We fallback to the Miter because we don't support the Round line join yet.
            case PenLineJoin.Miter:
              // We need to calculate the intersection of the 2 moved lines (Line A: movedCurrent/movedNext and Line B: movedLast0/movedLast1)
              PointF intersection;
              if (LineIntersect(movedCurrent, movedNext, movedLast0, movedLast1, out intersection))
              {
                vertList.Add(new PositionColoredTextured { Position = new Vector3(currentPoint.X, currentPoint.Y, zCoord) });
                vertList.Add(new PositionColoredTextured { Position = new Vector3(movedCurrent.X, movedCurrent.Y, zCoord) });
                vertList.Add(new PositionColoredTextured { Position = new Vector3(intersection.X, intersection.Y, zCoord) });

                vertList.Add(new PositionColoredTextured { Position = new Vector3(currentPoint.X, currentPoint.Y, zCoord) });
                vertList.Add(new PositionColoredTextured { Position = new Vector3(movedLast1.X, movedLast1.Y, zCoord) });
                vertList.Add(new PositionColoredTextured { Position = new Vector3(intersection.X, intersection.Y, zCoord) });
              }
              break;
            case PenLineJoin.Bevel:
              // This is currently not the exact WPF "Bevel" implementation, we only insert a simple triangle between the line ends.
              vertList.Add(new PositionColoredTextured { Position = new Vector3(currentPoint.X, currentPoint.Y, zCoord) });
              vertList.Add(new PositionColoredTextured { Position = new Vector3(movedCurrent.X, movedCurrent.Y, zCoord) });
              vertList.Add(new PositionColoredTextured { Position = new Vector3(movedLast1.X, movedLast1.Y, zCoord) });
              break;
          }
        }

        vertList.Add(new PositionColoredTextured { Position = new Vector3(currentPoint.X, currentPoint.Y, zCoord) });
        vertList.Add(new PositionColoredTextured { Position = new Vector3(nextPoint.X, nextPoint.Y, zCoord) });
        vertList.Add(new PositionColoredTextured { Position = new Vector3(movedCurrent.X, movedCurrent.Y, zCoord) });

        vertList.Add(new PositionColoredTextured { Position = new Vector3(nextPoint.X, nextPoint.Y, zCoord) });
        vertList.Add(new PositionColoredTextured { Position = new Vector3(movedNext.X, movedNext.Y, zCoord) });
        vertList.Add(new PositionColoredTextured { Position = new Vector3(movedCurrent.X, movedCurrent.Y, zCoord) });

        lastLine = new PointF[] { currentPoint, nextPoint };
      }
      verts = vertList.ToArray();
    }
Exemplo n.º 51
0
        public void DrawLine(IList<Point> points, Color stroke, double thickness = 1, double[] dashArray = null, PenLineJoin lineJoin = PenLineJoin.Miter, bool aliased = false)
        {
            using (var paint = new Paint())
            {
                paint.StrokeWidth = (float)thickness;
                paint.Color = stroke;
                paint.AntiAlias = !aliased;
                var pts = new float[(points.Count - 1) * 4];
                int j = 0;
                for (int i = 0; i + 1 < points.Count; i++)
                {
                    pts[j++] = (float)points[i].X;
                    pts[j++] = (float)points[i].Y;
                    pts[j++] = (float)points[i + 1].X;
                    pts[j++] = (float)points[i + 1].Y;
                }

                canvas.DrawLines(pts, paint);
            }
        }
Exemplo n.º 52
0
        public void DrawLineSegments(IList<Point> points, Color stroke, double thickness = 1, double[] dashArray = null, PenLineJoin lineJoin = PenLineJoin.Miter, bool aliased = false)
        {
            using (var paint = new Paint())
            {
                paint.StrokeWidth = (float)thickness;
                paint.Color = stroke;
                paint.AntiAlias = !aliased;
                var pts = new float[points.Count * 2];
                int i = 0;
                foreach (var p in points)
                {
                    pts[i++] = (float)p.X;
                    pts[i++] = (float)p.Y;
                }

                canvas.DrawLines(pts, paint);
            }
        }
 public static void DrawCircle(this IDrawingContext renderer, Point point, double radius, Color fillColor, Color strokeColor,
     double thickness = 1.0, PenLineJoin lineJoin = PenLineJoin.Miter, ICollection<double> dashArray = null, double dashOffset = 0, bool isHitTestVisible = false)
 {
     var diameter = radius*2;
     renderer.DrawEllipse(point, new Size(diameter, diameter), fillColor, strokeColor, thickness, lineJoin, dashArray, dashOffset, isHitTestVisible);
 }
Exemplo n.º 54
0
        public void DrawPolygon(IList<Point> points, Color fill, Color stroke, double thickness = 1, double[] dashArray = null, PenLineJoin lineJoin = PenLineJoin.Miter, bool aliased = false)
        {
            using (var paint = new Paint())
            {
                paint.AntiAlias = !aliased;
                paint.StrokeWidth = (float)thickness;
                using (var path = new Path())
                {
                    path.MoveTo((float)points[0].X, (float)points[0].Y);
                    for (int i = 1; i <= points.Count; i++)
                    {
                        path.LineTo((float)points[i % points.Count].X, (float)points[i % points.Count].Y);
                    }

                    if (fill != null)
                    {
                        paint.SetStyle(Paint.Style.Fill);
                        paint.Color = fill;
                        canvas.DrawPath(path, paint);
                    }

                    if (stroke != null)
                    {
                        paint.SetStyle(Paint.Style.Stroke);
                        paint.Color = stroke;
                        canvas.DrawPath(path, paint);
                    }
                }
            }
        }
Exemplo n.º 55
0
		public void SetLineJoin (Pen widget, PenLineJoin lineJoin)
		{
			widget.ToSD ().LineJoin = lineJoin.ToSD ();
		}
Exemplo n.º 56
0
		public PenX3D(
			IMaterial material,
			ICrossSectionOfLine crossSection,
			PenLineJoin lineJoin,
			double miterLimit,
			ILineCap lineStartCap, ILineCap lineEndCap, IDashPattern dashPattern, ILineCap dashStartCap, bool dashStartCapSuppressionIfSpaceInsufficient, ILineCap dashEndCap, bool dashEndCapSuppressionIfSpaceInsufficient)
		{
			if (!(miterLimit >= 1))
				throw new ArgumentOutOfRangeException(nameof(miterLimit), "must be >= 1");
			if (null == dashPattern)
				throw new ArgumentNullException(nameof(dashPattern));

			_material = material;
			_crossSection = crossSection;
			_lineJoin = lineJoin;
			_miterLimit = miterLimit;
			_lineStartCap = lineStartCap;
			_lineEndCap = lineEndCap;
			_dashPattern = dashPattern;
			_dashStartCap = dashStartCap;
			_dashStartCapSuppressionIfSpaceInsufficient = dashStartCapSuppressionIfSpaceInsufficient;
			_dashEndCap = dashEndCap;
			_dashEndCapSuppressionIfSpaceInsufficient = dashEndCapSuppressionIfSpaceInsufficient;
		}