本文整理汇总了C#中Cairo.LinearGradient.AddColorStopRgb方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.LinearGradient.AddColorStopRgb方法的具体用法?C# Cairo.LinearGradient.AddColorStopRgb怎么用?C# Cairo.LinearGradient.AddColorStopRgb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.LinearGradient
的用法示例。
在下文中一共展示了Cairo.LinearGradient.AddColorStopRgb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetBrush
private void SetBrush(Brush brush, Size destinationSize)
{
var solid = brush as SolidColorBrush;
var linearGradientBrush = brush as LinearGradientBrush;
if (solid != null)
{
_context.SetSourceRGBA(
solid.Color.R / 255.0,
solid.Color.G / 255.0,
solid.Color.B / 255.0,
solid.Color.A / 255.0);
}
else if (linearGradientBrush != null)
{
Cairo.LinearGradient g = new Cairo.LinearGradient(linearGradientBrush.StartPoint.X * destinationSize.Width, linearGradientBrush.StartPoint.Y * destinationSize.Height, linearGradientBrush.EndPoint.X * destinationSize.Width, linearGradientBrush.EndPoint.Y * destinationSize.Height);
foreach (var s in linearGradientBrush.GradientStops)
g.AddColorStopRgb(s.Offset, new Cairo.Color(s.Color.R, s.Color.G, s.Color.B, s.Color.A));
g.Extend = Cairo.Extend.Pad;
_context.SetSource(g);
}
}
示例2: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose e)
{
using (Cairo.Context cr = Gdk.CairoHelper.Create (e.Window)) {
cr.Rectangle (0, 0, Allocation.Width, upperGradientHeight);
using (var pattern = new Cairo.LinearGradient (0, 0, 0, upperGradientHeight)) {
pattern.AddColorStopRgb (0, new Cairo.Color (0.6, 0.8, 0.6));
pattern.AddColorStopRgb (1, new Cairo.Color (0.8, 1.0, 0.8));
cr.Pattern = pattern;
cr.Fill ();
}
cr.Rectangle (0, upperGradientHeight, Allocation.Width, Allocation.Height - upperGradientHeight);
using (var pattern = new Cairo.LinearGradient (0, upperGradientHeight, 0, Allocation.Height)) {
pattern.AddColorStop (0, new Cairo.Color (0.8, 1.0, 0.8));
pattern.AddColorStop (1, new Cairo.Color (0.6, 0.8, 0.6));
cr.Pattern = pattern;
cr.Fill ();
}
cr.LineWidth = 1;
cr.Line (0, 0, Allocation.Width, 0);
cr.Color = new Cairo.Color (0.4, 0.6, 0.4);
cr.Stroke ();
double xPos = padding, yPos = padding;
var layout = PangoUtil.CreateLayout (this);
int w, h;
layout.SetText (new string ('X', maxLength));
layout.GetPixelSize (out w, out h);
foreach (Category cat in categories) {
yPos = padding;
cr.MoveTo (xPos, yPos);
layout.SetMarkup ("<b>" + cat.Title + "</b>");
cr.Color = (HslColor)Style.Text (StateType.Normal);
cr.ShowLayout (layout);
layout.SetMarkup ("");
int w2, h2;
layout.GetPixelSize (out w2, out h2);
yPos += h2;
yPos += headerDistance;
var startY = yPos;
int curItem = 0;
int row = 0;
var iconHeight = Math.Max (h, cat.Items [0].Icon.Height + 2);
if (cat.FirstVisibleItem > 0) {
Gtk.Style.PaintArrow (Style, e.Window, State, ShadowType.None,
new Rectangle ((int)xPos, (int)yPos, w, h),
this,
"",
ArrowType.Up,
true,
(int)xPos,
(int)yPos,
w,
h);
yPos += iconHeight;
curItem++;
}
for (int i = cat.FirstVisibleItem; i < cat.Items.Count; i++) {
var item = cat.Items [i];
if (curItem + 1 >= maxItems && row + 1 >= maxRows && i + 1 < cat.Items.Count) {
Gtk.Style.PaintArrow (Style, e.Window, State, ShadowType.None,
new Rectangle ((int)xPos, (int)yPos, w, h),
this,
"",
ArrowType.Down,
true,
(int)xPos,
(int)yPos,
w,
h);
break;
}
if (item == ActiveItem) {
cr.Rectangle (xPos + 0.5, yPos + 0.5, w + item.Icon.Width + 2, iconHeight);
using (var pattern = new Cairo.LinearGradient (xPos, yPos, xPos, yPos + iconHeight * 2)) {
pattern.AddColorStop (0, (HslColor)Style.Base (StateType.Selected));
pattern.AddColorStop (1, new Cairo.Color (0.8, 1.0, 0.8));
cr.Pattern = pattern;
cr.FillPreserve ();
}
cr.Color = (HslColor)Style.Base (StateType.Selected);
cr.Stroke ();
cr.Color = (HslColor)Style.Text (StateType.Selected);
} else if (item == hoverItem) {
cr.Rectangle (xPos + 0.5, yPos + 0.5, w + item.Icon.Width + 2, iconHeight);
using (var pattern = new Cairo.LinearGradient (xPos, yPos, xPos, yPos + iconHeight)) {
pattern.AddColorStop (0, new Cairo.Color (0.6, 0.8, 0.6));
pattern.AddColorStop (1, new Cairo.Color (0.8, 1.0, 0.8));
cr.Pattern = pattern;
cr.Fill ();
}
cr.Color = (HslColor)Style.Text (StateType.Normal);
} else {
//.........这里部分代码省略.........