Example #1
0
        public override IBrush GetBrush(byte alpha)
        {
            if (_canvasRadialGradientBrush is not null)
            {
                return(_canvasRadialGradientBrush);
            }

            var startPoint = new Vector((float)_x0, (float)_y0);
            var endPoint   = new Vector((float)_x1, (float)_y1);

            startPoint = LocalMatrix.Transform(startPoint);
            endPoint   = LocalMatrix.Transform(endPoint);

            var x0 = startPoint.X;
            var y0 = startPoint.Y;
            var x1 = endPoint.X;
            var y1 = endPoint.Y;

            var r   = Math.Sqrt(Math.Pow(x1 - x0, 2) + Math.Pow(y1 - y0, 2));
            var ang = Math.Atan2(x1 - x0, y1 - y0);

            var percent = _hl;

            percent = percent switch
            {
Example #2
0
        public override IBrush GetBrush(byte alpha)
        {
            if (_canvasRadialGradientBrush == null)
            {
                var center = new Vector2(_x0, _y0);
                center = LocalMatrix.Transform(center);

                //
                // var properties = new RadialGradientBrushProperties
                // {
                //     RadiusX = _r,
                //     RadiusY = _r,
                //     Center = center
                // };
                //
                // var collection = new GradientStopCollection(renderTarget, _canvasGradientStopCollection, Gamma.Linear, ExtendMode.Clamp);
                // //TODO: OID: property missed, Same for Linear
                //

                _canvasRadialGradientBrush = new RadialGradientBrush
                {
                    Radius        = _r,
                    Center        = new RelativePoint(center.X, center.Y, RelativeUnit.Relative),
                    GradientStops = _canvasGradientStopCollection
                };
            }

            _canvasRadialGradientBrush.Opacity = alpha / 255f;

            return(_canvasRadialGradientBrush.ToImmutable());
        }
Example #3
0
        public override ICanvasBrush GetBrush(CanvasDevice device, byte alpha)
        {
            var startPoint = new Vector2(_x0, _y0);
            var endPoint   = new Vector2(_x1, _y1);

            startPoint = LocalMatrix.Transform(startPoint);
            endPoint   = LocalMatrix.Transform(endPoint);

            var canvasLinearGradientBrush = new CanvasLinearGradientBrush(device,
                                                                          _canvasGradientStopCollection, CanvasEdgeBehavior.Clamp, CanvasAlphaMode.Straight)
            {
                StartPoint = startPoint,
                EndPoint   = endPoint,
                Opacity    = alpha / 255f
            };

            return(canvasLinearGradientBrush);
        }
Example #4
0
        public override ICanvasBrush GetBrush(CanvasDevice device, byte alpha)
        {
            var center = new Vector2(_x0, _y0);

            center = LocalMatrix.Transform(center);

            var canvasRadialGradientBrush = new CanvasRadialGradientBrush(device,
                                                                          _canvasGradientStopCollection,
                                                                          CanvasEdgeBehavior.Clamp, CanvasAlphaMode.Straight)
            {
                Center  = center,
                Opacity = alpha / 255f,
                RadiusX = _r,
                RadiusY = _r
            };

            return(canvasRadialGradientBrush);
        }
        public override IBrush GetBrush(byte alpha)
        {
            if (_canvasLinearGradientBrush == null)
            {
                var startPoint = new Vector((float)_x0, (float)_y0);
                var endPoint   = new Vector((float)_x1, (float)_y1);

                startPoint = LocalMatrix.Transform(startPoint);
                endPoint   = LocalMatrix.Transform(endPoint);

                _canvasLinearGradientBrush = new ImmutableLinearGradientBrush(_canvasGradientStopCollection,
                                                                              alpha / 255f,
                                                                              startPoint: new RelativePoint(startPoint.X, startPoint.Y, RelativeUnit.Relative),
                                                                              endPoint: new RelativePoint(endPoint.X, endPoint.Y, RelativeUnit.Relative));
            }

            return(_canvasLinearGradientBrush);
        }
Example #6
0
        public override Brush GetBrush(RenderTarget renderTarget, byte alpha)
        {
            if (_canvasLinearGradientBrush == null || _canvasLinearGradientBrush.IsDisposed)
            {
                var startPoint = new Vector2(_x0, _y0);
                var endPoint   = new Vector2(_x1, _y1);

                startPoint = LocalMatrix.Transform(startPoint);
                endPoint   = LocalMatrix.Transform(endPoint);

                _canvasLinearGradientBrush = new LinearGradientBrush(renderTarget, new LinearGradientBrushProperties
                {
                    StartPoint = startPoint.ToRaw(),
                    EndPoint   = endPoint.ToRaw(),
                }
                                                                     , new GradientStopCollection(renderTarget, _canvasGradientStopCollection, Gamma.Linear, ExtendMode.Clamp));
            }

            _canvasLinearGradientBrush.Opacity = alpha / 255f;

            return(_canvasLinearGradientBrush);
        }
Example #7
0
        public override IBrush GetBrush(byte alpha)
        {
            if (_canvasLinearGradientBrush == null)
            {
                var startPoint = new Vector2(_x0, _y0);
                var endPoint   = new Vector2(_x1, _y1);

                startPoint = LocalMatrix.Transform(startPoint);
                endPoint   = LocalMatrix.Transform(endPoint);

                _canvasLinearGradientBrush = new LinearGradientBrush
                {
                    StartPoint    = new RelativePoint(startPoint.X, startPoint.Y, RelativeUnit.Relative),
                    EndPoint      = new RelativePoint(endPoint.X, endPoint.Y, RelativeUnit.Relative),
                    GradientStops = _canvasGradientStopCollection
                };
            }

            _canvasLinearGradientBrush.Opacity = alpha / 255f;

            return(_canvasLinearGradientBrush.ToImmutable());
        }
Example #8
0
        public override Brush GetBrush(RenderTarget renderTarget, byte alpha)
        {
            if (_canvasRadialGradientBrush == null || _canvasRadialGradientBrush.IsDisposed)
            {
                var center = new Vector2(_x0, _y0);
                center = LocalMatrix.Transform(center);

                var properties = new RadialGradientBrushProperties
                {
                    RadiusX = _r,
                    RadiusY = _r,
                    Center  = center
                };

                var collection = new GradientStopCollection(renderTarget, _canvasGradientStopCollection, Gamma.Linear, ExtendMode.Clamp);
                //TODO: OID: property missed, Same for Linear
                _canvasRadialGradientBrush = new RadialGradientBrush(renderTarget, properties, collection);
            }

            _canvasRadialGradientBrush.Opacity = alpha / 255f;

            return(_canvasRadialGradientBrush);
        }