本文整理汇总了C#中Cairo.Context.Rectangle方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.Context.Rectangle方法的具体用法?C# Cairo.Context.Rectangle怎么用?C# Cairo.Context.Rectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Cairo.Context.Rectangle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBrush
void DrawBrush (double x, double y)
{
using (Cairo.Context ctx = new Cairo.Context (surface)) {
ctx.Rectangle ((int) x - 3, (int) y - 3, 6, 6);
ctx.Fill ();
}
QueueDrawArea ((int) x - 3, (int) y - 3, 6, 6);
}
示例2: BgBufferUpdate
public BgBufferUpdate (Minimpap mode)
{
this.mode = mode;
cr = Gdk.CairoHelper.Create (mode.backgroundBuffer);
cr.LineWidth = 1;
int w = mode.backgroundBuffer.ClipRegion.Clipbox.Width;
int h = mode.backgroundBuffer.ClipRegion.Clipbox.Height;
cr.Rectangle (0, 0, w, h);
if (mode.TextEditor.ColorStyle != null)
cr.Color = mode.TextEditor.ColorStyle.Default.CairoBackgroundColor;
cr.Fill ();
maxLine = mode.TextEditor.GetTextEditorData ().VisibleLineCount;
sx = w / (double)mode.TextEditor.Allocation.Width;
sy = Math.Min (1, lineHeight * maxLine / (double)mode.TextEditor.GetTextEditorData ().TotalHeight );
cr.Scale (sx, sy);
handler = GLib.Idle.Add (BgBufferUpdater);
}
示例3: OnWidgetDestroyed
private void OnWidgetDestroyed(object sender, EventArgs args)
{
if (!IsRealized) {
return;
}
// Copy the widget's pixels to surface, we'll use it to draw the animation
surface = Window.CreateSimilarSurface (Cairo.Content.ColorAlpha, widget_alloc.Width, widget_alloc.Height);
using (var cr = new Cairo.Context (surface)) {
Gdk.CairoHelper.SetSourceWindow (cr, Window, widget_alloc.X, widget_alloc.Y);
cr.Rectangle (0, 0, widget_alloc.Width, widget_alloc.Height);
cr.Fill ();
if (AnimationState != AnimationState.Going) {
WidgetDestroyed (this, args);
}
}
}
示例4: OnConfigured
void OnConfigured(object o, ConfigureEventArgs args)
{
pixmap = new Pixmap (args.Event.Window,
Allocation.Width,
Allocation.Height);
cairo = Gdk.CairoHelper.Create (pixmap);
cairo.Rectangle (0, 0,
Allocation.Width,
Allocation.Height);
cairo.Clip ();
ArrayList oldlist = points;
points = new ArrayList ();
ComputePositions ();
foreach (GraphPoint point in oldlist)
{
__AddGameInfo (point.info);
}
UpdatePixmap ();
}
示例5: CreateBitmap
internal static Gdk.Pixbuf CreateBitmap(string stockId, double width, double height, double scaleFactor)
{
Gdk.Pixbuf result = null;
Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault (stockId);
if (iconset != null) {
// Find the size that better fits the requested size
Gtk.IconSize gsize = Util.GetBestSizeFit (width);
result = iconset.RenderIcon (Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, gsize, null, null, scaleFactor);
if (result == null || result.Width < width * scaleFactor) {
var gsize2x = Util.GetBestSizeFit (width * scaleFactor, iconset.Sizes);
if (gsize2x != Gtk.IconSize.Invalid && gsize2x != gsize)
// Don't dispose the previous result since the icon is owned by the IconSet
result = iconset.RenderIcon (Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, gsize2x, null, null);
}
}
if (result == null && Gtk.IconTheme.Default.HasIcon (stockId))
result = Gtk.IconTheme.Default.LoadIcon (stockId, (int)width, (Gtk.IconLookupFlags)0);
if (result == null)
{
// render a custom gtk-missing-image icon
// if Gtk.Stock.MissingImage is not found
int w = (int)width;
int h = (int)height;
#if XWT_GTK3
Cairo.ImageSurface s = new Cairo.ImageSurface(Cairo.Format.ARGB32, w, h);
Cairo.Context cr = new Cairo.Context(s);
cr.SetSourceRGB(255, 255, 255);
cr.Rectangle(0, 0, w, h);
cr.Fill();
cr.SetSourceRGB(0, 0, 0);
cr.LineWidth = 1;
cr.Rectangle(0.5, 0.5, w - 1, h - 1);
cr.Stroke();
cr.SetSourceRGB(255, 0, 0);
cr.LineWidth = 3;
cr.LineCap = Cairo.LineCap.Round;
cr.LineJoin = Cairo.LineJoin.Round;
cr.MoveTo(w / 4, h / 4);
cr.LineTo((w - 1) - w / 4, (h - 1) - h / 4);
cr.MoveTo(w / 4, (h - 1) - h / 4);
cr.LineTo((w - 1) - w / 4, h / 4);
cr.Stroke();
result = Gtk3Extensions.GetFromSurface(s, 0, 0, w, h);
#else
using (Gdk.Pixmap pmap = new Gdk.Pixmap (Gdk.Screen.Default.RootWindow, w, h))
using (Gdk.GC gc = new Gdk.GC (pmap)) {
gc.RgbFgColor = new Gdk.Color (255, 255, 255);
pmap.DrawRectangle (gc, true, 0, 0, w, h);
gc.RgbFgColor = new Gdk.Color (0, 0, 0);
pmap.DrawRectangle (gc, false, 0, 0, (w - 1), (h - 1));
gc.SetLineAttributes (3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
gc.RgbFgColor = new Gdk.Color (255, 0, 0);
pmap.DrawLine (gc, (w / 4), (h / 4), ((w - 1) - (w / 4)), ((h - 1) - (h / 4)));
pmap.DrawLine (gc, ((w - 1) - (w / 4)), (h / 4), (w / 4), ((h - 1) - (h / 4)));
result = Gdk.Pixbuf.FromDrawable (pmap, pmap.Colormap, 0, 0, 0, 0, w, h);
}
#endif
}
return result;
}