本文整理汇总了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);
}
示例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();
}
}
示例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);
}
示例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;
}
示例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
);
}
示例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;
}
示例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);
}
示例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];
}
}
示例9: GradientBrushTexture
public GradientBrushTexture(GradientStopCollection stops)
{
_assetId++;
_stops = stops.OrderedGradientStopList.Select(GradientStopData.FromGradientStop).ToList();
_name = String.Format("GradientBrushTexture#{0}", _assetId);
Allocate();
}
示例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);
}
示例11: CreateFrozenBrush
protected static LinearGradientBrush CreateFrozenBrush(GradientStopCollection stops, Point start, Point end)
{
var brush = new LinearGradientBrush(stops, start, end);
brush.Freeze();
return brush;
}
示例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"));
}
示例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);
}
示例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);
}
示例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;
}