Пример #1
0
 public override void Clean()
 {
     X.Clear();
     Y.Clear();
     RadiusX.Clear();
     RadiusY.Clear();
 }
Пример #2
0
        public override string ToString()
        {
            var arcFlag   = Size == SvgArcSize.Large ? "1" : "0";
            var sweepFlag = Sweep == SvgArcSweep.Positive ? "1" : "0";

            return("A" + RadiusX.ToSvgString() + " " + RadiusY.ToSvgString() + " " + Angle.ToSvgString() + " " + arcFlag + " " + sweepFlag + " " + End.ToSvgString());
        }
Пример #3
0
        private void OnPropertyChanged(ManagedWeakReference?instance, DependencyProperty property, DependencyPropertyChangedEventArgs?args)
        {
            if (_svgElement == null)
            {
                return;
            }

            if (property == CenterProperty)
            {
                var center = Center;

                _svgElement.SetAttribute(
                    ("cx", center.X.ToStringInvariant()),
                    ("cy", center.Y.ToStringInvariant()));
                _svgElement.InvalidateMeasure();
            }
            else if (property == RadiusXProperty)
            {
                _svgElement.SetAttribute("rx", RadiusX.ToStringInvariant());
                _svgElement.InvalidateMeasure();
            }
            else if (property == RadiusYProperty)
            {
                _svgElement.SetAttribute("ry", RadiusY.ToStringInvariant());
                _svgElement.InvalidateMeasure();
            }
        }
Пример #4
0
        public override void Prepare(DrawInfo info)
        {
            // Prepare inputs:
            base.Prepare(info);

            if (info.Mode == SurfaceDrawMode.CPU)
            {
                // Prerender now! Bitmap node will sample it as needed.

                int width  = info.ImageX;
                int height = info.ImageY;

                // Set buffer etc:
                Setup(info);

                // Setup secondary buffer:
                if (Buffer2 == null || Buffer2.Length != Buffer.Length)
                {
                    Buffer2 = new Color[Buffer.Length];
                }

                Width  = width;
                Height = height;

                // Render into buffer2:
                SourceModule.DrawCPU(info, Buffer2);

                // Get radii:
                int hRadius = (int)(width * RadiusX.GetValue(0.0, 0.0));
                int vRadius = (int)(height * RadiusY.GetValue(0.0, 0.0));

                // Do percentile filter now:
                PercentileFilter.Filter(Buffer2, Buffer, width, height, hRadius, vRadius, Percent);
            }
        }
Пример #5
0
        public override void Prepare(DrawInfo info)
        {
            base.Prepare(info);

            if (info.Mode == SurfaceDrawMode.CPU)
            {
                // Prerender source now!

                int width  = info.ImageX;
                int height = info.ImageY;

                // Buffer etc:
                Setup(info);

                // Setup secondary buffer:
                if (Buffer2 == null || Buffer2.Length != Buffer.Length)
                {
                    Buffer2 = new Color[Buffer.Length];
                }

                // Draw source now:
                SourceModule.DrawCPU(info, Buffer2);

                Width  = width;
                Height = height;

                // Get radii:
                float hRadius = (float)(width * RadiusX.GetValue(0.0, 0.0));
                float vRadius = (float)(height * RadiusY.GetValue(0.0, 0.0));

                // Box or gaus blur:
                if (Method_ == (int)BlurMethod.Box)
                {
                    // Blurs and flips (horizontal for vertical):
                    BoxBlurFilter.BlurAndTranspose(Buffer2, Buffer, width, height, (int)hRadius);
                    BoxBlurFilter.BlurAndTranspose(Buffer, Buffer2, height, width, (int)vRadius);
                }
                else
                {
                    Kernel kernelH = GaussianFilter.MakeKernel(hRadius);
                    Kernel kernelV;

                    if (vRadius == hRadius)
                    {
                        kernelV = kernelH;
                    }
                    else
                    {
                        kernelV = GaussianFilter.MakeKernel(vRadius);
                    }

                    // Blurs and flips (horizontal for vertical):
                    GaussianFilter.ConvolveAndTranspose(kernelH, Buffer2, Buffer, width, height, true, ConvolveWrapping.ClampEdges);
                    GaussianFilter.ConvolveAndTranspose(kernelV, Buffer, Buffer2, height, width, true, ConvolveWrapping.ClampEdges);
                }
            }
        }
        /// <summary>
        /// Gets the path representing this element.
        /// </summary>
        public override VectorPath GetPath(SVGElement context, RenderContext renderer)
        {
            Css.RenderableData rd = context.RenderData;

            // Don't build the path if there's no radius:
            float radiusX = RadiusX.GetDecimal(rd, ViewportAxis.X);
            float radiusY = RadiusY.GetDecimal(rd, ViewportAxis.Y);

            if (radiusX <= 0f || radiusY <= 0f)
            {
                return(null);
            }

            if (_Path == null)
            {
                // Don't need to consider stroke width.

                _Path = new VectorPath();

                float centerX = CenterX.GetDecimal(rd, ViewportAxis.X);
                float centerY = CenterX.GetDecimal(rd, ViewportAxis.Y);

                // Get the C values:
                float cX = centerX + (CircleProvider.BezierC * radiusX);
                float cY = centerY + (CircleProvider.BezierC * radiusY);

                float nRadiusX = centerX - radiusX;
                float nRadiusY = centerY - radiusY;

                // Offset radius:
                radiusX += centerX;
                radiusY += centerY;

                _Path.MoveTo(centerX, radiusY);

                // First quadrant (top right, going clockwise):
                _Path.CurveTo(cX, radiusY, radiusX, cY, radiusX, centerY);

                // Bottom right:
                _Path.CurveTo(radiusX, -cY, cX, nRadiusY, centerX, nRadiusY);

                // Bottom left:
                _Path.CurveTo(-cX, nRadiusY, nRadiusX, -cY, nRadiusX, centerY);

                // Top left:
                _Path.CurveTo(nRadiusX, cY, -cX, radiusY, centerX, radiusY);

                // Mark as closed:
                _Path.LatestPathNode.IsClose = true;
            }

            return(_Path);
        }
Пример #7
0
 public override string ToString()
 {
     return(string.Join(" ", new object[]
     {
         "A", // arc absolute
         RadiusX.ToDisplayString(),
         RadiusY.ToDisplayString(),
         XAxisRotation.ToDisplayString(),
         IsLargeArc ? 1 : 0,
         IsCounterClockwiseSweep ? 1 : 0,
         EndPoint.ToString()
     }));
 }
Пример #8
0
        private void UpdateRadius()
        {
            var child = Content as FrameworkElement;

            if (child == null || !RadiusX.Equals(0) || !RadiusY.Equals(0))
            {
                return;
            }

            var types = new Dictionary <Type, Action>
            {
                { typeof(Grid), () => RadiusX = RadiusY = ((Grid)child).CornerRadius.TopLeft },
                { typeof(Border), () => RadiusX = RadiusY = ((Border)child).CornerRadius.TopLeft },
                { typeof(RelativePanel), () => RadiusX = RadiusY = ((RelativePanel)child).CornerRadius.TopLeft },
                { typeof(StackPanel), () => RadiusX = RadiusY = ((StackPanel)child).CornerRadius.TopLeft }
            };

            if (types.ContainsKey(child.GetType()))
            {
                types[child.GetType()]();
            }
        }
Пример #9
0
 partial void OnRadiusYChangedPartial()
 {
     _rectangle.SetAttribute("ry", RadiusY.ToStringInvariant());
 }
Пример #10
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((Location.GetHashCode() * 397) ^ (RadiusX.GetHashCode() * 397) ^ (RadiusY.GetHashCode() * 397) ^ (StartAngle.GetHashCode() * 397) ^ SweepAngle.GetHashCode());
     }
 }
Пример #11
0
 public string ToString(string format, IFormatProvider provider)
 {
     return($"CenterX={CenterX.ToString(format, provider)} CenterY={CenterY.ToString(format, provider)} RadiusX={RadiusX.ToString(format, provider)} RadiusY={RadiusY.ToString(format, provider)}");
 }