本文整理汇总了C#中Cairo.Context.Mask方法的典型用法代码示例。如果您正苦于以下问题:C# Context.Mask方法的具体用法?C# Context.Mask怎么用?C# Context.Mask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Context.Mask方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnExpose
public bool OnExpose (Context ctx, Gdk.Rectangle allocation)
{
if (frames == 0)
start = DateTime.UtcNow;
frames ++;
TimeSpan elapsed = DateTime.UtcNow - start;
double fraction = elapsed.Ticks / (double) duration.Ticks;
double opacity = Math.Sin (Math.Min (fraction, 1.0) * Math.PI * 0.5);
ctx.Operator = Operator.Source;
SurfacePattern p = new SurfacePattern (begin_buffer.Surface);
ctx.Matrix = begin_buffer.Fill (allocation);
p.Filter = Filter.Fast;
ctx.Source = p;
ctx.Paint ();
ctx.Operator = Operator.Over;
ctx.Matrix = end_buffer.Fill (allocation);
SurfacePattern sur = new SurfacePattern (end_buffer.Surface);
#if MONO_1_2_5
Pattern black = new SolidPattern (new Cairo.Color (0.0, 0.0, 0.0, opacity));
#else
Pattern black = new SolidPattern (new Cairo.Color (0.0, 0.0, 0.0, opacity), true);
#endif
//ctx.Source = black;
//ctx.Fill ();
sur.Filter = Filter.Fast;
ctx.Source = sur;
ctx.Mask (black);
//ctx.Paint ();
ctx.Matrix = new Matrix ();
ctx.MoveTo (allocation.Width / 2.0, allocation.Height / 2.0);
ctx.Source = new SolidPattern (1.0, 0, 0);
#if debug
ctx.ShowText (String.Format ("{0} {1} {2} {3} {4} {5} {6} {7}",
frames,
sur.Status,
p.Status,
opacity, fraction, elapsed, start, DateTime.UtcNow));
#endif
sur.Destroy ();
p.Destroy ();
return fraction < 1.0;
}
示例2: OnMouseDown
protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
{
int x = (int)point.X;
int y = (int)point.Y;
if (args.Event.Button == 1)//Left
{
//Select an origin with Ctrl + Click
if((args.Event.State & Gdk.ModifierType.ControlMask) == Gdk.ModifierType.ControlMask)
{
from_point = new Point (x, y);
stamp = new Cairo.ImageSurface (PintaCore.Layers.CurrentLayer.Surface.Format, BrushWidth*2, BrushWidth*2);
from_point = ClampPoint(from_point);
using (Context g = new Context (stamp)) {
g.SetSourceSurface (PintaCore.Layers.CurrentLayer.Surface,
0 - (from_point.X - BrushWidth),
0 - (from_point.Y - BrushWidth));//dest - source
g.Rectangle(0, 0, BrushWidth * 2, BrushWidth * 2);
Gradient radpat = new RadialGradient(from_point.X, from_point.Y, BrushWidth, from_point.X, from_point.Y, BrushWidth);
radpat.AddColorStop(0, new Color(0, 0, 0, 1));
radpat.AddColorStop(1, new Color(0, 0, 0, 0));
g.Mask(radpat);
g.Fill ();
}
// Draw the copy
} else {
to_point = new Point (x, y);
if (PintaCore.Workspace.PointInCanvas (point) && !from_point.Equals (point_empty))
{
to_point = ClampPoint(to_point);
surface_modified = true;
undo_surface = PintaCore.Layers.CurrentLayer.Surface.Clone ();
ImageSurface surf = PintaCore.Layers.CurrentLayer.Surface;
using (Context g = new Context (surf)) {
g.SetSourceSurface (stamp, to_point.X - BrushWidth, to_point.Y - BrushWidth);
g.Paint ();
}
Gdk.Rectangle r = GetRectangleFromPoints (to_point, to_point);
PintaCore.Workspace.Invalidate ();
PintaCore.History.PushNewItem(new SimpleHistoryItem (Icon, Name,undo_surface, PintaCore.Layers.CurrentLayerIndex));
}
from_point = point_empty;
}
}
base.OnMouseDown (canvas, args, point);
}
示例3: Apply
public void Apply(Context ctx, Gdk.Rectangle allocation)
{
var p = new SurfacePattern (info.Surface);
ctx.Matrix = new Matrix ();
Matrix m = info.Fit (allocation);
ctx.Operator = Operator.Over;
ctx.Matrix = m;
ctx.SetSource (p);
ctx.Paint ();
var overlay = new SurfacePattern (blur.Surface);
ctx.Matrix = new Matrix ();
ctx.Matrix = blur.Fit (allocation);
ctx.Operator = Operator.Over;
ctx.SetSource (overlay);
// FIXME ouch this is ugly.
if (mask == null)
Radius = Radius;
//ctx.Paint ();
ctx.Mask (mask);
overlay.Dispose ();
p.Dispose ();
}
示例4: OnExpose
public bool OnExpose(Context ctx, Gdk.Rectangle allocation)
{
ctx.Operator = Operator.Source;
SurfacePattern p = new SurfacePattern (begin_buffer.Surface);
ctx.Matrix = begin_buffer.Fill (allocation);
p.Filter = Filter.Fast;
ctx.Source = p;
ctx.Paint ();
ctx.Operator = Operator.Over;
ctx.Matrix = end_buffer.Fill (allocation);
SurfacePattern sur = new SurfacePattern (end_buffer.Surface);
sur.Filter = Filter.Fast;
ctx.Source = sur;
Pattern mask = CreateMask (allocation, fraction);
ctx.Mask (mask);
mask.Destroy ();
p.Destroy ();
sur.Destroy ();
return fraction < 1.0;
}
示例5: Apply
public void Apply(Context ctx, Gdk.Rectangle allocation)
{
SurfacePattern p = new SurfacePattern (info.Surface);
ctx.Matrix = new Matrix ();
Matrix m = info.Fit (allocation);
ctx.Operator = Operator.Over;
ctx.Matrix = m;
ctx.Source = p;
ctx.Paint ();
SurfacePattern overlay = new SurfacePattern (blur.Surface);
ctx.Matrix = new Matrix ();
ctx.Matrix = blur.Fit (allocation);
ctx.Operator = Operator.Over;
ctx.Source = overlay;
// FIXME ouch this is ugly.
if (mask == null)
Radius = Radius;
//ctx.Paint ();
ctx.Mask (mask);
overlay.Destroy ();
p.Destroy ();
}
示例6: ClippedRender
protected override void ClippedRender(Context cr)
{
if (!EnsureLayout ()) {
return;
}
Brush foreground = Foreground;
if (!foreground.IsValid) {
return;
}
cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height);
cr.Clip ();
bool fade = text_alloc.Width > RenderSize.Width;
if (fade) {
cr.PushGroup ();
}
cr.MoveTo (text_alloc.X, text_alloc.Y);
Foreground.Apply (cr);
Pango.CairoHelper.ShowLayout (cr, layout);
cr.Fill ();
if (fade) {
LinearGradient mask = new LinearGradient (RenderSize.Width - 20, 0, RenderSize.Width, 0);
mask.AddColorStop (0, new Color (0, 0, 0, 1));
mask.AddColorStop (1, new Color (0, 0, 0, 0));
cr.PopGroupToSource ();
cr.Mask (mask);
mask.Destroy ();
}
cr.ResetClip ();
}