当前位置: 首页>>代码示例>>C#>>正文


C# GradientStopCollection类代码示例

本文整理汇总了C#中GradientStopCollection的典型用法代码示例。如果您正苦于以下问题:C# GradientStopCollection类的具体用法?C# GradientStopCollection怎么用?C# GradientStopCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GradientStopCollection类属于命名空间,在下文中一共展示了GradientStopCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveGradient

        public override void SaveGradient()
        {
            double rate = DataManager.Instance.MainData.PixelWidth / _bokehData.Width;

            GradientStopCollection collection = new GradientStopCollection();
            collection.Add(new GradientStop() { Color = Colors.Transparent, Offset = _bokehData.Rate });
            collection.Add(new GradientStop() { Color = Color.FromArgb(128, 0, 0, 0), Offset = _bokehData.Rate });
            collection.Add(new GradientStop() { Color = Color.FromArgb(255, 0, 0, 0), Offset = 1 });

            RadialGradientBrush brush = new RadialGradientBrush()
            {
                GradientOrigin = _bokehData.StarPoint,
                Center = _bokehData.StarPoint,
                RadiusX = _bokehData.RadiusX,
                RadiusY = _bokehData.RadiusY,
                GradientStops = collection,
            };
            Rectangle rectangle = new Rectangle()
            {
                Width = DataManager.Instance.MainData.PixelWidth,
                Height = DataManager.Instance.MainData.PixelHeight,
                Fill = _bokehData.MaskBrush,
                OpacityMask = brush
            };
            Canvas saveCanvas = new Canvas()
            {
                Width = rectangle.Width,
                Height = rectangle.Height,
                Background = new ImageBrush() { ImageSource = DataManager.Instance.MainData },
            };
            saveCanvas.Children.Add(rectangle);

            WriteableBitmap bmp = new WriteableBitmap(saveCanvas, null);
            DataManager.Instance.SaveToFile(bmp);
        }
开发者ID:onionstyle,项目名称:BokehDemo,代码行数:35,代码来源:EllipseGradient.cs

示例2: GetBrush

        public static System.Windows.Media.Brush GetBrush(this Brush brush)
        {
            if (brush is GradientBrush)
            {
                var gradienBrush = brush as GradientBrush;
                var stops = new GradientStopCollection(gradienBrush.Stops.Select(
                    g => new System.Windows.Media.GradientStop(g.Color.GetColor(), g.Offset)
                ));

                if (brush is LinearGradientBrush)
                {
                    return new System.Windows.Media.LinearGradientBrush(stops);
                }
                else if (brush is RadialGradientBrush)
                {
                    return new System.Windows.Media.RadialGradientBrush(stops);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            else if (brush is SolidBrush)
            {
                var solidBrush = brush as SolidBrush;
                return new SolidColorBrush(solidBrush.Color.GetColor());
            }
            else
            {
                throw new NotImplementedException();
            }
        }
开发者ID:zone117x,项目名称:NGraphics,代码行数:32,代码来源:PresentationFoundationPlatform.cs

示例3: RadialGradientBrush

        internal RadialGradientBrush(Direct2DRenderTarget renderTargetOwner, 
                                     GradientStop[] gradientStops, 
                                     ExtendMode extendMode, 
                                     PointF centerPoint, 
                                     PointF gradientOriginOffset,
                                     SizeF radius)
        {
            m_renderTargetOwner = renderTargetOwner;
            m_extendMode = extendMode;
            m_radius = radius;
            m_gradientOriginOffset = gradientOriginOffset;
            m_centerPoint = centerPoint;

            var gradientStopList = new List<SlimDX.Direct2D.GradientStop>(gradientStops.Length);

            for (int i = 0; i < gradientStops.Length; i++)
            {
                gradientStopList.Add(gradientStops[i].InternalGradientStop);
            }

            var props = new RadialGradientBrushProperties();
            props.CenterPoint = centerPoint.InternalPointF;
            props.GradientOriginOffset = gradientOriginOffset.InternalPointF;
            props.HorizontalRadius = radius.Width;
            props.VerticalRadius = radius.Height;

            m_internalGradientStopCollection = new GradientStopCollection(m_renderTargetOwner.InternalRenderTarget,
                                                                          gradientStopList.ToArray(),
                                                                          Gamma.Linear,
                                                                          (SlimDX.Direct2D.ExtendMode)extendMode);

            m_internalRadialGradientBrush = new SlimDX.Direct2D.RadialGradientBrush(m_renderTargetOwner.InternalRenderTarget,
                                                                                    m_internalGradientStopCollection, props);
        }
开发者ID:treytomes,项目名称:DirectCanvas,代码行数:34,代码来源:RadialGradientBrush.cs

示例4: Convert

        public static GradientBrush Convert(System.Windows.Media.Color color)
        {
            var scrgb = color.ToScRGBColor();

            var xyz = KnownColorSpaces.scRGB.ToXYZColor(scrgb);

            var lab = KnownColorSpaces.Lab.FromXYZColor(xyz) as LabColor;

            var l_base = lab.L;

            var gradientStops = new GradientStopCollection();

            var _lab = new LabColor(0xff, l_base * 1.07, lab.a, lab.b);
            var _c = _lab.ToWindowsMediaColor();

            gradientStops.Add(new GradientStop(_c, 0.5));


            _lab = new LabColor(0xff, l_base * .93, lab.a, lab.b);
            _c = _lab.ToWindowsMediaColor();

            gradientStops.Add(new GradientStop(_c, 1));


            var result = new LinearGradientBrush(gradientStops, 90);

            result.Freeze();

            return result;
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:30,代码来源:ColorToGradientBrushConverter.cs

示例5: D2Lines_Paint

        void D2Lines_Paint(object sender, PaintEventArgs e)
        {
            var lines = LineInfo.GenerateRandom(new Rectangle(Point.Empty, this.ClientSize));

            var sw = new Stopwatch();
            sw.Start();
            this.d2target.BeginDraw();
            this.d2target.Clear(Color.Black);

            foreach (var line in lines) {
                using (var gsc = new GradientStopCollection(this.d2target, new[]{
                    new GradientStop{ Position = 0f, Color = line.Ca },
                    new GradientStop{ Position = 1f, Color = line.Cb },
                }))
                using(var gb = new LinearGradientBrush(this.d2target, gsc, new LinearGradientBrushProperties{
                    StartPoint = line.Pa,
                    EndPoint = line.Pb,
                })) {
                    this.d2target.DrawLine(gb, line.Pa.X, line.Pa.Y, line.Pb.X, line.Pb.Y);
                }
            }

            this.d2target.EndDraw();
            sw.Stop();
            Program.Info(
                "{0}: {1} [ms], {2} [line], {3:.00} [line/ms], {4} * {5}",
                this.Text,
                sw.ElapsedMilliseconds,
                lines.Length,
                lines.Length / (float)sw.ElapsedMilliseconds,
                this.ClientSize.Width, this.ClientSize.Height
            );
        }
开发者ID:saiya,项目名称:111210_bentchmark_translucentLines,代码行数:33,代码来源:D2Lines.cs

示例6: Convert

        /// <summary>
        /// Converts the color of the supplied brush changing its luminosity by the given factor.
        /// </summary>
        /// <param name="value">The value that is produced by the binding target.</param>
        /// <param name="targetType">The type to convert to.</param>
        /// <param name="parameter">The factor used to adjust the luminosity (0..1).</param>
        /// <param name="culture">The culture to use in the converter (unused).</param>
        /// <returns>A converted value.</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
#endif
        {
            if (value == null) return null;
            if (parameter == null) return null;

            var factor = double.Parse(parameter.ToString(), CultureInfo.InvariantCulture);

            if (value is SolidColorBrush)
            {
                var color = ((SolidColorBrush)value).Color;
                var hlsColor = HlsColor.FromRgb(color);
                hlsColor.L *= factor;
                return new SolidColorBrush(hlsColor.ToRgb());
            }
            else if (value is LinearGradientBrush)
            {
                var gradientStops = new GradientStopCollection();
                foreach (var stop in ((LinearGradientBrush)value).GradientStops)
                {
                    var hlsColor = HlsColor.FromRgb(stop.Color);
                    hlsColor.L *= factor;
                    gradientStops.Add(new GradientStop() { Color = hlsColor.ToRgb(), Offset = stop.Offset });
                }

                var brush = new LinearGradientBrush(gradientStops, 0.0);
                return brush;
            }

            return value;
        }
开发者ID:alykhaled,项目名称:facebook-winclient-sdk,代码行数:39,代码来源:ColorLuminosityConverter.cs

示例7: DrawSquares

        private void DrawSquares()
        {
            if (Row >= 3)
            {
                startx += 5;
            }
            if (Row >= 6)
            {
                startx += 5;
            }

            int x = startx + (Row * 40);

            if (Column >= 3)
            {
                starty += 5;
            }

            if (Column >= 6)
            {
                starty += 5;
            }

            int y = starty + (Column * 37);

            SetValue(Canvas.LeftProperty, Convert.ToDouble(x));
            SetValue(Canvas.TopProperty, Convert.ToDouble(y));

            GradientStopCollection gradients = new GradientStopCollection();

            if (Value != 0)
            {
                gradients.Add(new GradientStop(Colors.LightBlue, 1));
                gradients.Add(new GradientStop(Color.FromArgb(38, 255, 255, 255), 0.448));
                gradients.Add(new GradientStop(Color.FromArgb(90, 73, 73, 73), 0.076));
                SudokuTextBox.Text = Value.ToString();
                SudokuTextBox.IsEnabled = false;
            }
            else
            {
                gradients.Add(new GradientStop(Colors.LightGreen, 0.9));
                gradients.Add(new GradientStop(Colors.White, 0.448));
                gradients.Add(new GradientStop(Colors.LightGreen, 0.076));

            }

            SudokuTextBox.BorderThickness = new Thickness(0);
            SudokuTextBox.TextAlignment = TextAlignment.Center;

            LinearGradientBrush brush = new LinearGradientBrush(gradients);
            brush.StartPoint = new Point(0.5, 0);
            brush.EndPoint = new Point(0.5, 1);
            SudokuRectangle.Fill = brush;
            SudokuRectangle.Stroke = Brushes.Gray;
            SudokuRectangle.StrokeThickness = 1;
            SudokuRectangle.RadiusX = 8;
            SudokuRectangle.RadiusY = 8;

            SudokuTextBox.TextChanged += new TextChangedEventHandler(SudokuTextBox_TextChanged);
        }
开发者ID:amomsen,项目名称:projects,代码行数:60,代码来源:SudokuSquare.xaml.cs

示例8: BGBarListBoxItem

        public BGBarListBoxItem(RecFolderInfo item)
        {
            InitializeComponent();

            labelFolder.Content = item.recFolder;
            progressBar.Value = item.freeBytes;
            progressBar.Maximum = item.totalBytes;

            GradientStopCollection stops = new GradientStopCollection();
            stops.Add(new GradientStop(Colors.Red, 0.1));
            stops.Add(new GradientStop(Colors.Yellow, 0.3));
            stops.Add(new GradientStop(Colors.Lime, 0.4));
            LinearGradientBrush brush = new LinearGradientBrush(stops, new Point(0, 0), new Point(1, 0));
            brush.ColorInterpolationMode = ColorInterpolationMode.SRgbLinearInterpolation;
            progressBar.Background = brush;

            if (item.freeBytes > 0 && item.totalBytes > 0)
            {
                List<string> units = new List<string> { "Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" };
                int unit_base = 1024;

                int n = (int)Math.Floor(Math.Min(Math.Log(item.freeBytes) / Math.Log(unit_base), units.Count - 1));
                int m = (int)Math.Floor(Math.Min(Math.Log(item.totalBytes) / Math.Log(unit_base), units.Count - 1));
                ToolTip = "空き容量: " + Math.Round(item.freeBytes / Math.Pow(unit_base, n), 1).ToString() + " " + units[n]
                 + "/" + Math.Round(item.totalBytes / Math.Pow(unit_base, m), 1).ToString() + " " + units[m];
            }
        }
开发者ID:xceza7,项目名称:EDCB,代码行数:27,代码来源:BGBarListBoxItem.xaml.cs

示例9: GradientBrushTexture

 public GradientBrushTexture(GradientStopCollection stops)
 {
   _assetId++;
   _stops = stops.OrderedGradientStopList.Select(GradientStopData.FromGradientStop).ToList();
   _name = String.Format("GradientBrushTexture#{0}", _assetId);
   Allocate();
 }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:7,代码来源:GradientBrushTexture.cs

示例10: LinearGradientBrush

        internal LinearGradientBrush(Direct2DRenderTarget renderTargetOwner, 
                                     GradientStop[] gradientStops, 
                                     ExtendMode extendMode, 
                                     PointF startPoint, 
                                     PointF endPoint)
        {
            m_renderTargetOwner = renderTargetOwner;

            var gradientStopList = new List<SlimDX.Direct2D.GradientStop>(gradientStops.Length);

            for (int i = 0; i < gradientStops.Length; i++)
            {
                gradientStopList.Add(gradientStops[i].InternalGradientStop);
            }

            var props = new LinearGradientBrushProperties();
            props.StartPoint = startPoint.InternalPointF;
            props.EndPoint = endPoint.InternalPointF;

            m_startPoint = startPoint;
            m_endPoint = endPoint;

            var internalRt = m_renderTargetOwner.InternalRenderTarget;

            m_internalGradientStopCollection = new GradientStopCollection(internalRt, 
                                                                          gradientStopList.ToArray(), 
                                                                          Gamma.Linear, 
                                                                          (SlimDX.Direct2D.ExtendMode)extendMode);

            m_internalLinearGradientBrush = new SlimDX.Direct2D.LinearGradientBrush(internalRt,
                                                                                    m_internalGradientStopCollection, 
                                                                                    props);
        }
开发者ID:treytomes,项目名称:DirectCanvas,代码行数:33,代码来源:LinearGradientBrush.cs

示例11: CreateFrozenBrush

        protected static LinearGradientBrush CreateFrozenBrush(GradientStopCollection stops, Point start, Point end)
        {
            var brush = new LinearGradientBrush(stops, start, end);

            brush.Freeze();

            return brush;
        }
开发者ID:HEskandari,项目名称:FarsiLibrary,代码行数:8,代码来源:ButtonChrome.cs

示例12: CreateParallelBrush

 public void CreateParallelBrush(string ls, double acc, double tot, string esp, string eep)
 {
     var stops = new GradientStopCollection();
     var line = ls.AsLine();
     var actual = GradientPath.CreateParallelBrush(stops, acc, tot, line);
     Assert.Equal(esp, actual.StartPoint.ToString("F0"));
     Assert.Equal(eep, actual.EndPoint.ToString("F0"));
 }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.Geometry,代码行数:8,代码来源:GradientPathTests.cs

示例13: CreatePerpendicularBrush

 public void CreatePerpendicularBrush(string ls, double width, string esp, string eep)
 {
     var stops = new GradientStopCollection();
     var line = ls.AsLine();
     var actual = GradientPath.CreatePerpendicularBrush(stops, 10, line);
     Assert.Equal(Point.Parse(esp), actual.StartPoint);
     Assert.Equal(Point.Parse(eep), actual.EndPoint);
 }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.Geometry,代码行数:8,代码来源:GradientPathTests.cs

示例14: CreateGradientBrush

 protected Brush CreateGradientBrush(Color baseColor)
 {
     const byte brightness = 60;
     var gradientStops = new GradientStopCollection();
     gradientStops.Add(new GradientStop() { Color = LightenColor(baseColor, brightness), Offset = 0.0 });
     gradientStops.Add(new GradientStop() { Color = baseColor, Offset = 1.0 });
     return new LinearGradientBrush(gradientStops, 90);
 }
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:8,代码来源:ExtendedDataToSeriesConverterBase.cs

示例15: OnMouseLeave

		private void OnMouseLeave(object sender, RoutedEventArgs e)
		{
			GradientStopCollection stopCollection = new GradientStopCollection();
			stopCollection.Add(new GradientStop(Colors.Blue, 0.05));
			stopCollection.Add(new GradientStop(Colors.LightBlue, 0.95));
			RadialGradientBrush brush = new RadialGradientBrush(stopCollection);
			circle.Fill = brush;		
		}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:8,代码来源:PlaybackButton.xaml.cs


注:本文中的GradientStopCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。