public virtual void DrawAnnotation(Cairo.Context context, Cdn.AnnotationInfo info) { var uw = context.LineWidth; var alloc = AnnotationAllocation(1 / uw, context); alloc.Offset(-Allocation.X / uw, -Allocation.Y / uw); context.Save(); context.Scale(context.LineWidth, context.LineWidth); context.LineWidth = 1; context.Rectangle(alloc.X, alloc.Y, alloc.Width, alloc.Height); context.SetSourceRGBA(1, 1, 1, 0.75); context.Fill(); context.Rectangle(alloc.X + 2, alloc.Y + 2, alloc.Width - 4, alloc.Height - 4); context.SetSourceRGB(0.95, 0.95, 0.95); context.SetDash(new double[] { 5, 5 }, 0); context.Stroke(); Pango.Layout layout = Pango.CairoHelper.CreateLayout(context); Pango.CairoHelper.UpdateLayout(context, layout); layout.FontDescription = Settings.Font; layout.SetText(info.Text.Trim()); context.MoveTo(alloc.X + 2, alloc.Y + 2); context.SetSourceRGB(0.5, 0.5, 0.5); Pango.CairoHelper.ShowLayout(context, layout); context.Restore(); }
private void DrawingArea_OnDraw(object o, DrawnArgs args) { Widget widget = o as Widget; Cairo.Context cr = args.Cr; cr.SetSourceRGB(0.9, 0.9, 0.9); cr.Rectangle(0, 0, widget.Allocation.Width, widget.Allocation.Height); cr.Fill(); cr.SetSourceRGB(1.0, 1.0, 1.0); cr.Rectangle(5, 5, widget.Allocation.Width - 10, widget.Allocation.Height - 10); cr.Fill(); if (this.player != null) { if (this.player.IsLoop) { cr.SetSourceRGB(0.21, 0.517, 0.894); cr.Rectangle((int)((widget.Allocation.Width - 10) * ((double)this.player.LoopStart / player.TotalSamples)) + 5, 5, (int)((widget.Allocation.Width - 10) * ((double)(this.player.LoopEnd - this.player.LoopStart) / player.TotalSamples)), widget.Allocation.Height - 10); cr.Fill(); } cr.SetSourceRGB(0, 0, 0); cr.Rectangle(((widget.Allocation.Width - 10) * ((double)player.SamplePosition / player.TotalSamples)), 0, 10, widget.Allocation.Height); cr.Fill(); cr.SetSourceRGB(1.0, 1.0, 1.0); cr.Rectangle(((widget.Allocation.Width - 10) * ((double)player.SamplePosition / player.TotalSamples)) + 1, 1, 8, widget.Allocation.Height - 2); cr.Fill(); } }
/// <summary> /// Prints the data of the chart /// </summary> /// <param name="height">Height of drawing area.</param> /// <param name="width">Width of drawing area.</param> /// <param name="canvas">The cairo context.</param> void DrawData(int height, int width, Cairo.Context canvas) { double totalWidth = (XEnd - XStart); //If dont exist Custom Data Set, Default set wil be Draw. Boolean drawSetDefault = (GetSetCount() == 0); if (drawSetDefault) { int numBars = data["Default"].Count; int actualBar = 0; double XSetStart = XStart + PaddingSets; //double XSetEnd = XSetStart + maxWidthPerSet; double maxWidthPerBar = (totalWidth - (PaddingSets * 2)) / (double)(numBars); foreach (BarData bd in data["Default"]) { double altura = ((YEnd - YStart) * ((bd.Value - MinValue) / (MaxValue - MinValue))); Cairo.Rectangle rect = new Cairo.Rectangle(new Cairo.Point((int)(XSetStart + (maxWidthPerBar * actualBar) + maxWidthPerBar * 0.05), (int)YEnd), maxWidthPerBar * 0.9, -altura); canvas.Rectangle(rect); canvas.SetSourceRGB(ColorSets[bd.Name].R, ColorSets[bd.Name].G, ColorSets[bd.Name].B); canvas.Fill(); canvas.Stroke(); actualBar++; } return; } int Sets = GetSetCount(); double maxWidthPerSet = (totalWidth / (double)Sets); int actualSet = 0; foreach (String key in GetSetIds()) { if (key.Equals("Default")) { continue; } int numBars = data[key].Count; int actualBar = 0; double XSetStart = XStart + maxWidthPerSet * actualSet + PaddingSets; //double XSetEnd = XSetStart + maxWidthPerSet; double maxWidthPerBar = (maxWidthPerSet - (PaddingSets * 2)) / (double)(numBars); foreach (BarData bd in data[key]) { double altura = ((YEnd - YStart) * ((bd.Value - MinValue) / (MaxValue - MinValue))); Cairo.Rectangle rect = new Cairo.Rectangle(new Cairo.Point((int)(XSetStart + (maxWidthPerBar * actualBar) + maxWidthPerBar * 0.05), (int)YEnd), maxWidthPerBar * 0.9, -altura); canvas.Rectangle(rect); canvas.SetSourceRGB(ColorSets[bd.Name].R, ColorSets[bd.Name].G, ColorSets[bd.Name].B); canvas.Fill(); canvas.Stroke(); actualBar++; } actualSet++; } }
public void Render(Player player, List <Ball> balls, List <Monster> monsters) { Gdk.Window canvas = area.GdkWindow; if (canvas != null) { using (Cairo.Context context = Gdk.CairoHelper.Create(canvas)) { canvas.BeginPaintRegion(new Gdk.Region()); context.SetSourceSurface(background, 0, 0); context.Paint(); foreach (Field field in player.Trail) { paintTrail(context, field.X * fieldSize, field.Y * fieldSize); } foreach (Ball ball in balls) { context.SetSourceRGB(1, 0, 0); paintCircle(context, ball.X, ball.Y); } foreach (Monster monster in monsters) { paintMonster(context, monster); } context.SetSourceRGB(0, 0, 1); paintPlayer(context, player); canvas.EndPaint(); } } }
protected void paintMonster(Cairo.Context context, Monster monster) { switch (monster.Type) { case "Wanderer": context.SetSourceRGB(0, 1, 0); paintWanderer(context, monster); break; case "Sniffer": context.SetSourceRGB(1, 0, 1); paintSniffer(context, monster); break; case "Circulator": context.SetSourceRGB(0, 0, 0); paintCirculator(context, monster); break; default: context.SetSourceRGB(1, 1, 0); paintCircle(context, monster.X, monster.Y); break; } }
protected Gdk.Pixbuf DrawConstDataIcon() { using (var surface = new Cairo.ImageSurface(Cairo.Format.Argb32, rectSizing.Width, rectSizing.Height)) { using (Cairo.Context cr = new Cairo.Context(surface)) { // background cr.SetSourceRGB(0.7, 0.7, 0.7); cr.Paint(); // text cr.SetSourceRGB(1, 0, 0); // simple Cairo text API instead of Pango //cr.MoveTo (10, 0.3 * height); //cr.SetFontSize (20); //cr.ShowText ("const"); using (var layout = Pango.CairoHelper.CreateLayout(cr)) { // font size 12 seems suitable for iconHeight 48 pixels float fontSize = 12 * rectSizing.Height / 48f; layout.FontDescription = Pango.FontDescription.FromString("Sans " + fontSize.ToString()); layout.SetText("const"); layout.Width = rectSizing.Width; layout.Alignment = Pango.Alignment.Center; int lwidth, lheight; layout.GetPixelSize(out lwidth, out lheight); // 0, 0 = left top //cr.MoveTo (0.5 * (width - lwidth), 0.5 * (height - lheight)); cr.MoveTo(0.5 * rectSizing.Width, 0.5 * (rectSizing.Height - lheight)); Pango.CairoHelper.ShowLayout(cr, layout); } } return(new Gdk.Pixbuf(surface.Data, Gdk.Colorspace.Rgb, true, 8, rectSizing.Width, rectSizing.Height, surface.Stride, null)); } }
/// <summary> /// Creates a bitmap for each character in the font. /// Characters that the font does not include will not be assigned a bitmap. /// </summary> private void CreateBitmaps() { characters = new Dictionary <char, PixelSet>(); ImageSurface surface = new ImageSurface(Format.RGB24, 1, 1); Context context = new Context(surface); context.SelectFontFace(FontName, FontSlant.Normal, FontWeight.Normal); context.SetFontSize(Font.Size); TextExtents ext = context.TextExtents("@"); int charW = (int)Math.Ceiling(ext.Width); int charH = (int)Math.Ceiling(ext.Height); context.Dispose(); surface.Dispose(); surface = new ImageSurface(Format.RGB24, charW, charH); context = new Context(surface); PixelSet missingChar = null; for (int i = 0; i < asciiString.Length; i++) { // Render one character into a PixelSet string asciiChar = string.Empty + asciiString[i]; context.SelectFontFace(FontName, FontSlant.Normal, FontWeight.Normal); context.SetFontSize(Font.Size); context.SetSourceRGB(0.067, 0.067, 0.067); context.Paint(); context.SetSourceRGB(1, 1, 1); ext = context.TextExtents(asciiChar); context.MoveTo(ext.XBearing, ext.YBearing * -1); context.ShowText(asciiChar); PixelSet ch = new PixelSet(surface); // Filter out characters the font doesn't include // The first character is always unprintable, and serves as // a reference for what unprintable characters look like in this font if (i == 0) { missingChar = ch; continue; } else if (ch == missingChar) { continue; } characters.Add(asciiString[i], ch); } context.Dispose(); surface.Dispose(); // Add the space manually if it wasn't included if (!characters.ContainsKey(' ')) { var en = characters.Values.GetEnumerator(); en.MoveNext(); characters.Add(' ', new PixelSet(en.Current.Width, en.Current.Height)); } }
void ExposeIt() { if (!this.Visible) { return; } Gdk.GC gc = new Gdk.GC(this.GdkWindow); int w, h; this.GdkWindow.GetSize(out w, out h); /* * Gdk.Pixmap pixmap_mask; * Pixmap pixmap; * Gdk.Pixbuf pixbuf = Images.LeftPaneBackground; * pixbuf.RenderPixmapAndMask( out pixmap, out pixmap_mask, 255); * gc.Fill = Gdk.Fill.Tiled; * gc.Tile = pixmap; * this.GdkWindow.DrawRectangle (gc, true, 0, 0, 260, h); */ int posterW, posterH, posterX; if (Poster != null) { posterW = Poster.Width; posterH = Poster.Height; //Poster.RenderPixmapAndMask(out pixmap, out pixmap_mask, 255); } else { posterW = Images.NoPosterPixbuf.Width; posterH = Images.NoPosterPixbuf.Height; //Images.NoPosterPixbuf.RenderPixmapAndMask(out pixmap, out pixmap_mask, 255); } posterX = (260 - posterW) / 2; using (Cairo.Context cr = Gdk.CairoHelper.Create(this.GdkWindow)) { cr.SetSourceRGB(.87, .894, .9215); cr.Rectangle(0, 0, 259, h); cr.Fill(); cr.Rectangle(posterX - 2, 98, posterW + 4, posterH + 4); cr.SetSourceRGB(.7, .7, .7); cr.Fill(); cr.Rectangle(258, 0, 1, h); cr.Fill(); } this.GdkWindow.DrawPixbuf(gc, Poster ?? Images.NoPosterPixbuf, 0, 0, posterX, 100, posterW, posterH, RgbDither.Normal, 0, 0); image1.HeightRequest = posterH + 20; }
private void CheckerboardDrawn(object o, DrawnArgs args) { const int CheckSize = 10; const int Spacing = 2; Widget widget = o as Widget; Cairo.Context cr = args.Cr; int i, j, xcount, ycount; // At the start of a draw handler, a clip region has been set on // the Cairo context, and the contents have been cleared to the // widget's background color. Rectangle alloc = widget.Allocation; // Start redrawing the Checkerboard xcount = 0; i = Spacing; while (i < alloc.Width) { j = Spacing; ycount = xcount % 2; // start with even/odd depending on row while (j < alloc.Height) { if (ycount % 2 != 0) { cr.SetSourceRGB(0.45777, 0, 0.45777); } else { cr.SetSourceRGB(1, 1, 1); } // If we're outside the clip, this will do nothing. cr.Rectangle(i, j, CheckSize, CheckSize); cr.Fill(); j += CheckSize + Spacing; ++ycount; } i += CheckSize + Spacing; ++xcount; } // return true because we've handled this event, so no // further processing is required. args.RetVal = true; }
TimerApp() { win = new Window("Timer Example"); win.SetDefaultSize(260, 110); da = new DrawingArea(); // For DeleteEvent Observable.FromEventPattern <DeleteEventArgs>(win, "DeleteEvent") .Subscribe(delegate { Application.Quit(); }); // For Timer Observable.Interval(TimeSpan.FromSeconds(1)) .Subscribe(_ => { Gtk.Application.Invoke(delegate { da.QueueDraw(); }); }); // For DrawingArea event Observable.FromEventPattern <DrawnArgs>(da, "Drawn") .Subscribe(args => { Cairo.Context cr = args.EventArgs.Cr; cr.SetSourceRGB(0.5, 0.5, 0.5); cr.Paint(); cr.SetFontSize(48); cr.MoveTo(20, 68); string date = DateTime.Now.ToString("HH-mm-ss"); cr.SetSourceRGB(0.2, 0.23, 0.9); cr.ShowText(date); cr.Fill(); ((IDisposable)cr).Dispose(); args.EventArgs.RetVal = true; }); win.Add(da); win.ShowAll(); }
void OnExpose(object sender, ExposeEventArgs args) { DrawingArea area = (DrawingArea)sender; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); IcnRecode icn = new IcnRecode(project, 1920, 1080, (x, y, w, h, s) => { x *= scale; y *= scale; w *= scale; h *= scale; x += X; y += Y; w += X; h += Y; cr.Save(); cr.SetSourceRGB(0, 0, 0); cr.LineWidth = s * 0.7; cr.MoveTo(x, y); cr.LineTo(w, h); cr.ClosePath(); cr.Stroke(); cr.Restore(); }); icn.Exec(); cr.Dispose(); }
private void HandlePintaCoreActionsFileNewActivated(object sender, EventArgs e) { NewImageDialog dialog = new NewImageDialog (); dialog.ParentWindow = main_window.GdkWindow; dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent; int response = dialog.Run (); if (response == (int)Gtk.ResponseType.Ok) { PintaCore.Workspace.ImageSize = new Cairo.PointD (dialog.NewImageWidth, dialog.NewImageHeight); PintaCore.Workspace.CanvasSize = new Cairo.PointD (dialog.NewImageWidth, dialog.NewImageHeight); PintaCore.Layers.Clear (); PintaCore.History.Clear (); PintaCore.Layers.DestroySelectionLayer (); PintaCore.Layers.ResetSelectionPath (); // Start with an empty white layer Layer background = PintaCore.Layers.AddNewLayer ("Background"); using (Cairo.Context g = new Cairo.Context (background.Surface)) { g.SetSourceRGB (255, 255, 255); g.Paint (); } PintaCore.Workspace.Filename = "Untitled1"; PintaCore.Workspace.IsDirty = false; PintaCore.Actions.View.ZoomToWindow.Activate (); } dialog.Destroy (); }
void ClearSurface() { using (Cairo.Context ctx = new Cairo.Context(surface)) { ctx.SetSourceRGB(1, 1, 1); ctx.Paint(); } }
void ClearSurface () { using (Cairo.Context ctx = new Cairo.Context (surface)) { ctx.SetSourceRGB (1, 1, 1); ctx.Paint (); } }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow)) { cr.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); cr.ClipPreserve(); cr.SetSourceRGB(1.00, 0.98, 0.91); cr.FillPreserve(); cr.SetSourceRGB(0.87, 0.83, 0.74); cr.LineWidth = 2; cr.Stroke(); } return(base.OnExposeEvent(evnt)); }
private void ExposeIt() { Gdk.GC gc = new Gdk.GC(this.GdkWindow); int w, h; this.GdkWindow.GetSize(out w, out h); Gdk.Pixmap pixmap_mask; Pixmap pixmap; Gdk.Pixbuf pixbuf = Images.DialogBackground; pixbuf.RenderPixmapAndMask(out pixmap, out pixmap_mask, 255); gc.Fill = Gdk.Fill.Tiled; gc.Tile = pixmap; this.GdkWindow.DrawRectangle(gc, true, 0, 0, Images.DialogBackground.Width, h - 41); if (Poster != null) { Rectangle posterBounds = new Rectangle((Poster.Width - 272) / 2, 10, Poster.Width, Poster.Height); using (Cairo.Context cr = Gdk.CairoHelper.Create(this.GdkWindow)) { cr.SetSourceRGB(.7, .7, .7); cr.Rectangle(posterBounds.X - 2, posterBounds.Y - 2, posterBounds.Width + 4, posterBounds.Height + 4); cr.Fill(); } this.GdkWindow.DrawPixbuf(gc, Poster, 0, 0, posterBounds.X, posterBounds.Y, posterBounds.Width, posterBounds.Height, RgbDither.Normal, 0, 0); } }
// Render the dirtied window void OnExpose(object sender, ExposeEventArgs args) { DrawingArea area = (DrawingArea)sender; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); // Clear background cr.SetSourceRGB(1.0, 1.0, 1.0); cr.Paint(); // Set the coordinate system origin at bottom left cr.Translate(0, area.Allocation.Height); cr.Scale(1.0, -1.0); // Render all Drawables, resetting the coordinate transform for each foreach (Drawable d in drawable) { cr.Save(); d.Draw(cr); cr.Restore(); } cr.GetTarget().Dispose(); ((IDisposable)cr).Dispose(); }
void DrawAlphaBetaMarker(Cairo.Context c, ref Cairo.PointD bottomRight, string text) { c.SelectFontFace(SplashFontFamily, Cairo.FontSlant.Normal, Cairo.FontWeight.Bold); c.SetFontSize(SplashFontSize); // Create a rectangle larger than the text so we can have a nice border // And round the value so we don't have a blurry rectangle. var extents = c.TextExtents(text); var x = Math.Round(bottomRight.X - extents.Width * 1.3); var y = Math.Round(bottomRight.Y - extents.Height * 2.8); var rectangle = new Cairo.Rectangle(x, y, bottomRight.X - x, bottomRight.Y - y); // Draw the background color the text will be overlaid on DrawRectangle(c, rectangle); // Calculate the offset the text will need to be at to be centralised // in the border x = x + extents.XBearing + (rectangle.Width - extents.Width) / 2; y = y - extents.YBearing + (rectangle.Height - extents.Height) / 2; c.MoveTo(x, y); // Draw the text c.SetSourceRGB(1, 1, 1); c.ShowText(text); bottomRight.Y -= rectangle.Height - 2; }
private void OnExpose(object sender, ExposeEventArgs args) { DrawingArea area = (DrawingArea)sender; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); cr.LineWidth = 2; cr.SetSourceRGB(0.7, 0.2, 0.0); }
private void OnExpose(object obj, Gtk.ExposeEventArgs args) { Gtk.DrawingArea area = (Gtk.DrawingArea)obj; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); int width, height; width = Allocation.Width; height = Allocation.Height; double radius = Math.Min(width, height) / 4; //draw face cr.Arc(width / 2, height / 2, radius, 0, 2 * Math.PI); cr.StrokePreserve(); cr.SetSourceRGB(0, 0, 0); cr.Fill(); //draw hands double hoursHandSize = 0.35 * radius; double minutesHandSize = 0.5 * radius; double secondsHandSize = 0.75 * radius; double x = width / 2; double y = height / 2; cr.LineWidth = 2 * cr.LineWidth; cr.SetSourceRGB(0, 255, 0); cr.MoveTo(x, y); cr.LineTo(x + hoursHandSize * Math.Cos(ToRadian(hoursHand)), y + hoursHandSize * Math.Sin(ToRadian(hoursHand))); cr.Stroke(); cr.MoveTo(x, y); cr.LineTo(x + minutesHandSize * Math.Cos(ToRadian(minutesHand)), y + minutesHandSize * Math.Sin(ToRadian(minutesHand))); cr.Stroke(); cr.LineWidth = 0.25 * cr.LineWidth; cr.SetSourceRGB(255, 0, 0); cr.MoveTo(x, y); cr.LineTo(x + secondsHandSize * Math.Cos(ToRadian(secondsHand)), y + secondsHandSize * Math.Sin(ToRadian(secondsHand))); cr.Stroke(); ((IDisposable)cr.Target).Dispose(); ((IDisposable)cr).Dispose(); }
void HandleActionAreahandleExposeEvent(object o, ExposeEventArgs args) { return; int w, h; this.ActionArea.GdkWindow.GetSize(out w, out h); using (Cairo.Context cr = Gdk.CairoHelper.Create(this.ActionArea.GdkWindow)) { cr.Rectangle(0, h - 51, w, 1); cr.SetSourceRGB(.5, .5, .5); cr.Fill(); cr.Rectangle(0, h - 50, w, 50); cr.SetSourceRGB(1, 1, 1); cr.Fill(); } }
protected override bool OnDrawn(Cairo.Context cr) { cr.Save(); cr.SetSourceRGB(0.0, 0.0, 0.0); cr.Rectangle(0, 0, Allocation.Width, Allocation.Height); cr.Fill(); cr.Restore(); return(base.OnDrawn(cr)); }
/* * public override void SetSelColor() * { * Stroke = new SolidColorBrush(Properties.Settings.Default.Overlay_CoordSelColor); * } * public override void SetStdColor() * { * Stroke = new SolidColorBrush(Properties.Settings.Default.Overlay_CoordColor); * } */ /// <summary> /// Draw an X /// </summary> /// <param name="dc"></param> public override void Draw(Cairo.Context dc) { Pen p = IsSelected ? SelPen : StdPen; Rect lBB = GetBB(Parent.Height); dc.SetSourceRGB(1, 0, 0); // todo dc.DrawLine(lBB.TopLeft, lBB.BottomRight); dc.DrawLine(lBB.BottomLeft, lBB.TopRight); }
protected void placeShapes() { if (_surface != null) { drawingArea.GdkWindow.Clear(); _surface.Dispose(); _surface = null; } _min = Vertex.CreateMax(); _max = Vertex.CreateMin(); foreach (AbstractShape shape in _shapes) { _min.Minimize(shape.Min); _max.Maximize(shape.Max); log("фигура {0} расположена на позиции от {1} до {2}", shape, shape.Min.Literal, shape.Max.Literal); } _min -= _lineWidthGap; _max += _lineWidthGap; _logicCanvasSize = _max - _min; log("размер логического холста (с учётом толщины линий) - {0}", _logicCanvasSize.Literal); _logicCanvasSize *= _prescale; _surface = new Cairo.ImageSurface(Cairo.Format.Argb32, ( int )_logicCanvasSize.X, ( int )_logicCanvasSize.Y); using (var surfaceContext = new Cairo.Context(_surface)) { surfaceContext.SetSourceRGB(1.0, 1.0, 1.0); surfaceContext.Paint(); surfaceContext.LineWidth = 1.0; surfaceContext.SetSourceRGB(.0, .0, .0); surfaceContext.Scale(_prescale, -_prescale); surfaceContext.Translate(-_min.X, -_max.Y); if (null != _shapes && 0 < _shapes.Count) { foreach (AbstractShape shape in _shapes) { shape.Draw(surfaceContext); surfaceContext.Stroke(); } } } }
public override void Draw(Cairo.Context ctx, Vector3 origin, Graphics.Camera camera) { // just draw a circle var pos = camera.Transform(this.position) - camera.Transform(origin); var cl = this.color; ctx.SetSourceRGB(cl.x, cl.y, cl.z); ctx.Arc(pos.x, pos.y, this.radius, 0, 2 * Math.PI); ctx.Fill(); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { using (Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow)) { cr.Rectangle(Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); cr.SetSourceRGB(1.0, 0.98, 0.91); cr.Fill(); } return(base.OnExposeEvent(evnt)); }
protected void paintTrail(Cairo.Context context, int x, int y) { context.Save(); context.SetSourceRGB(0, 1, 0); context.Translate(x, y); context.Rectangle(new Cairo.Rectangle(0, 0, fieldSize, fieldSize)); context.SetSourceRGBA(0, 1, 0, 0.3); context.FillPreserve(); context.NewPath(); context.Restore(); }
public static void DrawCircle(DrawingArea da, int width, int height, double lineWidth, double[] lineColor, double[] fillColor, Position position, double size) { Cairo.Context cr = Gdk.CairoHelper.Create(da.GdkWindow); cr.SetSourceRGB(lineColor[0], lineColor[1], lineColor[2]); cr.LineWidth = lineWidth; cr.Translate(position.x * width, position.y * height); cr.Arc(0, 0, size * width / 100f, 0, 2 * Math.PI); cr.StrokePreserve(); cr.SetSourceRGB(fillColor[0], fillColor[1], fillColor[2]); cr.Fill(); ((IDisposable)cr.GetTarget()).Dispose(); ((IDisposable)cr).Dispose(); }
protected void paintSquare(Cairo.Context context, int x, int y, bool fill) { context.Save(); context.SetSourceRGB(0, 0, 1); context.Translate(x, y); context.Rectangle(new Cairo.Rectangle(0, 0, fieldSize, fieldSize)); context.SetSourceRGBA(0, 0, 0, fill ? 0.5 : 0.3); context.FillPreserve(); context.NewPath(); context.Restore(); }
void DrawRectangle(Cairo.Context c, Cairo.Rectangle rect) { double x = rect.X; double y = rect.Y; double width = rect.Width; double height = rect.Height; c.Rectangle(x, y, width, height); c.SetSourceRGB(0, 0, 0); c.Fill(); }
private void SetColor(Cairo.Context graphics, double[] color) { if (color.Length == 3) { graphics.SetSourceRGB(color[0], color[1], color[2]); } else { graphics.SetSourceRGBA(color[0], color[1], color[2], color[3]); } }
void DrawCodeSegmentBorder(Gdk.GC gc, Cairo.Context ctx, double x, int width, BlockInfo firstBlock, BlockInfo lastBlock, string[] lines, Gtk.Widget widget, Gdk.Drawable window) { int shadowSize = 2; int spacing = 4; int bottomSpacing = (lineHeight - spacing) / 2; ctx.Rectangle(x + shadowSize + 0.5, firstBlock.YStart + bottomSpacing + spacing - shadowSize + 0.5, width - shadowSize * 2, shadowSize); ctx.SetSourceRGB(0.9, 0.9, 0.9); ctx.LineWidth = 1; ctx.Fill(); ctx.Rectangle(x + shadowSize + 0.5, lastBlock.YEnd + bottomSpacing + 0.5, width - shadowSize * 2, shadowSize); ctx.SetSourceRGB(0.9, 0.9, 0.9); ctx.Fill(); ctx.Rectangle(x + 0.5, firstBlock.YStart + bottomSpacing + spacing + 0.5, width, lastBlock.YEnd - firstBlock.YStart - spacing); ctx.SetSourceRGB(0.7, 0.7, 0.7); ctx.Stroke(); string text = lines[firstBlock.FirstLine].Replace("@", "").Replace("-", ""); text = "<span size='x-small'>" + text.Replace("+", "</span><span size='small'>➜</span><span size='x-small'> ") + "</span>"; layout.SetText(""); layout.SetMarkup(text); int tw, th; layout.GetPixelSize(out tw, out th); th--; int dy = (lineHeight - th) / 2; ctx.Rectangle(x + 2 + LeftPaddingBlock - 1 + 0.5, firstBlock.YStart + dy - 1 + 0.5, tw + 2, th + 2); ctx.LineWidth = 1; ctx.SetSourceColor(widget.Style.Base(StateType.Normal).ToCairoColor()); ctx.FillPreserve(); ctx.SetSourceRGB(0.7, 0.7, 0.7); ctx.Stroke(); window.DrawLayout(gc, (int)(x + 2 + LeftPaddingBlock), firstBlock.YStart + dy, layout); }
public void NewFile(Size imageSize) { PintaCore.Workspace.ActiveDocument.HasFile = false; PintaCore.Workspace.ImageSize = imageSize; PintaCore.Workspace.CanvasSize = imageSize; PintaCore.Layers.Clear (); PintaCore.History.Clear (); PintaCore.Layers.DestroySelectionLayer (); PintaCore.Layers.ResetSelectionPath (); // Start with an empty white layer Layer background = PintaCore.Layers.AddNewLayer (Catalog.GetString ("Background")); using (Cairo.Context g = new Cairo.Context (background.Surface)) { g.SetSourceRGB (255, 255, 255); g.Paint (); } PintaCore.Workspace.Filename = "Untitled1"; PintaCore.History.PushNewItem (new BaseHistoryItem (Stock.New, Catalog.GetString ("New Image"))); PintaCore.Workspace.IsDirty = false; PintaCore.Actions.View.ZoomToWindow.Activate (); }
protected Gdk.Pixbuf DrawConstDataIcon() { using (var surface = new Cairo.ImageSurface (Cairo.Format.Argb32, rectSizing.Width, rectSizing.Height)) { using (Cairo.Context cr = new Cairo.Context (surface)) { // background cr.SetSourceRGB (0.7, 0.7, 0.7); cr.Paint (); // text cr.SetSourceRGB (1, 0, 0); // simple Cairo text API instead of Pango //cr.MoveTo (10, 0.3 * height); //cr.SetFontSize (20); //cr.ShowText ("const"); using (var layout = Pango.CairoHelper.CreateLayout (cr)) { // font size 12 seems suitable for iconHeight 48 pixels float fontSize = 12 * rectSizing.Height / 48f; layout.FontDescription = Pango.FontDescription.FromString ("Sans " + fontSize.ToString ()); layout.SetText ("const"); layout.Width = rectSizing.Width; layout.Alignment = Pango.Alignment.Center; int lwidth, lheight; layout.GetPixelSize (out lwidth, out lheight); // 0, 0 = left top //cr.MoveTo (0.5 * (width - lwidth), 0.5 * (height - lheight)); cr.MoveTo (0.5 * rectSizing.Width, 0.5 * (rectSizing.Height - lheight)); Pango.CairoHelper.ShowLayout (cr, layout); } } return new Gdk.Pixbuf (surface.Data, Gdk.Colorspace.Rgb, true, 8, rectSizing.Width, rectSizing.Height, surface.Stride, null); } }
// Create a new surface of the appropriate size to store our scribbles private void ScribbleConfigure(object o, ConfigureEventArgs args) { Widget widget = o as Widget; if (surface != null) surface.Destroy (); var allocation = widget.Allocation; surface = widget.Window.CreateSimilarSurface (Cairo.Content.Color, allocation.Width, allocation.Height); var cr = new Cairo.Context (surface); cr.SetSourceRGB (1, 1, 1); cr.Paint (); ((IDisposable)cr).Dispose (); // We've handled the configure event, no need for further processing. args.RetVal = true; }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); Requisition req = new Requisition (); req.Height = 600; req.Width = 800; drawingarea1.Requisition = req; // Initialize interface things PintaCore.Actions.AccelGroup = new AccelGroup (); this.AddAccelGroup (PintaCore.Actions.AccelGroup); PintaCore.Initialize (tooltoolbar, label5, drawingarea1, treeview1, this); colorpalettewidget1.Initialize (); PintaCore.Chrome.StatusBarTextChanged += new EventHandler<TextChangedEventArgs> (Chrome_StatusBarTextChanged); PintaCore.History.HistoryItemAdded += new EventHandler<HistoryItemAddedEventArgs> (History_HistoryItemAdded); PintaCore.History.HistoryItemRemoved += new EventHandler<HistoryItemRemovedEventArgs> (History_HistoryItemRemoved); PintaCore.Workspace.CanvasInvalidated += new EventHandler<CanvasInvalidatedEventArgs> (Workspace_CanvasInvalidated); PintaCore.Workspace.CanvasSizeChanged += new EventHandler (Workspace_CanvasSizeChanged); CreateToolBox (); PintaCore.Actions.CreateMainMenu (menubar1); PintaCore.Actions.CreateToolBar (toolbar1); PintaCore.Actions.Layers.CreateLayerWindowToolBar (toolbar4); PintaCore.Actions.Edit.CreateHistoryWindowToolBar (toolbar2); Gtk.Image i = new Gtk.Image (PintaCore.Resources.GetIcon ("StatusBar.CursorXY.png")); i.Show (); statusbar1.Add (i); Gtk.Box.BoxChild box = (Gtk.Box.BoxChild)statusbar1[i]; box.Position = 2; box.Fill = false; box.Expand = false; this.Icon = PintaCore.Resources.GetIcon ("Pinta.png"); dialog_handler = new DialogHandlers (this); // Create a blank document Layer background = PintaCore.Layers.AddNewLayer ("Background"); using (Cairo.Context g = new Cairo.Context (background.Surface)) { g.SetSourceRGB (255, 255, 255); g.Paint (); } PintaCore.Workspace.Filename = "Untitled1"; PintaCore.Workspace.IsDirty = false; PintaCore.Workspace.Invalidate (); treeview1.Model = new ListStore (typeof (Pixbuf), typeof (string)); treeview1.HeadersVisible = false; treeview1.RowActivated += HandleTreeview1RowActivated; AddColumns (treeview1); PintaCore.Actions.View.ZoomToWindow.Activated += new EventHandler (ZoomToWindow_Activated); DeleteEvent += new DeleteEventHandler (MainWindow_DeleteEvent); EffectsAction.Visible = false; WindowAction.Visible = false; }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); Requisition req = new Requisition (); req.Height = 600; req.Width = 800; drawingarea1.Requisition = req; // Initialize interface things PintaCore.Actions.AccelGroup = new AccelGroup (); this.AddAccelGroup (PintaCore.Actions.AccelGroup); progress_dialog = new ProgressDialog (); PintaCore.Initialize (tooltoolbar, label5, drawingarea1, history_treeview, this, progress_dialog, (Gtk.Viewport)table1.Parent); colorpalettewidget1.Initialize (); PintaCore.Chrome.StatusBarTextChanged += new EventHandler<TextChangedEventArgs> (Chrome_StatusBarTextChanged); PintaCore.Workspace.CanvasInvalidated += new EventHandler<CanvasInvalidatedEventArgs> (Workspace_CanvasInvalidated); PintaCore.Workspace.CanvasSizeChanged += new EventHandler (Workspace_CanvasSizeChanged); CreateToolBox (); PintaCore.Actions.CreateMainMenu (menubar1); PintaCore.Actions.CreateToolBar (toolbar1); PintaCore.Actions.Layers.CreateLayerWindowToolBar (toolbar4); PintaCore.Actions.Edit.CreateHistoryWindowToolBar (toolbar2); Gtk.Image i = new Gtk.Image (PintaCore.Resources.GetIcon ("StatusBar.CursorXY.png")); i.Show (); statusbar1.Add (i); Gtk.Box.BoxChild box = (Gtk.Box.BoxChild)statusbar1[i]; box.Position = 2; box.Fill = false; box.Expand = false; this.Icon = PintaCore.Resources.GetIcon ("Pinta.png"); dialog_handler = new DialogHandlers (this); // Create a blank document Layer background = PintaCore.Layers.AddNewLayer ("Background"); using (Cairo.Context g = new Cairo.Context (background.Surface)) { g.SetSourceRGB (255, 255, 255); g.Paint (); } PintaCore.Workspace.Filename = "Untitled1"; PintaCore.History.PushNewItem (new BaseHistoryItem ("gtk-new", "New Image")); PintaCore.Workspace.IsDirty = false; PintaCore.Workspace.Invalidate (); //History history_treeview.Model = PintaCore.History.ListStore; history_treeview.HeadersVisible = false; history_treeview.Selection.Mode = SelectionMode.Single; history_treeview.Selection.SelectFunction = HistoryItemSelected; Gtk.TreeViewColumn icon_column = new Gtk.TreeViewColumn (); Gtk.CellRendererPixbuf icon_cell = new Gtk.CellRendererPixbuf (); icon_column.PackStart (icon_cell, true); Gtk.TreeViewColumn text_column = new Gtk.TreeViewColumn (); Gtk.CellRendererText text_cell = new Gtk.CellRendererText (); text_column.PackStart (text_cell, true); text_column.SetCellDataFunc (text_cell, new Gtk.TreeCellDataFunc (HistoryRenderText)); icon_column.SetCellDataFunc (icon_cell, new Gtk.TreeCellDataFunc (HistoryRenderIcon)); history_treeview.AppendColumn (icon_column); history_treeview.AppendColumn (text_column); PintaCore.History.HistoryItemAdded += new EventHandler<HistoryItemAddedEventArgs> (OnHistoryItemsChanged); PintaCore.History.ActionUndone += new EventHandler (OnHistoryItemsChanged); PintaCore.History.ActionRedone += new EventHandler (OnHistoryItemsChanged); PintaCore.Actions.View.ZoomToWindow.Activated += new EventHandler (ZoomToWindow_Activated); DeleteEvent += new DeleteEventHandler (MainWindow_DeleteEvent); PintaCore.LivePreview.RenderUpdated += LivePreview_RenderUpdated; WindowAction.Visible = false; hruler = new HRuler (); hruler.Metric = MetricType.Pixels; table1.Attach (hruler, 1, 2, 0, 1, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); vruler = new VRuler (); vruler.Metric = MetricType.Pixels; table1.Attach (vruler, 0, 1, 1, 2, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); UpdateRulerRange (); PintaCore.Actions.View.ZoomComboBox.ComboBox.Changed += HandlePintaCoreActionsViewZoomComboBoxComboBoxChanged; gr = new GridRenderer (cr); if (Platform.GetOS () == Platform.OS.Mac) { try { //enable the global key handler for keyboard shortcuts IgeMacMenu.GlobalKeyHandlerEnabled = true; //Tell the IGE library to use your GTK menu as the Mac main menu IgeMacMenu.MenuBar = menubar1; /* //tell IGE which menu item should be used for the app menu's quit item IgeMacMenu.QuitMenuItem = yourQuitMenuItem; */ //add a new group to the app menu, and add some items to it var appGroup = IgeMacMenu.AddAppMenuGroup (); MenuItem aboutItem = (MenuItem)PintaCore.Actions.Help.About.CreateMenuItem (); appGroup.AddMenuItem (aboutItem, Mono.Unix.Catalog.GetString ("About")); menubar1.Hide (); } catch { // If things don't work out, just use a normal menu. } } }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); Requisition req = new Requisition (); req.Height = 600; req.Width = 800; drawingarea1.Requisition = req; // Initialize interface things PintaCore.Actions.AccelGroup = new AccelGroup (); this.AddAccelGroup (PintaCore.Actions.AccelGroup); PintaCore.Initialize (tooltoolbar, label5, drawingarea1, treeview1, this); colorpalettewidget1.Initialize (); PintaCore.Chrome.StatusBarTextChanged += new EventHandler<TextChangedEventArgs> (Chrome_StatusBarTextChanged); PintaCore.History.HistoryItemAdded += new EventHandler<HistoryItemAddedEventArgs> (History_HistoryItemAdded); PintaCore.History.HistoryItemRemoved += new EventHandler<HistoryItemRemovedEventArgs> (History_HistoryItemRemoved); PintaCore.Workspace.CanvasInvalidated += new EventHandler<CanvasInvalidatedEventArgs> (Workspace_CanvasInvalidated); PintaCore.Workspace.CanvasSizeChanged += new EventHandler (Workspace_CanvasSizeChanged); CreateToolBox (); PintaCore.Actions.CreateMainMenu (menubar1); PintaCore.Actions.CreateToolBar (toolbar1); PintaCore.Actions.Layers.CreateLayerWindowToolBar (toolbar4); PintaCore.Actions.Edit.CreateHistoryWindowToolBar (toolbar2); Gtk.Image i = new Gtk.Image (PintaCore.Resources.GetIcon ("StatusBar.CursorXY.png")); i.Show (); statusbar1.Add (i); Gtk.Box.BoxChild box = (Gtk.Box.BoxChild)statusbar1[i]; box.Position = 2; box.Fill = false; box.Expand = false; this.Icon = PintaCore.Resources.GetIcon ("Pinta.png"); dialog_handler = new DialogHandlers (this); // Create a blank document Layer background = PintaCore.Layers.AddNewLayer ("Background"); using (Cairo.Context g = new Cairo.Context (background.Surface)) { g.SetSourceRGB (255, 255, 255); g.Paint (); } PintaCore.Workspace.Filename = "Untitled1"; PintaCore.Workspace.IsDirty = false; PintaCore.Workspace.Invalidate (); treeview1.Model = new ListStore (typeof (Pixbuf), typeof (string)); treeview1.HeadersVisible = false; treeview1.RowActivated += HandleTreeview1RowActivated; AddColumns (treeview1); PintaCore.Actions.View.ZoomToWindow.Activated += new EventHandler (ZoomToWindow_Activated); DeleteEvent += new DeleteEventHandler (MainWindow_DeleteEvent); WindowAction.Visible = false; if (Platform.GetOS () == Platform.OS.Mac) { try { //enable the global key handler for keyboard shortcuts IgeMacMenu.GlobalKeyHandlerEnabled = true; //Tell the IGE library to use your GTK menu as the Mac main menu IgeMacMenu.MenuBar = menubar1; /* //tell IGE which menu item should be used for the app menu's quit item IgeMacMenu.QuitMenuItem = yourQuitMenuItem; */ //add a new group to the app menu, and add some items to it var appGroup = IgeMacMenu.AddAppMenuGroup(); MenuItem aboutItem = (MenuItem) PintaCore.Actions.Help.About.CreateMenuItem(); appGroup.AddMenuItem(aboutItem, Mono.Unix.Catalog.GetString ("About")); menubar1.Hide(); } catch { // If things don't work out, just use a normal menu. } } }
/// <summary> /// Draws the text. /// </summary> /// <param name="showCursor">Whether or not to show the mouse cursor in the drawing.</param> /// <param name="useTextLayer">Whether or not to use the TextLayer (as opposed to the Userlayer).</param> private void RedrawText(bool showCursor, bool useTextLayer) { Rectangle r = CurrentTextEngine.GetLayoutBounds(); r.Inflate(10 + OutlineWidth, 10 + OutlineWidth); CurrentTextBounds = r; Rectangle cursorBounds = Rectangle.Zero; Cairo.ImageSurface surf; if (!useTextLayer) { //Draw text on the current UserLayer's surface as finalized text. surf = PintaCore.Workspace.ActiveDocument.CurrentUserLayer.Surface; } else { //Draw text on the current UserLayer's TextLayer's surface as re-editable text. surf = PintaCore.Workspace.ActiveDocument.CurrentUserLayer.TextLayer.Surface; ClearTextLayer(); } using (var g = new Cairo.Context (surf)) { g.Save (); // Show selection if on text layer if (useTextLayer) { // Selected Text Cairo.Color c = new Cairo.Color (0.7, 0.8, 0.9, 0.5); foreach (Rectangle rect in CurrentTextEngine.SelectionRectangles) g.FillRectangle (rect.ToCairoRectangle (), c); } g.AppendPath (PintaCore.Workspace.ActiveDocument.Selection.SelectionPath); g.FillRule = Cairo.FillRule.EvenOdd; g.Clip (); g.MoveTo (new Cairo.PointD (CurrentTextEngine.Origin.X, CurrentTextEngine.Origin.Y)); g.SetSourceRGBA (PintaCore.Palette.PrimaryColor); //Fill in background if (BackgroundFill) { using (var g2 = new Cairo.Context (surf)) { g2.FillRectangle(CurrentTextEngine.GetLayoutBounds().ToCairoRectangle(), PintaCore.Palette.SecondaryColor); } } // Draw the text if (FillText) Pango.CairoHelper.ShowLayout (g, CurrentTextEngine.Layout); if (FillText && StrokeText) { g.SetSourceRGBA (PintaCore.Palette.SecondaryColor); g.LineWidth = OutlineWidth; Pango.CairoHelper.LayoutPath (g, CurrentTextEngine.Layout); g.Stroke (); } else if (StrokeText) { g.SetSourceRGBA (PintaCore.Palette.PrimaryColor); g.LineWidth = OutlineWidth; Pango.CairoHelper.LayoutPath (g, CurrentTextEngine.Layout); g.Stroke (); } if (showCursor) { var loc = CurrentTextEngine.GetCursorLocation (); g.Antialias = Cairo.Antialias.None; g.DrawLine (new Cairo.PointD (loc.X, loc.Y), new Cairo.PointD (loc.X, loc.Y + loc.Height), new Cairo.Color (0, 0, 0, 1), 1); cursorBounds = Rectangle.Inflate (loc, 2, 10); } g.Restore (); if (useTextLayer && (is_editing || ctrlKey) && !CurrentTextEngine.IsEmpty()) { //Draw the text edit rectangle. g.Save(); g.Translate(.5, .5); using (Cairo.Path p = g.CreateRectanglePath(new Cairo.Rectangle(CurrentTextBounds.Left, CurrentTextBounds.Top, CurrentTextBounds.Width, CurrentTextBounds.Height - FontSize))) { g.AppendPath(p); } g.LineWidth = 1; g.SetSourceRGB (1, 1, 1); g.StrokePreserve(); g.SetDash(new double[] { 2, 4 }, 0); g.SetSourceRGB (1, .1, .2); g.Stroke(); g.Restore(); } } InflateAndInvalidate(PintaCore.Workspace.ActiveDocument.CurrentUserLayer.previousTextBounds); PintaCore.Workspace.Invalidate(old_cursor_bounds); PintaCore.Workspace.Invalidate(r); PintaCore.Workspace.Invalidate(cursorBounds); old_cursor_bounds = cursorBounds; }
public void NewFile(Size imageSize) { PintaCore.Workspace.CreateAndActivateDocument (null, imageSize); PintaCore.Workspace.ActiveDocument.HasFile = false; PintaCore.Workspace.ActiveWorkspace.CanvasSize = imageSize; // Start with an empty white layer Layer background = PintaCore.Workspace.ActiveDocument.AddNewLayer (Catalog.GetString ("Background")); using (Cairo.Context g = new Cairo.Context (background.Surface)) { g.SetSourceRGB (1, 1, 1); g.Paint (); } PintaCore.Workspace.ActiveWorkspace.History.PushNewItem (new BaseHistoryItem (Stock.New, Catalog.GetString ("New Image"))); PintaCore.Workspace.ActiveDocument.IsDirty = false; PintaCore.Actions.View.ZoomToWindow.Activate (); }
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; }