private void dibujar_grilla(DrawingArea area, Cairo.Context cr) { for (int x = 0; x < Constantes.nro_casillas; x++) { int x0 = Logica.grilla.get_casillero(x, 0).inicioX; cr.Save(); cr.LineWidth = 0.5; cr.SetSourceRGBA(0, 0, 0, 0.5); cr.MoveTo(x0, 0); cr.LineTo(x0, Constantes.limites.Height); cr.Stroke(); cr.Restore(); } for (int y = 0; y < Constantes.nro_casillas; y++) { int y0 = Logica.grilla.get_casillero(0, y).inicioY; cr.Save(); cr.LineWidth = 0.5; cr.SetSourceRGBA(0, 0, 0, 0.5); cr.MoveTo(0, y0); cr.LineTo(Constantes.limites.Width, y0); cr.Stroke(); cr.Restore(); } }
public override void Draw(Context context) { SetupLayout(context); RectangleD displayBox = DisplayBox; displayBox.OffsetDot5(); double side = 10.0; context.LineWidth = LineWidth; context.Save (); //Box context.MoveTo (displayBox.X, displayBox.Y); context.LineTo (displayBox.X, displayBox.Y + displayBox.Height); context.LineTo (displayBox.X + displayBox.Width, displayBox.Y + displayBox.Height); context.LineTo (displayBox.X + displayBox.Width, displayBox.Y + side); context.LineTo (displayBox.X + displayBox.Width - side, displayBox.Y); context.LineTo (displayBox.X, displayBox.Y); context.Save (); //Triangle context.MoveTo (displayBox.X + displayBox.Width - side, displayBox.Y); context.LineTo (displayBox.X + displayBox.Width - side, displayBox.Y + side); context.LineTo (displayBox.X + displayBox.Width, displayBox.Y + side); context.LineTo (displayBox.X + displayBox.Width - side, displayBox.Y); context.Restore (); context.Color = FillColor; context.FillPreserve (); context.Color = LineColor; context.Stroke (); DrawText (context); }
protected void DrawBackground(Cairo.Context cr) { var totalRect = GetTotalBounds(); cr.SetSourceColor(BackgroundColor); cr.Rectangle(totalRect.X, totalRect.Y, totalRect.Width, totalRect.Height); cr.Fill(); cr.Save(); cr.Translate(XOffset, YOffset); cr.Scale(Scale, Scale); if (Surface != null) { cr.SetSource(Surface, 0, 0); using (SurfacePattern pattern = (SurfacePattern)cr.GetSource()) { pattern.Filter = Filter.Nearest; } cr.Paint(); } else if (Image != null) { using (Surface source = new BitmapSurface(Image)) { cr.SetSource(source, 0, 0); using (SurfacePattern pattern = (SurfacePattern)cr.GetSource()) { pattern.Filter = Filter.Nearest; } cr.Paint(); } } else { Cairo.Rectangle extents = cr.ClipExtents(); for (int i = 0; i < Width * Height; i++) { int tileX = i % Width; int tileY = i / Width; Cairo.Rectangle rect = GetTileRectWithPadding(tileX, tileY, scale: false, offset: false); if (!CairoHelper.RectsOverlap(extents, rect)) { continue; } cr.Save(); cr.Translate(rect.X + TilePaddingX, rect.Y + TilePaddingY); cr.Rectangle(0, 0, TileWidth, TileHeight); cr.Clip(); TileDrawer(i, cr); cr.Restore(); } } cr.Restore(); // Undo scale, offset }
protected override void OnDrawContent(Gdk.EventExpose evnt, Cairo.Context g) { Theme.BorderColor = marker.TooltipColor.Color; g.Rectangle(0, 0, Allocation.Width, Allocation.Height); g.SetSourceColor(marker.TooltipColor.Color); g.Fill(); using (var drawingLayout = new Pango.Layout(this.PangoContext)) { drawingLayout.FontDescription = cache.tooltipFontDescription; double y = verticalTextBorder; var showBulletedList = marker.Errors.Count > 1; foreach (var msg in marker.Errors) { var icon = msg.IsError ? cache.errorPixbuf : cache.warningPixbuf; if (!showBulletedList) { drawingLayout.Width = maxTextWidth; } drawingLayout.SetText(GetFirstLine(msg)); int w; int h; drawingLayout.GetPixelSize(out w, out h); if (showBulletedList) { g.Save(); g.Translate( textBorder, y + verticalTextSpace / 2 + 1 + Math.Max(0, (h - icon.Height) / 2) ); Gdk.CairoHelper.SetSourcePixbuf(g, icon, 0, 0); g.Paint(); g.Restore(); } g.Save(); g.Translate(showBulletedList ? textBorder + iconTextSpacing + icon.Width: textBorder, y + verticalTextSpace / 2 + 1); g.SetSourceColor(ShadowColor); g.ShowLayout(drawingLayout); g.Translate(0, -1); g.SetSourceColor(marker.TagColor.SecondColor); g.ShowLayout(drawingLayout); g.Restore(); y += h + verticalTextSpace; } } }
protected override void Draw(Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress) { cr.Color = new Color (0, 0, 0); if (prev != null) { double scale = Math.Min ((double)width/(double)prev.Width, (double)height/(double)prev.Height); cr.Save (); cr.Translate (-progress * width, 0); cr.Rectangle (0, 0, width, .5 * (height - scale*prev.Height)); cr.Fill (); cr.Rectangle (0, height - .5 * (height - scale*prev.Height), width, .5 * (height - scale*prev.Height)); cr.Fill (); cr.Rectangle (0, 0, .5 * (width - scale*prev.Width), height); cr.Fill (); cr.Rectangle (width - .5 * (width - scale*prev.Width), 0, .5 * (width - scale*prev.Width), height); cr.Fill (); cr.Rectangle (0, 0, width, height); cr.Scale (scale, scale); CairoHelper.SetSourcePixbuf (cr, prev, .5 * ((double)width/scale - prev.Width), .5 * ((double)height/scale - prev.Height)); cr.Fill (); cr.Restore (); } if (next != null) { double scale = Math.Min ((double)width/(double)next.Width, (double)height/(double)next.Height); cr.Save (); cr.Translate (width * (1.0 - progress), 0); cr.Rectangle (0, 0, width, .5 * (height - scale*next.Height)); cr.Fill (); cr.Rectangle (0, height - .5 * (height - scale*next.Height), width, .5 * (height - scale*next.Height)); cr.Fill (); cr.Rectangle (0, 0, .5 * (width - scale*next.Width), height); cr.Fill (); cr.Rectangle (width - .5 * (width - scale*next.Width), 0, .5 * (width - scale*next.Width), height); cr.Fill (); cr.Rectangle (0, 0, width, height); cr.Scale (scale, scale); CairoHelper.SetSourcePixbuf (cr, next, .5 * ((double)width/scale - next.Width), .5 * ((double)height/scale - next.Height)); cr.Fill (); cr.Restore (); } }
private void DrawOutputndicator(Cairo.Context context) { context.Save(); RelativeLocator locator = new RelativeLocator(-0.04, 1.2); PointD point = locator.Locate(this); context.MoveTo(point); context.LineCap = LineCap.Round; context.Color = s_ioIndicatorColor; double l = 4; //arm lenght of indicator icon double s = 0.4; //spacing between arms in the indicator icon //draw << //up context.RelLineTo(new Distance(-s, -l)); context.RelMoveTo(new Distance(s, l)); //back //right context.RelLineTo(new Distance(l, s)); context.RelMoveTo(new Distance(-l, -s)); //back context.RelMoveTo(new Distance(3, -3)); //repeat above for second arrow context.RelLineTo(new Distance(-s, -l)); context.RelMoveTo(new Distance(s, l)); //back context.RelLineTo(new Distance(l, s)); context.RelMoveTo(new Distance(-l, -s)); //back context.Stroke(); context.Restore(); }
void RenderPreview(Cairo.Context context, Gdk.Point position, double opacity) { if (brandedIcon != null) { /* if (previewSurface == null) { * previewSurface = new SurfaceWrapper (context, brandedIcon); * } * double scale = PreviewSize / previewSurface.Width; * * context.Save (); * context.Translate (position.X, position.Y); * context.Scale (scale * IconScale, scale * IconScale); * context.SetSourceSurface (previewSurface.Surface, -previewSurface.Width / 2, -previewSurface.Height / 2); * context.PaintWithAlpha (opacity); * context.Restore (); */ double scale = PreviewSize / brandedIcon.Width; context.Save(); context.Translate(position.X, position.Y); context.Scale(scale * IconScale, scale * IconScale); context.DrawImage(this, brandedIcon.WithAlpha(opacity), -brandedIcon.Width / 2, -brandedIcon.Height / 2); context.Restore(); } }
void FillChecks (Context cr, int x, int y, int width, int height) { int CHECK_SIZE = 32; cr.Save (); Surface check = cr.Target.CreateSimilar (Content.Color, 2 * CHECK_SIZE, 2 * CHECK_SIZE); // draw the check using (Context cr2 = new Context (check)) { cr2.Operator = Operator.Source; cr2.Color = new Color (0.4, 0.4, 0.4); cr2.Rectangle (0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE); cr2.Fill (); cr2.Color = new Color (0.7, 0.7, 0.7); cr2.Rectangle (x, y, CHECK_SIZE, CHECK_SIZE); cr2.Fill (); cr2.Rectangle (x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE); cr2.Fill (); } // Fill the whole surface with the check SurfacePattern check_pattern = new SurfacePattern (check); check_pattern.Extend = Extend.Repeat; cr.Source = check_pattern; cr.Rectangle (0, 0, width, height); cr.Fill (); check_pattern.Destroy (); check.Destroy (); cr.Restore (); }
public void Render(Cairo.Context c, Control control) { TextBlock textBlock = control as TextBlock; Rectangle borderRect; c.Save(); borderRect = new Rectangle(textBlock.Location.X, textBlock.Location.Y, textBlock.Width, textBlock.Height); if (!textBlock.CanGrow || DesignMode) { c.ClipRectangle(borderRect); } var rect = c.DrawTextBlock(textBlock, false); if (!DesignMode && (textBlock.CanGrow && rect.Height > textBlock.Height || textBlock.CanShrink && rect.Height < textBlock.Height)) { borderRect = new Rectangle(textBlock.Location.X, textBlock.Location.Y, textBlock.Width, rect.Height); } else { borderRect = new Rectangle(textBlock.Location.X, textBlock.Location.Y, textBlock.Width, textBlock.Height); } c.FillRectangle(borderRect, textBlock.BackgroundColor.ToCairoColor()); c.DrawTextBlock(textBlock, true); c.DrawInsideBorder(borderRect, textBlock.Border, true); c.Restore(); }
void DrawString(string text, bool isMarkup, Cairo.Context context, int x, int y, int width, double opacity, Pango.Context pango, StatusArea.RenderArg arg) { Pango.Layout pl = new Pango.Layout(pango); if (isMarkup) { pl.SetMarkup(text); } else { pl.SetText(text); } pl.FontDescription = Styles.StatusFont; pl.FontDescription.AbsoluteSize = Pango.Units.FromPixels(Styles.StatusFontPixelHeight); pl.Ellipsize = Pango.EllipsizeMode.End; pl.Width = Pango.Units.FromPixels(width); int w, h; pl.GetPixelSize(out w, out h); context.Save(); // use widget height instead of message box height as message box does not have a true height when no widgets are packed in it // also ensures animations work properly instead of getting clipped context.Rectangle(new Rectangle(x, arg.Allocation.Y, width, arg.Allocation.Height)); context.Clip(); // Subtract off remainder instead of drop to prefer higher centering when centering an odd number of pixels context.MoveTo(x, y - h / 2 - (h % 2)); context.Color = Styles.WithAlpha(FontColor(), opacity); Pango.CairoHelper.ShowLayout(context, pl); pl.Dispose(); context.Restore(); }
public void Draw(Cairo.Context g, double scale, bool fillSelection) { g.Save(); g.Translate(0.5, 0.5); g.Scale(scale, scale); g.AppendPath(selection_path); if (fillSelection) { g.Color = new Cairo.Color(0.7, 0.8, 0.9, 0.2); g.FillRule = Cairo.FillRule.EvenOdd; g.FillPreserve(); } g.LineWidth = 1 / scale; // Draw a white line first so it shows up on dark backgrounds g.Color = new Cairo.Color(1, 1, 1); g.StrokePreserve(); // Draw a black dashed line over the white line g.SetDash(new double[] { 2 / scale, 4 / scale }, 0); g.Color = new Cairo.Color(0, 0, 0); g.Stroke(); g.Restore(); }
protected void DrawHoverAndSelection(Cairo.Context cr) { cr.Save(); cr.Translate(XOffset, YOffset); cr.Scale(Scale, Scale); if (Hoverable && hoveringIndex != -1) { Cairo.Rectangle rect = GetTileRectSansPadding(HoveringX, HoveringY, scale: false, offset: false); cr.NewPath(); cr.SetSourceColor(HoverColor); cr.Rectangle(new Cairo.Rectangle(rect.X + 0.5, rect.Y + 0.5, rect.Width - 1, rect.Height - 1)); cr.LineWidth = 1; cr.LineJoin = LineJoin.Bevel; cr.Stroke(); } if (Selectable) { var rect = GetTileRectSansPadding(SelectedX, SelectedY, scale: false, offset: false); if (IsInBounds((int)rect.X, (int)rect.Y, scale: false, offset: false)) { cr.NewPath(); cr.SetSourceColor(SelectionColor); cr.Rectangle(rect.X + 0.5, rect.Y + 0.5, rect.Width - 1, rect.Height - 1); cr.LineWidth = 1; cr.Stroke(); } } cr.Restore(); }
public override void Run() { ICollection<double> chapters = this.Theory.Chapters; StripCanvasSize scs = this.Manager.GenerateStripCanvasSize (chapters.Count); double dw = scs.CanvasSize.Width; double dh = scs.CanvasSize.Height; using (PdfSurface surface = new PdfSurface (this.Manager.OutputFile, scs.TotalWidth, scs.TotalHeight)) { using (Context ctx = new Context (surface)) { int index = 0x00; IPoint3 p; foreach (double chapter in chapters) { p = scs.GetCanvasOffset (index); ctx.Save (); ctx.Translate (p.X, p.Y); ctx.Rectangle (0.0d, 0.0d, dw, dh); ctx.Stroke (); this.Theory.Time = chapter; CairoEngine engine = new CairoEngine (this.Theory); engine.Context = ctx; engine.Process (); ctx.Restore (); index++; } } } }
void DrawPixbuf(Cairo.Context ctx, Gdk.Pixbuf img, double x, double y, Size idesc) { ctx.Save(); ctx.Translate(x, y); ctx.Scale(idesc.Width / (double)img.Width, idesc.Height / (double)img.Height); Gdk.CairoHelper.SetSourcePixbuf(ctx, img, 0, 0); #pragma warning disable 618 using (var p = ctx.Source) { if (p is SurfacePattern pattern) { if (idesc.Width > img.Width || idesc.Height > img.Height) { // Fixes blur issue when rendering on an image surface pattern.Filter = Cairo.Filter.Fast; } else { pattern.Filter = Cairo.Filter.Good; } } } #pragma warning restore 618 ctx.Paint(); ctx.Restore(); }
private void PaintZoomScale(Cairo.Context gc, double width, double height, double centerx, double centery) { if (this.drawZoomScale) { gc.Save(); string s = String.Format("x:{0:##0.0} y:{1:##0.0} *:{2:#0.0#}", this.TranslatedX, this.TranslatedY, this.ScaleFactor); int textWidth, textHeight; Pango.Layout layout = new Pango.Layout(this.PangoContext); layout.FontDescription = this.PangoContext.FontDescription.Copy(); layout.FontDescription.Size = Pango.Units.FromDouble(12.0); layout.SetText(s); Size te = GetTextSize(layout); gc.Color = new Cairo.Color(0.0, 0.0, 0.0, 0.6); gc.Rectangle(width - 7.5d - te.Width, height - te.Height - 5.5d, 7.5d + te.Width, 5.5d + te.Height); gc.Fill(); gc.MoveTo(width - 4.5d - te.Width, height - te.Height - 4.5d); gc.Color = new Cairo.Color(1.0, 1.0, 1.0, 0.6); Pango.CairoHelper.ShowLayout(gc, layout); gc.Fill(); gc.Restore(); } }
//http://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cairo/cookbook/ private static void drawRoundedRectangle(double x, double y, double width, double height, double radius, Cairo.Context g, Cairo.Color color) { g.Save(); //manage negative widths if (width < 0) { x += width; //it will shift to the left (width is negative) width *= -1; } if ((radius > height / 2) || (radius > width / 2)) { radius = min(height / 2, width / 2); } g.MoveTo(x, y + radius); g.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2); g.LineTo(x + width - radius, y); g.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0); g.LineTo(x + width, y + height - radius); g.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2); g.LineTo(x + radius, y + height); g.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); g.ClosePath(); g.Restore(); g.SetSourceRGB(color.R, color.G, color.B); g.FillPreserve(); g.SetSourceRGB(0, 0, 0); g.LineWidth = 2; g.Stroke(); }
public static void DrawRoundedRectangle(Cairo.Context gr, double x, double y, double width, double height, double radius, Cairo.Color color, Cairo.Color borderColor) { gr.Save(); if ((radius > height / 2) || (radius > width / 2)) { radius = Math.Min(height / 2, width / 2); } gr.MoveTo(x, y + radius); gr.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2); gr.LineTo(x + width - radius, y); gr.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0); gr.LineTo(x + width, y + height - radius); gr.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2); gr.LineTo(x + radius, y + height); gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); gr.ClosePath(); gr.Restore(); gr.LineJoin = LineJoin.Round; gr.Color = borderColor; gr.StrokePreserve(); gr.Color = color; gr.Fill(); }
public static Rectangle DrawRectangle(this Cairo.Context g, Cairo.Rectangle r, Cairo.Color color, int lineWidth) { // Put it on a pixel line if (lineWidth == 1) { r = new Rectangle(r.X - 0.5, r.Y - 0.5, r.Width, r.Height); } g.Save(); g.MoveTo(r.X, r.Y); g.LineTo(r.X + r.Width, r.Y); g.LineTo(r.X + r.Width, r.Y + r.Height); g.LineTo(r.X, r.Y + r.Height); g.LineTo(r.X, r.Y); g.Color = color; g.LineWidth = lineWidth; g.LineCap = LineCap.Square; Rectangle dirty = g.StrokeExtents(); g.Stroke(); g.Restore(); return(dirty); }
protected override FlowReturn OnTransformIp (Gst.Buffer buf) { if (!buf.IsWritable) return FlowReturn.Error; Cairo.ImageSurface img = new Cairo.ImageSurface (buf.Data, Cairo.Format.Rgb24, width, height, width*4); using (Cairo.Context context = new Cairo.Context (img)) { double dx = (double) ( (buf.Timestamp / Clock.MSecond) % 2180) / 5; context.Save (); context.Scale (width / 640.0, height / 480.0); context.MoveTo (300, 10 + dx); context.LineTo (500 - dx, 400); context.LineWidth = 4.0; context.Color = new Color (0, 0, 1.0); context.Stroke(); context.Restore (); if (lastX != -1 && lastY != -1) { context.Color = new Color (1.0, 0, 0); context.Translate (lastX, lastY); context.Scale (Math.Min (width / 640.0, height / 480.0), Math.Min (width / 640.0, height / 480.0)); context.Arc (0, 0, 10.0, 0.0, 2 * Math.PI); context.Fill(); } } img.Destroy (); return base.OnTransformIp (buf); }
protected override bool OnExposeEvent(EventExpose evnt) { if (!IsRealized) { return(true); } using (Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window)) { cr.Save(); cr.Color = new Cairo.Color(0, 0, 0, 0); cr.Operator = Operator.Source; cr.Paint(); cr.Restore(); int width, height; GetSizeRequest(out width, out height); double opacity = Math.Min(1, (DateTime.UtcNow - shown_time).TotalMilliseconds / AnimationTime); if (!curtainDown) { opacity = 1 - opacity; } cr.Rectangle(0, 0, width, height); cr.Color = new Cairo.Color(0, 0, 0, CurtainOpacity * opacity); cr.Fill(); (cr.Target as IDisposable).Dispose(); } return(false); }
protected override void Draw(Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress) { cr.SetSourceColor (new Color (0, 0, 0, progress)); if (next != null) { double scale = Math.Min ((double)width/(double)next.Width, (double)height/(double)next.Height); cr.Save (); cr.Rectangle (0, 0, width, .5 * (height - scale*next.Height)); cr.Fill (); cr.Rectangle (0, height - .5 * (height - scale*next.Height), width, .5 * (height - scale*next.Height)); cr.Fill (); cr.Rectangle (0, 0, .5 * (width - scale*next.Width), height); cr.Fill (); cr.Rectangle (width - .5 * (width - scale*next.Width), 0, .5 * (width - scale*next.Width), height); cr.Fill (); cr.Rectangle (0, 0, width, height); cr.Scale (scale, scale); CairoHelper.SetSourcePixbuf (cr, next, .5 * ((double)width/scale - next.Width), .5 * ((double)height/scale - next.Height)); cr.PaintWithAlpha (progress); cr.Restore (); } }
public void Draw(ImageSurface dst) { if (disposed) { throw new ObjectDisposedException("PlacedSurface"); } using (Cairo.Context g = new Cairo.Context(dst)) { g.Save(); Rectangle r = what.GetBounds().ToCairoRectangle(); // We need to use the source operator to fully replace the old // data. Or else we may paint transparent on top of it and // it will still be visible. [Bug #670411] using (Path p = g.CreateRectanglePath(new Rectangle(where.X, where.Y, r.Width, r.Height))) { g.AppendPath(p); g.Clip(); g.Operator = Operator.Source; g.DrawPixbuf(what.ToPixbuf(), new Cairo.Point(where.X, where.Y)); } g.Restore(); } }
void Draw(Context cr, int width, int height) { cr.LineWidth = 1.0; cr.Color = new Color(1.0, 1.0, 1.0); cr.Rectangle(0, 0, width, height); cr.Fill(); cr.Save(); cr.Scale(scale_factor, scale_factor); try { if(diagram != null) { DiagramRenderer dr = new DiagramRenderer(cr, width, height, diagram); cr.Color = new Color(0.0, 0.0, 0.0); dr.Render(); dr.Draw(); } } catch { error_counter++; } cr.Restore(); }
public void DrawObject(Context ctx, DrawingObject body) { if (body == null) return; ctx.Save (); ctx.Color = new Cairo.Color (0, 0, 0); ctx.LineWidth = 1; foreach (Tuple<PointDouble, PointDouble> line in body.lines) { ctx.MoveTo (line.Item1.toPointD()); ctx.LineTo (line.Item2.toPointD()); } if (body.points.Count > 1) ctx.Rectangle(body._centerOfMass.X - 5, body._centerOfMass.Y - 5, 10, 10); ctx.Stroke (); foreach (PointDouble point in body.points) { ctx.Rectangle (point.X - 5, point.Y - 5, 10, 10); ctx.Fill (); } foreach (Tuple<PointDouble, double, double> force in body._forces) { DrawForce (ctx, force); } foreach (Tuple<PointDouble, double> moment in body._moments) { DrawMoment (ctx, moment); } ctx.Restore (); }
void RenderBackground(Cairo.Context context, Gdk.Rectangle region) { region.Inflate(-Padding, -Padding); context.RenderOuterShadow(new Gdk.Rectangle(region.X + 10, region.Y + 15, region.Width - 20, region.Height - 15), Padding, 3, .25); context.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 5); using (var lg = new LinearGradient(0, region.Y, 0, region.Bottom)) { lg.AddColorStop(0, new Cairo.Color(.36, .53, .73)); lg.AddColorStop(1, new Cairo.Color(.21, .37, .54)); context.SetSource(lg); context.FillPreserve(); } context.Save(); context.Translate(IconPosition.X, IconPosition.Y); context.Scale(0.75, 0.75); Gdk.CairoHelper.SetSourcePixbuf(context, starburst, -starburst.Width / 2, -starburst.Height / 2); context.FillPreserve(); context.Restore(); context.LineWidth = 1; context.SetSourceRGB(.29, .47, .67); context.Stroke(); }
public override void Render(Cairo.Context c) { InvalidateBound(); c.Save(); c.FillRectangle(AbsoluteBound, section.BackgroundColor.ToCairoColor()); Rectangle r = new Rectangle(AbsoluteBound.X, AbsoluteBound.Y, parentReport.Width, SectionheaderHeight); Cairo.Gradient pat = new Cairo.LinearGradient(0, AbsoluteBound.Y, 0, AbsoluteBound.Y + SectionheaderHeight); pat.AddColorStop(0, sectionHeaderColor); pat.AddColorStop(1, sectionHeaderColor1); c.FillRectangle(r, pat); c.DrawText(new Cairo.PointD(r.X + 3, r.Y + 3), "Tahoma", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal, 11, blackColor, 600, Section.Name); c.FillRectangle(GripperAbsoluteBound, SectionGripperColor); c.Translate(AbsoluteDrawingStartPoint.X, AbsoluteDrawingStartPoint.Y); for (int j = 0; j < Controls.Count; j++) { var ctrl = Controls [j]; ctrl.Render(c); } c.Restore(); }
public void FinishSelection() { // We don't have an uncommitted layer, abort if (!ShowSelectionLayer) { return; } FinishPixelsHistoryItem hist = new FinishPixelsHistoryItem(); hist.TakeSnapshot(); Layer layer = SelectionLayer; using (Cairo.Context g = new Cairo.Context(CurrentLayer.Surface)) { g.Save(); g.SetSourceSurface(layer.Surface, (int)layer.Offset.X, (int)layer.Offset.Y); g.PaintWithAlpha(layer.Opacity); g.Restore(); } DestroySelectionLayer(); Workspace.Invalidate(); Workspace.History.PushNewItem(hist); }
private void RenderNetwork(Network network, Cairo.Context gc) { lock (network) { Rectangle rect = (Rectangle)network.Properties["rect"]; SizeD titleSize = CalculateNetworkTitleSize(network, gc); Hashtable nodegroups = network.Properties["nodegroups"] as Hashtable; gc.Save(); // Draw network box gc.Color = networkBG; gc.Rectangle(rect); gc.Fill(); // Draw title, 2px/2px offset from top/left corner gc.Color = white; gc.MoveTo(rect.X + 2, rect.Y + 2 /* + titleSize.Height */); Pango.Layout layout = new Pango.Layout(this.PangoContext); layout.FontDescription = this.PangoContext.FontDescription.Copy(); layout.FontDescription.Size = Pango.Units.FromDouble(NetworkNameFontSize); layout.SetText(network.NetworkName); Pango.CairoHelper.ShowLayout(gc, layout); foreach (NodeGroup ng in nodegroups.Values) { RenderNodeGroup(ng, network, gc); } gc.Restore(); RenderConnections(network, gc); } }
protected override FlowReturn OnTransformIp(Gst.Buffer buf) { if (!buf.IsWritable) { return(FlowReturn.Error); } Cairo.ImageSurface img = new Cairo.ImageSurface(buf.Data, Cairo.Format.Rgb24, width, height, width * 4); using (Cairo.Context context = new Cairo.Context(img)) { double dx = (double)((buf.Timestamp / Clock.MSecond) % 2180) / 5; context.Save(); context.Scale(width / 640.0, height / 480.0); context.MoveTo(300, 10 + dx); context.LineTo(500 - dx, 400); context.LineWidth = 4.0; context.Color = new Color(0, 0, 1.0); context.Stroke(); context.Restore(); if (lastX != -1 && lastY != -1) { context.Color = new Color(1.0, 0, 0); context.Translate(lastX, lastY); context.Scale(Math.Min(width / 640.0, height / 480.0), Math.Min(width / 640.0, height / 480.0)); context.Arc(0, 0, 10.0, 0.0, 2 * Math.PI); context.Fill(); } } img.Destroy(); return(base.OnTransformIp(buf)); }
private void DrawContents(Cairo.Context gc) { try { //if (debug) Console.Out.WriteLine ("Drawing NetworkMap Contents..."); gc.Save(); lock (this) { // TODO: Deal with overlapping nodes -- connections don't handle this yet. // XXX: Eww.. ArrayList networks = (ArrayList)networkZOrder.Clone(); networks.Reverse(); foreach (Network network in networks) { // XXX: Don't do this on every draw, // only when things actually change! CalculateNetworkSize(network, gc); if (network.ReadyLocalConnections.Length > 0) { RenderNetwork(network, gc); } } } gc.Restore(); } catch (Exception ex) { OnError(ex); } }
//http://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cairo/cookbook/ private static void drawRoundedRectangle(double x, double y, double width, double height, double radius, Cairo.Context g, Cairo.Color color) { g.Save(); if ((radius > height / 2) || (radius > width / 2)) { radius = min(height / 2, width / 2); } g.MoveTo(x, y + radius); g.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2); g.LineTo(x + width - radius, y); g.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0); g.LineTo(x + width, y + height - radius); g.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2); g.LineTo(x + radius, y + height); g.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); g.ClosePath(); g.Restore(); g.SetSourceRGB(color.R, color.G, color.B); g.FillPreserve(); g.SetSourceRGB(0, 0, 0); g.LineWidth = 2; g.Stroke(); }
protected void DrawSmallCovers(Cairo.Context context, float width, float height, double lwidth) { context.Save(); double hlwidth = lwidth * 0.5; context.MoveTo(hlwidth, height - hlwidth); context.LineTo(hlwidth, 0.3 * (height - lwidth)); context.LineTo((width - lwidth) * 0.65, hlwidth); context.LineTo((width - lwidth) * 0.65, 0.7 * (height - lwidth)); context.ClosePath(); context.LineWidth = lwidth; context.SetSourceRGBA(0.1, 0.1, 0.1, 1.0); context.FillPreserve(); context.SetSourceRGBA(1.0, 1.0, 1.0, 0.7); context.Stroke(); context.Translate((4 + hlwidth), 0); context.MoveTo(hlwidth, height - hlwidth); context.LineTo(hlwidth, 0.3 * (height - lwidth)); context.LineTo((width - lwidth) * 0.65, hlwidth); context.LineTo((width - lwidth) * 0.65, 0.7 * (height - lwidth)); context.ClosePath(); context.SetSourceRGBA(0.1, 0.1, 0.1, 1.0); context.FillPreserve(); context.SetSourceRGBA(1.0, 1.0, 1.0, 0.7); context.Stroke(); context.Translate(-(4 + hlwidth), 0); context.Restore(); }
void DrawButtonTabs(Cairo.Context cr, Cairo.Rectangle rectangle) { if (IsSeparator) { cr.NewPath(); double x = Math.Ceiling(rectangle.X + rectangle.Width / 2) + 0.5; cr.MoveTo(x, rectangle.Y + 0.5 + 2); cr.RelLineTo(0, rectangle.Height - 1 - 4); cr.ClosePath(); cr.Color = (HslColor)parent.Style.Dark(StateType.Normal); cr.LineWidth = 1; cr.Stroke(); return; } int topPadding = 2; if (Active || HoverPosition.X >= 0) { cr.NewPath(); cr.Rectangle(rectangle.X + 0.5, rectangle.Y + 0.5 + topPadding, rectangle.Width - 1, rectangle.Height - topPadding); cr.ClosePath(); if (Active) { cr.Color = (HslColor)parent.Style.Background(StateType.Prelight); } else if (HoverPosition.X >= 0) { double rx = rectangle.X + HoverPosition.X; double ry = rectangle.Y + HoverPosition.Y; Cairo.RadialGradient gradient = new Cairo.RadialGradient(rx, ry, rectangle.Height * 1.5, rx, ry, 2); var color = (HslColor)parent.Style.Dark(StateType.Normal); color.L *= 1.1; gradient.AddColorStop(0, color); color.L *= 1.1; gradient.AddColorStop(1, color); cr.Pattern = gradient; } if (!Active) { cr.Fill(); } else { cr.FillPreserve(); cr.Color = (HslColor)parent.Style.Dark(StateType.Normal); cr.LineWidth = 1; cr.Stroke(); } } cr.Save(); cr.Translate(rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2 + topPadding); cr.Color = (HslColor)parent.Style.Text(StateType.Normal); cr.ShowLayout(layout); cr.Restore(); }
protected override bool OnExposeEvent(EventExpose ev) { using (Cairo.Context context = CairoHelper.Create(ev.Window)) { context.Save(); PointD translation = DrawingToView(0.0, 0.0); context.Translate(translation.X, translation.Y); context.Scale(Scale, Scale); foreach (IFigure figure in Drawing.FiguresEnumerator) { // check region for update bool shouldDraw = true; if (shouldDraw) { figure.Draw(context); } } foreach (IFigure figure in SelectionEnumerator) { figure.DrawSelected(context); } context.Restore(); foreach (IHandle handle in SelectionHandles) { handle.Draw(context, this); } } DebugUpdateFrame(); return(base.OnExposeEvent(ev)); }
protected void OnRender(Context cr, int width, int height) { cr.Save(); cr.SetSourceRGBA(1, 0, 0, mTick*0.1); cr.Rectangle(0, 0, width, height); cr.Fill(); cr.Restore(); }
protected void RenderPixbufToSurf(Cairo.Context gc, Gdk.Pixbuf pixbuf, double x, double y) { gc.Save(); gc.Rectangle(x, y, pixbuf.Width, pixbuf.Height); Gdk.CairoHelper.SetSourcePixbuf(gc, pixbuf, x, y); gc.Fill(); gc.Restore(); }
private void PaintMotionIndicators(Cairo.Context gc, double width, double height, double centerx, double centery) { if (this.isTranslating) { gc.Save(); gc.Matrix.InitIdentity(); RenderPixbufToSurf(gc, arrowUp, (width / 2.0) - (arrowUp.Width / 2.0), 10); RenderPixbufToSurf(gc, arrowDown, (width / 2.0) - (arrowDown.Width / 2.0), (height - 10 - arrowDown.Height)); RenderPixbufToSurf(gc, arrowRight, (width - 10 - arrowRight.Width) + 0.5, (height / 2.0) - (arrowRight.Height / 2.0)); RenderPixbufToSurf(gc, arrowLeft, 10, (height / 2.0) - (arrowRight.Height / 2.0)); gc.Restore(); return; } if (this.isScaling) { gc.Save(); CreateRoundedRectPath(gc, width - 104, 4, 100, 110, 30); gc.Color = new Cairo.Color(0, 0, 0, 0.5); gc.Fill(); RenderPixbufToSurf(gc, zoomGlass, width - 102, 6); Pango.Layout layout = new Pango.Layout(this.PangoContext); layout.FontDescription = this.PangoContext.FontDescription.Copy(); layout.FontDescription.Size = Pango.Units.FromDouble(10.0); layout.SetText("Zooming"); Size te = GetTextSize(layout); gc.MoveTo(width - 52 - (te.Width / 2.0), 109); gc.Color = new Cairo.Color(1, 1, 1, 0.7); Pango.CairoHelper.ShowLayout(gc, layout); gc.Restore(); return; } }
void DrawCurveTabs(Cairo.Context cr, Cairo.Rectangle rectangle) { if (IsSeparator) { return; } cr.MoveTo(rectangle.X, rectangle.Y); double bottom = rectangle.Y + rectangle.Height - 1; cr.CurveTo( rectangle.X + SpacerWidth / 2, rectangle.Y, rectangle.X + SpacerWidth / 2, bottom, rectangle.X + SpacerWidth, bottom); cr.LineTo(rectangle.X + rectangle.Width - SpacerWidth, bottom); cr.CurveTo( rectangle.X + rectangle.Width - SpacerWidth / 2, bottom, rectangle.X + rectangle.Width - SpacerWidth / 2, rectangle.Y, rectangle.X + rectangle.Width, rectangle.Y); cr.Color = (HslColor)parent.Style.Dark(StateType.Normal); cr.StrokePreserve(); cr.ClosePath(); if (Active) { cr.Color = (HslColor)parent.Style.Background(StateType.Prelight); } else if (HoverPosition.X >= 0) { double rx = rectangle.X + HoverPosition.X; double ry = rectangle.Y + HoverPosition.Y; Cairo.RadialGradient gradient = new Cairo.RadialGradient(rx, ry, rectangle.Height * 1.5, rx, ry, 2); var color = (HslColor)parent.Style.Mid(StateType.Normal); color.L *= 1.05; gradient.AddColorStop(0, color); color.L *= 1.07; gradient.AddColorStop(1, color); cr.Pattern = gradient; } else { cr.Color = (HslColor)parent.Style.Mid(StateType.Normal); } cr.Fill(); cr.Save(); cr.Translate(rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2); cr.Color = (HslColor)parent.Style.Text(StateType.Normal); cr.ShowLayout(layout); cr.Restore(); }
protected void DrawCurvedRectangle(Cairo.Context gr, double x, double y, double width, double height) { gr.Save(); gr.MoveTo(x, y + height / 2); gr.CurveTo(x, y, x, y, x + width / 2, y); gr.CurveTo(x + width, y, x + width, y, x + width, y + height / 2); gr.CurveTo(x + width, y + height, x + width, y + height, x + width / 2, y + height); gr.CurveTo(x, y + height, x, y + height, x, y + height / 2); gr.Restore(); }
public virtual void Draw (Context context, IDrawingView view) { RectangleD rect = ViewDisplayBox(view); context.Save(); context.LineWidth = LineWidth; context.Rectangle (GdkCairoHelper.CairoRectangle (rect)); context.Color = FillColor; context.FillPreserve (); context.Color = LineColor; context.Stroke (); context.Restore(); }
/// <summary> /// Erase the handle that was drawn in a previous call to Render (). /// </summary> public void Clear (Context g) { g.Save (); var rect = GetHandleRect ().Inflate (2, 2); using (var path = g.CreateRectanglePath (rect)) g.AppendPath (path); g.Operator = Operator.Clear; g.Fill (); g.Restore (); }
public virtual void Render (Context cr, Gdk.Rectangle area, Color color, bool showEmptyStars, bool isHovering, int hoverValue, double fillOpacity, double hoverFillOpacity, double strokeOpacity) { if (Value == MinRating && !isHovering && !showEmptyStars) { return; } cr.Save (); Cairo.Color fill_color = color; fill_color.A = fillOpacity; Cairo.Color stroke_color = fill_color; stroke_color.A = strokeOpacity; Cairo.Color hover_fill_color = fill_color; hover_fill_color.A = hoverFillOpacity; double x, y; ComputePosition (area, out x, out y); cr.LineWidth = 1.0; cr.Translate (0.5, 0.5); for (int i = MinRating + 1, s = isHovering || showEmptyStars ? MaxRating : Value; i <= s; i++, x += Size) { bool fill = i <= Value && Value > MinRating; bool hover_fill = i <= hoverValue && hoverValue > MinRating; double scale = fill || hover_fill ? Size : Size - 2; double ofs = fill || hover_fill ? 0 : 1; for (int p = 0, n = star_plot.GetLength (0); p < n; p++) { double px = x + ofs + star_plot[p, 0] * scale; double py = y + ofs + star_plot[p, 1] * scale; if (p == 0) { cr.MoveTo (px, py); } else { cr.LineTo (px, py); } } cr.ClosePath (); if (fill || hover_fill) { if (!isHovering || hoverValue >= Value) { cr.Color = fill ? fill_color : hover_fill_color; } else { cr.Color = hover_fill ? fill_color : hover_fill_color; } cr.Fill (); } else { cr.Color = stroke_color; cr.Stroke (); } } cr.Restore (); }
public void BasicDrawSelected(Context context, PointD anchor) { BasicDrawSelected(context); context.Save(); context.Color = new Color(1.0, 0.2, 0.2); context.SetDash(Dash.DotDash, 0.0); context.MoveTo(anchor); context.LineTo(HandlePosition()); context.Stroke(); context.Restore(); }
public static void Render (Context cr, Rectangle box, double xalign, double yalign, Color innerColor, Color outerColor) { // virtual size of the figure we will draw below on the 1:1 scale double original_width = 8; double original_height = 12; // figure out the scale dimensions of the bounding box and the glyph double box_size = Math.Min (box.Width, box.Height); double original_size = Math.Max (original_width, original_height); // create a scale for the box (ratio between virtual glyph size and the box), // then re-scale to account for the extra size that will be added via stroke. // glyph_scale is the stroke width and the actual transformation size double box_scale = box_size / original_size; double glyph_scale = Math.Floor ((box_size - box_scale) / original_size); // compute the alignment to the pixel grid for the stroke/scale double pixel_align = Math.Floor (glyph_scale + 0.5) / 2.0; // figure out the actual size in pixels of the glyph double actual_width = glyph_scale * original_width + 2 * Math.Floor (pixel_align); double actual_height = glyph_scale * original_height + 2 * Math.Floor (pixel_align); // compute the offset accounting for box, grid alignment, and figure alignment double tx = box.X + pixel_align + Math.Round ((box.Width - actual_width) * xalign); double ty = box.Y + pixel_align + Math.Round ((box.Height - actual_height) * yalign); // save the context, and transform the current/new context cr.Save (); cr.Translate (tx, ty); cr.Scale (glyph_scale, glyph_scale); // define how the strokes look cr.LineWidth = 1; cr.LineCap = LineCap.Round; cr.LineJoin = LineJoin.Round; // inner 'b' note cr.Color = innerColor; cr.MoveTo (0, 2); cr.LineTo (2, 0); cr.Arc (4, 8, 2, Math.PI, Math.PI * 3); cr.Stroke (); // outer 'cut' circle cr.Color = outerColor; cr.Arc (4, 8, 4, Math.PI * 1.5, Math.PI * 1.12); cr.Stroke (); cr.Restore (); }
public override void BasicDraw (Context context) { RectangleD displayBox = DisplayBox; context.LineWidth = LineWidth; context.Save (); displayBox.OffsetDot5 (); context.Rectangle (GdkCairoHelper.CairoRectangle(displayBox)); context.Restore (); context.Color = FillColor; context.FillPreserve (); context.Color = LineColor; context.Stroke (); }
public override void Draw(Context context) { double middle = DisplayBox.Width / 2.0; context.LineWidth = LineWidth; context.Save (); context.Translate (DisplayBox.X + middle, DisplayBox.Y + middle); context.Arc (0.0, 0.0, middle, 0.0, 2.0 * Math.PI); context.Restore (); context.Color = new Cairo.Color (1.0, 1.0, 0.2, 0.2); context.FillPreserve (); context.Color = new Cairo.Color (0.0, 0.0, 0.0, 1.0); context.Stroke (); }
protected override void DrawBackground (Context context, Gdk.Rectangle region) { LayoutRoundedRectangle (context, region); context.Clip (); context.SetSourceColor (CairoExtensions.ParseColor ("D3E6FF")); context.Paint (); context.Save (); context.Translate (region.X + region.Width / 2.0, region.Y + region.Height); using (var rg = new RadialGradient (0, 0, 0, 0, 0, region.Height * 1.2)) { var color = CairoExtensions.ParseColor ("E5F0FF"); rg.AddColorStop (0, color); color.A = 0; rg.AddColorStop (1, color); context.Scale (region.Width / (double)region.Height, 1.0); context.SetSource (rg); context.Paint (); } context.Restore (); LayoutRoundedRectangle (context, region, -3, -3, 2); context.SetSourceRGBA (1, 1, 1, 0.4); context.LineWidth = 1; context.StrokePreserve (); context.Clip (); int boxSize = 11; int x = region.Left + (region.Width % boxSize) / 2; for (; x < region.Right; x += boxSize) { context.MoveTo (x + 0.5, region.Top); context.LineTo (x + 0.5, region.Bottom); } int y = region.Top + (region.Height % boxSize) / 2; y += boxSize / 2; for (; y < region.Bottom; y += boxSize) { context.MoveTo (region.Left, y + 0.5); context.LineTo (region.Right, y + 0.5); } context.SetSourceRGBA (1, 1, 1, 0.2); context.Stroke (); context.ResetClip (); }
void Draw (Context ctx, int width, int height) { double radius = 0.5 * Math.Min (width, height) - 10; int xc = width / 2; int yc = height / 2; Surface overlay = ctx.Target.CreateSimilar (Content.ColorAlpha, width, height); Surface punch = ctx.Target.CreateSimilar (Content.Alpha, width, height); Surface circles = ctx.Target.CreateSimilar (Content.ColorAlpha, width, height); FillChecks (ctx, 0, 0, width, height); ctx.Save (); // Draw a black circle on the overlay Context cr_overlay = new Context (overlay); cr_overlay.Color = new Color (0.0, 0.0, 0.0); OvalPath (cr_overlay, xc, yc, radius, radius); cr_overlay.Fill (); // Draw 3 circles to the punch surface, then cut // that out of the main circle in the overlay Context cr_tmp = new Context (punch); Draw3Circles (cr_tmp, xc, yc, radius, 1.0); //cr_tmp.Destroy (); cr_overlay.Operator = Operator.DestOut; cr_overlay.SetSourceSurface (punch, 0, 0); cr_overlay.Paint (); // Now draw the 3 circles in a subgroup again // at half intensity, and use OperatorAdd to join up // without seams. Context cr_circles = new Context (circles); cr_circles.Operator = Operator.Over; Draw3Circles (cr_circles, xc, yc, radius, 0.5); // cr_circles.Destroy (); cr_overlay.Operator = Operator.Add; cr_overlay.SetSourceSurface (circles, 0, 0); cr_overlay.Paint (); // cr_overlay.Destroy (); ctx.SetSourceSurface (overlay, 0, 0); ctx.Paint (); overlay.Destroy (); punch.Destroy (); circles.Destroy (); }
protected override bool OnExposed(Context cr, Rectangle area) { cr.Save(); if(!base.OnExposed(cr, area)) { cr.Color = new Color(1.0, 0.0, 0.0); cr.SetFontSize(100.0); cr.SelectFontFace("Librarian", FontSlant.Normal, FontWeight.Bold); cr.ShowText(role.ToString()); cr.Restore(); return true; } cr.Restore(); return true; }
public override void Draw (Context context, IDrawingView view) { RectangleD rect = ViewDisplayBox(view); double middle = rect.Width / 2.0; context.LineWidth = LineWidth; context.Save (); context.Translate (rect.X + middle, rect.Y + middle); context.Arc (0.0, 0.0, middle, 0.0, 2.0 * Math.PI); context.Restore (); context.Color = new Cairo.Color (0.2, 0.2, 1.0, 0.5); context.FillPreserve (); context.Color = new Cairo.Color (0.0, 0.0, 0.0, 1.0); context.Stroke (); }
public static void Main(string[] args) { // call the snippets Snippets snip = new Snippets(); Surface surface = new PSSurface("snippets.ps", IMAGE_WIDTH, IMAGE_WIDTH); Context cr = new Context(surface); foreach (string snippet in Snippets.snippets) { cr.Save(); Snippets.InvokeSnippet(snip, snippet, cr, IMAGE_WIDTH, IMAGE_HEIGHT); cr.ShowPage(); cr.Restore(); } surface.Finish (); }
public override void BasicDraw (Context context) { double midwidth = DisplayBox.Width / 2.0; double midheight = DisplayBox.Height / 2.0; context.LineWidth = LineWidth; context.Save (); context.Translate (DisplayBox.X + midwidth, DisplayBox.Y + midheight); context.Scale (midwidth - 1.0, midheight - 1.0); context.Arc (0.0, 0.0, 1.0, 0.0, 2.0 * Math.PI); context.Restore (); context.Color = FillColor; context.FillPreserve (); context.Color = LineColor; context.Stroke (); }
//FIXME: Figure produces invalid results public override PointD Draw(Context context, PointD a, PointD b) { // Save context context.Save (); if (_scaleX != _scaleY) context.Scale(_scaleX, _scaleY); var midpoint = new PointD (a.X + 2 * _radius, a.Y + 2 * _radius); context.Arc (midpoint.X, midpoint.Y, _radius, 0, (2 * Math.PI)); context.Restore (); context.Stroke (); return Geometry.EdgePointOfCircle (midpoint, _radius, b); }
public static void Main(string[] args) { // call the snippets Snippets snip = new Snippets(); foreach (string snippet in Snippets.snippets) { string filename = "./" + snippet + ".png"; Surface surface = new ImageSurface(Format.ARGB32, IMAGE_WIDTH, IMAGE_WIDTH); Context cr = new Context(surface); cr.Save(); Snippets.InvokeSnippet(snip, snippet, cr, IMAGE_WIDTH, IMAGE_HEIGHT); surface.WriteToPng(filename); cr.Restore(); } }
public override void Run() { StripCanvasSize scs = this.Manager.GenerateStripCanvasSize (0x01); using (PdfSurface surface = new PdfSurface (this.Manager.OutputFile, scs.TotalWidth, scs.TotalHeight)) { using (Context ctx = new Context (surface)) { IPoint3 p = scs.GetCanvasOffset (0x00); ctx.Save (); ctx.Translate (p.X, p.Y); this.Theory.Time = this.Manager.Time; CairoEngine engine = new CairoEngine (this.Theory); engine.Context = ctx; engine.Process (); ctx.Restore (); } } }
public static void Main(string[] args) { // call the snippets Snippets snip = new Snippets(); foreach (string snippet in Snippets.snippets) { string filename = "./" + snippet + ".svg"; Surface surface = new SvgSurface(filename, IMAGE_WIDTH, IMAGE_WIDTH); Context cr = new Context(surface); cr.Save(); Snippets.InvokeSnippet(snip, snippet, cr, IMAGE_WIDTH, IMAGE_HEIGHT); cr.ShowPage(); cr.Restore(); surface.Finish (); } }
protected override void RenderExpander(Context context, Gdk.Rectangle pix_rect) { Gdk.Pixbuf expander; if (IsExpanded) expander = new Gdk.Pixbuf(ExpandedIcon); else expander = new Gdk.Pixbuf(CollapsedIcon); context.Save(); Gdk.CairoHelper.SetSourcePixbuf(context, expander, pix_rect.Left, pix_rect.Y); m_TextXOffset = expander.Width; context.Paint(); context.Restore(); }
public override void PaintState(Context ctx) { IEnumerable<Tuple<int,VectorMessage>> peek = this.PeekMessagesGeneric<VectorMessage>(this.NeighbourIds); object[][] matrix = peek.Select(x => (x.Item2 != null) ? x.Item2.Data.Select(y => y.ToString("0.000")).Cast<object>().ToArray() : null).ToArray(); int n = matrix.Select(x => ((x == null) ? 0 : x.Length)).FirstOrDefault(x => x > 0); object[] nullrow = new object[n]; for(int i = 0; i < n; i++) { nullrow[i] = string.Empty; } for(int i = 0; i < matrix.Length; i++) { if(matrix[i] == null) { matrix[i] = nullrow; } } GraphicsUtils.PaintVectorSpace(ctx, matrix, NeighbourIds.ToArray(), new object[0], -1, new Color(0.0d, 0.7d, 0.0d)); ctx.Save(); if(this.paintMatrix == null) { string[][] vals = new string[this.Neighbours.Count][]; this.paintMatrix = new string[this.Neighbours.Count+1][]; this.paintHead = new string[this.Neighbours.Count+1]; int nl = this.supermatrix.Length; foreach(ParallelAlgorithm pa in this.Neighbours) { int at = indexMapping[pa.Id]; ProductSumVariableParallelAlgorithm psvpa = (ProductSumVariableParallelAlgorithm)pa; this.paintMatrix[at] = new string[nl]; this.paintHead[at] = pa.Name; vals[at] = psvpa.PossibleValues; } this.paintMatrix[this.Neighbours.Count] = new string[nl]; this.paintHead[this.Neighbours.Count] = "p"; int i = 0; foreach(int[] config in Utils.ConfigurationsMemory(this.dim)) { for(int j = 0; j < this.Neighbours.Count; j++) { paintMatrix[j][i] = vals[j][config[j]]; } paintMatrix[this.Neighbours.Count][i] = ((double)this.supermatrix.GetValue(config)).ToString("0.000"); i++; } } ctx.Translate(100.0d, 0.0d); GraphicsUtils.PaintVectorSpace(ctx, paintMatrix, this.paintHead, new object[0], 2, new Color(0.0d, 0.7d, 0.0d)); ctx.Restore(); }
protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface, int x, int y, int lastX, int lastY) { int line_width = (int)g.LineWidth; int size; // we want a minimum size of 2 for the splatter (except for when the brush width is 1), since a splatter of size 1 is very small if (line_width == 1) { size = 1; } else { size = Random.Next (2, line_width); } Rectangle r = new Rectangle (x - Random.Next (-15, 15), y - Random.Next (-15, 15), size, size); double rx = r.Width / 2; double ry = r.Height / 2; double cx = r.X + rx; double cy = r.Y + ry; double c1 = 0.552285; g.Save (); g.MoveTo (cx + rx, cy); g.CurveTo (cx + rx, cy - c1 * ry, cx + c1 * rx, cy - ry, cx, cy - ry); g.CurveTo (cx - c1 * rx, cy - ry, cx - rx, cy - c1 * ry, cx - rx, cy); g.CurveTo (cx - rx, cy + c1 * ry, cx - c1 * rx, cy + ry, cx, cy + ry); g.CurveTo (cx + c1 * rx, cy + ry, cx + rx, cy + c1 * ry, cx + rx, cy); g.ClosePath (); Rectangle dirty = g.FixedStrokeExtents (); g.Fill (); g.Restore (); return dirty.ToGdkRectangle (); }
protected override bool OnExposed(Context cr, Rectangle area) { cr.Save(); if(!base.OnExposed(cr, area)) { cr.Color = new Color(1.0, 0.0, 1.0); cr.Rectangle(new Rectangle(2.0, 2.0, Allocation.Width - 4.0, Allocation.Height - 4.0)); cr.LineWidth = 4.0; cr.LineJoin = LineJoin.Round; cr.Stroke(); cr.SetFontSize(20.0); cr.SelectFontFace("Librarian", FontSlant.Normal, FontWeight.Bold); cr.Translate(0.0, Allocation.Height / 2); cr.ShowText(type.ToString()); cr.Restore(); return true; } cr.Restore(); return true; }