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 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(); }
private void DrawShape(Cairo.Context g, int width, int height) { int inner_x = radius + border + inner; int cx = Center.X; int cy = Center.Y; g.Operator = Operator.Source; g.Source = new SolidPattern(new Cairo.Color(0, 0, 0, 0)); g.Rectangle(0, 0, width, height); g.Paint(); g.NewPath(); g.Translate(cx, cy); g.Rotate(angle); g.Source = new SolidPattern(new Cairo.Color(0.2, 0.2, 0.2, .6)); g.Operator = Operator.Over; g.Rectangle(0, -(border + inner), inner_x, 2 * (border + inner)); g.Arc(inner_x, 0, inner + border, 0, 2 * Math.PI); g.Arc(0, 0, radius + border, 0, 2 * Math.PI); g.Fill(); g.Source = new SolidPattern(new Cairo.Color(0, 0, 0, 1.0)); g.Operator = Operator.DestOut; g.Arc(inner_x, 0, inner, 0, 2 * Math.PI); #if true g.Fill(); #else g.FillPreserve(); g.Operator = Operator.Over; RadialGradient rg = new RadialGradient(inner_x - (inner * 0.3), inner * 0.3, inner * 0.1, inner_x, 0, inner); rg.AddColorStop(0, new Cairo.Color(0.0, 0.2, .8, 0.5)); rg.AddColorStop(0.7, new Cairo.Color(0.0, 0.2, .8, 0.1)); rg.AddColorStop(1.0, new Cairo.Color(0.0, 0.0, 0.0, 0.0)); g.Source = rg; g.Fill(); rg.Destroy(); #endif g.Operator = Operator.Over; g.Matrix = new Matrix(); g.Translate(cx, cy); if (source != null) { SetSourcePixbuf(g, source, -source.Width / 2, -source.Height / 2); } g.Arc(0, 0, radius, 0, 2 * Math.PI); g.Fill(); if (overlay != null) { SetSourcePixbuf(g, overlay, -overlay.Width / 2, -overlay.Height / 2); g.Arc(0, 0, radius, angle, angle + Math.PI); g.ClosePath(); g.FillPreserve(); g.Source = new SolidPattern(new Cairo.Color(1.0, 1.0, 1.0, 1.0)); g.Stroke(); } }
//system top public void SystemTop(Cairo.Context g, Int32 width) { PointD p1, p2, p3, p4, s1, s2, s3, s4; p1 = new PointD(5, 5); p2 = new PointD(width, 5); s1 = new PointD(width + 2, 7); s2 = new PointD(width + 2, 28); p3 = new PointD(width, 30); p4 = new PointD(5, 30); s3 = new PointD(3, 28); s4 = new PointD(3, 7); g.Color = new Color(0.3, 0.4, 0.6, 1); g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1); g.ClosePath(); g.LineWidth = 1; g.Stroke(); g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1); g.ClosePath(); Cairo.Gradient pat = new Cairo.LinearGradient(80, 10, 80, 60); pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0.6)); pat.AddColorStop(1, new Cairo.Color(0, 0, 0, 1)); g.Pattern = pat; g.FillPreserve(); g.SetFontSize(17); g.SelectFontFace("", FontSlant.Normal, FontWeight.Bold); g.MoveTo(new PointD(12, 23)); g.Color = new Color(1, 1, 1, 1); g.ShowText("General system information"); ((IDisposable)g.Target).Dispose(); ((IDisposable)g).Dispose(); }
static void draw(Cairo.Context gr, int width, int height) { gr.Scale(width, height); gr.LineWidth = 0.04; gr.MoveTo(new PointD(0.5, 0.1)); gr.LineTo(new PointD(0.9, 0.9)); gr.RelLineTo(new Distance(-0.4, 0.0)); gr.CurveTo(new PointD(0.2, 0.9), new PointD(0.2, 0.5), new PointD(0.5, 0.5) ); gr.ClosePath(); gr.MoveTo(new PointD(0.25, 0.1)); gr.RelLineTo(new Distance(0.2, 0.2)); gr.RelLineTo(new Distance(-0.2, 0.2)); gr.RelLineTo(new Distance(-0.2, -0.2)); gr.ClosePath(); gr.Color = new Color(0, 0, 1, 1); gr.FillPreserve(); gr.Color = new Color(0, 0, 0, 1); gr.Stroke(); }
//intro top Welcome public void IntroTop(Cairo.Context g, Int32 width) { PointD p1, p2, p3, p4, s1, s2, s3, s4; p1 = new PointD(10, 10); p2 = new PointD(width, 10); s1 = new PointD(width + 2, 12); s2 = new PointD(width + 2, 38); p3 = new PointD(width, 40); p4 = new PointD(10, 40); s3 = new PointD(8, 38); s4 = new PointD(8, 12); g.Color = new Color(0.3, 0.4, 0.6, 1); g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1); g.ClosePath(); g.LineWidth = 1; g.Stroke(); g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1); g.ClosePath(); Cairo.Gradient pat = new Cairo.LinearGradient(80, 10, 80, 80); pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0.6)); pat.AddColorStop(1, new Cairo.Color(0, 0, 0, 1)); g.Pattern = pat; g.FillPreserve(); g.SetFontSize(22); g.SelectFontFace("", FontSlant.Italic, FontWeight.Bold); g.MoveTo(new PointD(22, 33)); g.Color = new Color(1, 1, 1, 1); g.ShowText("Welcome to"); ((IDisposable)g.Target).Dispose(); ((IDisposable)g).Dispose(); }
protected override void CreateActiveTexture(Clutter.CairoTexture texture, int with_state) { texture.Clear(); Cairo.Context context = texture.Create(); double lwidth = 1; double hlwidth = lwidth * 0.5; //Draw outline rectangles: DrawSmallCovers(context, texture.Width, texture.Height, lwidth); //Draw stop icon: double dim = Math.Min(texture.Width * 0.6 - hlwidth, texture.Height * 0.6 - hlwidth); context.Rectangle(texture.Width * 0.4, texture.Height * 0.4, dim, dim); context.LineWidth = lwidth; double sat = (with_state == 0 ? 0.4 : (with_state == 1 ? 0.6 : 0.8)); context.SetSourceRGBA(sat, sat, sat, 1.0); context.FillPreserve(); context.SetSourceRGB(1.0, 1.0, 1.0); context.Stroke(); ((IDisposable)context.Target).Dispose(); ((IDisposable)context).Dispose(); }
void DrawFoldSegment(Cairo.Context ctx, double x, double y, bool isOpen, bool isSelected) { var drawArea = new Cairo.Rectangle(System.Math.Floor(x + (Margin.Width - foldSegmentSize) / 2) + 0.5, System.Math.Floor(y + (Editor.LineHeight - foldSegmentSize) / 2) + 0.5, foldSegmentSize, foldSegmentSize); ctx.Rectangle(drawArea); ctx.SetSourceColor(isOpen ? foldBgGC : foldToggleMarkerBackground); ctx.FillPreserve(); ctx.SetSourceColor(isSelected ? foldLineHighlightedGC : foldLineGC); ctx.Stroke(); ctx.DrawLine(isSelected ? foldLineHighlightedGC : foldToggleMarkerGC, drawArea.X + drawArea.Width * 2 / 10, drawArea.Y + drawArea.Height / 2, drawArea.X + drawArea.Width - drawArea.Width * 2 / 10, drawArea.Y + drawArea.Height / 2); if (!isOpen) { ctx.DrawLine(isSelected ? foldLineHighlightedGC : foldToggleMarkerGC, drawArea.X + drawArea.Width / 2, drawArea.Y + drawArea.Height * 2 / 10, drawArea.X + drawArea.Width / 2, drawArea.Y + drawArea.Height - drawArea.Height * 2 / 10); } }
public static Gdk.Pixbuf GetAsPixbuf(this IDrawingCell aCell, bool aFramed) { int fw = (aFramed == true) ? 1 : 0; Cairo.ImageSurface surface = new Cairo.ImageSurface(Cairo.Format.RGB24, System.Convert.ToInt32(aCell.Area.Width + 2), System.Convert.ToInt32(aCell.Area.Height + 2)); Cairo.Context context = new Cairo.Context(surface); CellRectangle rect = new CellRectangle(0, 0, aCell.Area.Width + (fw * 2), aCell.Area.Height + (fw * 2)); context.Color = new Cairo.Color(1, 1, 1); rect.DrawPath(context); // context.Rectangle (rect); context.FillPreserve(); context.Color = new Cairo.Color(0, 0, 0); if (aFramed == true) { context.Stroke(); rect = new CellRectangle(1, 1, aCell.Area.Width + 1, aCell.Area.Height + 1); } CellRectangle fake = new CellRectangle(0, 0, 9999999, 9999999); CellExposeEventArgs args = new CellExposeEventArgs(null, context, null, fake, rect); args.NeedsRecalculation = true; aCell.Paint(args); Gdk.Pixbuf px = surface.GetAsPixbuf(); ((IDisposable)context.Target).Dispose(); ((IDisposable)context).Dispose(); ((IDisposable)surface).Dispose(); return(px); }
protected override void CreatePassiveTexture(Clutter.CairoTexture texture, int with_state) { texture.Clear(); Cairo.Context context = texture.Create(); double lwidth = 1; double hlwidth = lwidth * 0.5; //Draw outline rectangles: DrawSmallCovers(context, texture.Width, texture.Height, lwidth); //Draw play icon: context.MoveTo((texture.Width - lwidth) * 0.5, 0.3 * (texture.Height - lwidth)); context.LineTo((texture.Width - lwidth) * 0.5, texture.Height - hlwidth); context.LineTo(texture.Width - hlwidth, 0.65 * (texture.Height - lwidth)); context.ClosePath(); context.LineWidth = lwidth; double sat = (with_state == 0 ? 0.4 : (with_state == 1 ? 0.6 : 0.8)); context.SetSourceRGBA(sat, sat, sat, 1.0); context.FillPreserve(); context.SetSourceRGB(1.0, 1.0, 1.0); context.Stroke(); ((IDisposable)context.Target).Dispose(); ((IDisposable)context).Dispose(); }
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(); }
//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(); }
private void OnDrawPage(object obj, Gtk.DrawPageArgs args) { PrintContext context = args.Context; Cairo.Context cr = context.CairoContext; double width = context.Width; cr.Rectangle(0, 0, width, headerHeight); cr.SetSourceRGB(0.8, 0.8, 0.8); cr.FillPreserve(); cr.SetSourceRGB(0, 0, 0); cr.LineWidth = 1; cr.Stroke(); Pango.Layout layout = context.CreatePangoLayout(); Pango.FontDescription desc = Pango.FontDescription.FromString("sans 14"); layout.FontDescription = desc; layout.SetText(fileName); layout.Width = (int)width; layout.Alignment = Pango.Alignment.Center; int layoutWidth, layoutHeight; layout.GetSize(out layoutWidth, out layoutHeight); double textHeight = (double)layoutHeight / (double)pangoScale; cr.MoveTo(width / 2, (headerHeight - textHeight) / 2); Pango.CairoHelper.ShowLayout(cr, layout); string pageStr = String.Format("{0}/{1}", args.PageNr + 1, numPages); layout.SetText(pageStr); layout.Alignment = Pango.Alignment.Right; cr.MoveTo(width - 2, (headerHeight - textHeight) / 2); Pango.CairoHelper.ShowLayout(cr, layout); layout = null; layout = context.CreatePangoLayout(); desc = Pango.FontDescription.FromString("mono"); desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; cr.MoveTo(0, headerHeight + headerGap); int line = args.PageNr * linesPerPage; for (int i = 0; i < linesPerPage && line < numLines; i++) { layout.SetText(lines[line]); Pango.CairoHelper.ShowLayout(cr, layout); cr.RelMoveTo(0, fontSize); line++; } (cr as IDisposable).Dispose(); layout = null; }
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(); }
//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(); }
//intro bottom tips public void IntroBottom(Cairo.Context g) { PointD p1, p2, p3, p4, s1, s2, s3, s4; p1 = new PointD(30, 10); p2 = new PointD(420, 10); s1 = new PointD(422, 12); s2 = new PointD(422, 88); p3 = new PointD(420, 90); p4 = new PointD(30, 90); s3 = new PointD(28, 88); s4 = new PointD(28, 12); g.Color = new Color(0.3, 0.4, 0.6, 0.8); g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1); g.ClosePath(); g.LineWidth = 1; g.Stroke(); g.MoveTo(p1); g.LineTo(p2); g.LineTo(s1); g.LineTo(s2); g.LineTo(p3); g.LineTo(p4); g.LineTo(s3); g.LineTo(s4); g.LineTo(p1); g.ClosePath(); Cairo.Gradient pat = new Cairo.LinearGradient(80, 20, 80, 80); pat.AddColorStop(0, new Cairo.Color(0.3, 0.4, 0.6, 0)); pat.AddColorStop(1, new Cairo.Color(0.3, 0.4, 0.6, 0.3)); g.Pattern = pat; g.FillPreserve(); g.Color = new Color(0, 0, 0, 0.8); g.SelectFontFace("", FontSlant.Italic, FontWeight.Bold); g.SetFontSize(18); g.MoveTo(new PointD(88, 28)); g.ShowText("."); g.MoveTo(new PointD(88, 58)); g.ShowText("."); g.SelectFontFace("", FontSlant.Italic, FontWeight.Normal); g.SetFontSize(10); g.MoveTo(new PointD(98, 30)); g.ShowText("Use the navigation on the left to choose different categories"); g.MoveTo(new PointD(98, 42)); g.ShowText("of your computer and system information to display."); g.MoveTo(new PointD(98, 60)); g.ShowText("When you click on a category in the navigation, the dynamic"); g.MoveTo(new PointD(98, 72)); g.ShowText("information is automatically refreshed."); g.MoveTo(new PointD(38, 35)); g.Color = new Color(0.3, 0.4, 0.6, 1); g.SelectFontFace("", FontSlant.Normal, FontWeight.Bold); g.SetFontSize(18); g.ShowText("Tips"); g.NewPath(); /* * g.Color = new Color (0.3, 0.4, 0.6, 0.8); * g.Scale (34, 34); * g.LineWidth = 0.06; * g.Arc (1.0, 1.0, 0.6, 0, 360); * g.Stroke ();*/ ((IDisposable)g.Target).Dispose(); ((IDisposable)g).Dispose(); }
public override void RealRenderCairo(Cairo.Context context) { //if (Camera.IsRendererOutOfScreen (this)) // return; context.MoveTo(Camera.WorldToScreenPosition(gameObject.transform.LocalToWorldPoint(points[len - 1])).ToPointD()); for (int i = 0; i < len; i++) { context.LineTo(Camera.WorldToScreenPosition(gameObject.transform.LocalToWorldPoint(points [i])).ToPointD()); } context.ClosePath(); if (surf == null) { context.SetSourceRGBA(ColorR, ColorG, ColorB, ColorA); context.Fill(); } else { int w = surf.Width; int h = surf.Height; Vector2 screenMinBound = Camera.WorldToScreenPosition(gameObject.transform.LocalToWorldPoint(minBound)); Vector2 screenMaxBound = Camera.WorldToScreenPosition(gameObject.transform.LocalToWorldPoint(maxBound)); int myH = (int)(screenMinBound.y - screenMaxBound.y); int posY = (int)screenMaxBound.y; while (myH > 0) { int posX = (int)screenMinBound.x; int myW = (int)(screenMaxBound.x - screenMinBound.x); while (myW > 0) { if (Camera.IsPointOutOfScreen(new Vector2(posX, posY)) && Camera.IsPointOutOfScreen(new Vector2(posX, posY + h)) && Camera.IsPointOutOfScreen(new Vector2(posX + w, posY)) && Camera.IsPointOutOfScreen(new Vector2(posX + w, posY + h))) { myW -= w; posX += w; continue; } context.SetSourceSurface(surf, posX, posY); context.FillPreserve(); myW -= w; posX += w; } myH -= h; posY += h; } context.SetSourceRGBA(ColorR, ColorG, ColorB, ColorA); context.Stroke(); //context.NewPath(); context.GetSource().Dispose(); } }
/* * void DrawBack () * { * // PaintFlatBox: null → nothing; "tooltip" → frame, "button" → solid * //Gtk.Style.PaintFlatBox (this.Style, this.GdkWindow, StateType.Normal, ShadowType.None, clipping_area, this, "tooltip", * // padLeft, padTop, backWidth, backHeight); * * // PaintBox: null → frame * Gtk.Style.PaintBox (this.Style, this.GdkWindow, StateType.Normal, ShadowType.None, clipping_area, this, null, * padLeft, padTop, backWidth, backHeight); * } */ void DrawBack(Cairo.Context cr) { Rectangle(cr, ref totalRect); if (!NoData && Sensitive) { SetColor(cr, ref ColorBack); cr.FillPreserve(); } SetColor(cr, ref ColorFrame); cr.Stroke(); }
public override void Draw(Context context) { RectangleD rect = DisplayBox; context.LineWidth = LineWidth; context.Rectangle (GdkCairoHelper.CairoRectangle (rect)); context.Color = FillColor; context.FillPreserve (); context.Color = LineColor; context.Stroke (); }
protected override void DrawFrame (Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor) { rect = DisplayBox; rect.OffsetDot5(); CairoFigures.AngleFrame(context, rect, 0, 0, 0, 0); Cairo.Color fillColorOrigin; fillColorOrigin = fillColor; lineWidth = 1; fillColor = new Cairo.Color (1.0, 1.0, 1.0, 1.0); context.Color = fillColor; context.FillPreserve(); context.Color = lineColor; context.LineWidth = lineWidth; double[] dash = {2, 0, 2}; context.SetDash (dash, 0); context.Stroke(); rect2 = DisplayBox; rect2.Width = DisplayBox.Width; rect2.Height = 30; rect2.OffsetDot5(); CairoFigures.AngleFrame(context, rect2, 0, 0, 0, 0); fillColor = fillColorOrigin; context.Color = fillColor; context.FillPreserve(); context.Color = lineColor; context.LineWidth = lineWidth; context.Stroke(); // HERZUM SPRINT 1.1 LOOP DrawScope (); // END HERZUM SPRINT 1.1 LOOP }
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 (); }
protected virtual void DrawBackground(Cairo.Context context, Gdk.Rectangle region) { LayoutRoundedRectangle(context, region); context.ClipPreserve(); using (LinearGradient lg = new LinearGradient(region.X, region.Y, region.X, region.Y + region.Height)) { lg.AddColorStop(0, Styles.StatusBarFill1Color); lg.AddColorStop(1, Styles.StatusBarFill4Color); context.SetSource(lg); context.FillPreserve(); } context.Save(); double midX = region.X + region.Width / 2.0; double midY = region.Y + region.Height; context.Translate(midX, midY); using (RadialGradient rg = new RadialGradient(0, 0, 0, 0, 0, region.Height * 1.2)) { rg.AddColorStop(0, Styles.StatusBarFill1Color); rg.AddColorStop(1, Styles.WithAlpha(Styles.StatusBarFill1Color, 0)); context.Scale(region.Width / (double)region.Height, 1.0); context.SetSource(rg); context.Fill(); } context.Restore(); using (LinearGradient lg = new LinearGradient(0, region.Y, 0, region.Y + region.Height)) { lg.AddColorStop(0, Styles.StatusBarShadowColor1); lg.AddColorStop(1, Styles.WithAlpha(Styles.StatusBarShadowColor1, Styles.StatusBarShadowColor1.A * 0.2)); LayoutRoundedRectangle(context, region, 0, -1); context.LineWidth = 1; context.SetSource(lg); context.Stroke(); } using (LinearGradient lg = new LinearGradient(0, region.Y, 0, region.Y + region.Height)) { lg.AddColorStop(0, Styles.StatusBarShadowColor2); lg.AddColorStop(1, Styles.WithAlpha(Styles.StatusBarShadowColor2, Styles.StatusBarShadowColor2.A * 0.2)); LayoutRoundedRectangle(context, region, 0, -2); context.LineWidth = 1; context.SetSource(lg); context.Stroke(); } context.ResetClip(); }
protected override bool OnDrawn(Cairo.Context cr) { if (this.isDirty) { this.Rebuild(); } bool baseDrawnResult = base.OnDrawn(cr); cr.SetFontSize(FONT_HEIGHT); cr.SelectFontFace("Mono", FontSlant.Normal, FontWeight.Normal); cr.Rectangle(0.0, 0.0, this.allocRect.Width, this.allocRect.Height); cr.SetSourceRGB(1, 1, 1); cr.Fill(); var gradient = new LinearGradient(0.0, 0.0, 0.0, this.allocRect.Height); gradient.AddColorStopRgb(0.0, new Color(0.4, 0.4, 0.4)); gradient.AddColorStopRgb(0.1, new Color(1.0, 1.0, 1.0)); gradient.AddColorStopRgb(0.2, new Color(0.6, 0.6, 0.6)); gradient.AddColorStopRgb(1.0, new Color(0.1, 0.1, 0.1)); cr.LineWidth = 1; foreach (var box in this.boxen) { this.RoundedRect(cr, box.Rect, 4.0); cr.SetSource(gradient); cr.FillPreserve(); cr.SetSourceRGB(0, 0, 0); cr.Stroke(); int x = (int)(box.Rect.X + TAGBOX_PADDING * 2 + TAGBOX_XSIZE); int y = (int)(box.Rect.Y + box.Rect.Height / 2 + cr.FontExtents.Height / 2 - cr.FontExtents.Descent / 2); cr.MoveTo(x, y); cr.TextPath(box.Tag); cr.SetSourceRGB(1.0, 1.0, 1.0); cr.Fill(); cr.MoveTo(box.Rect.X + TAGBOX_PADDING + TAGBOX_XOFFSET, box.Rect.Y + TAGBOX_PADDING + TAGBOX_XOFFSET); cr.RelLineTo(TAGBOX_XSIZE - TAGBOX_XOFFSET * 2, TAGBOX_XSIZE - TAGBOX_XOFFSET * 2); cr.MoveTo(box.Rect.X + TAGBOX_PADDING + TAGBOX_XOFFSET, box.Rect.Y + TAGBOX_PADDING + TAGBOX_XSIZE - TAGBOX_XOFFSET); cr.RelLineTo(TAGBOX_XSIZE - TAGBOX_XOFFSET * 2, -TAGBOX_XSIZE + TAGBOX_XOFFSET * 2); cr.Stroke(); } return(baseDrawnResult); }
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 (); }
private static void plotArc(int centerx, int centery, int radius, double start, double end, Cairo.Context g, Cairo.Color color) { //pie chart g.MoveTo(centerx, centery); g.Arc(centerx, centery, radius, start * Math.PI, end * Math.PI); g.ClosePath(); g.SetSourceRGB(color.R, color.G, color.B); g.FillPreserve(); g.SetSourceRGB(0, 0, 0); g.LineWidth = 2; g.Stroke(); }
void RenderButton(Cairo.Context context, Gdk.Point corner, double opacity, bool hovered) { Gdk.Rectangle region = new Gdk.Rectangle(corner.X, corner.Y, ButtonSize.Width, ButtonSize.Height); context.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 3); using (var lg = new LinearGradient(0, region.Top, 0, region.Bottom)) { if (hovered) { lg.AddColorStop(0, new Cairo.Color(.15, .76, .09, opacity)); lg.AddColorStop(1, new Cairo.Color(.41, .91, .46, opacity)); } else { lg.AddColorStop(0, new Cairo.Color(.41, .91, .46, opacity)); lg.AddColorStop(1, new Cairo.Color(.15, .76, .09, opacity)); } context.SetSource(lg); context.FillPreserve(); } context.SetSourceRGBA(.29, .79, .28, opacity); context.LineWidth = 1; context.Stroke(); region.Inflate(-1, -1); context.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 2); using (var lg = new LinearGradient(0, region.Top, 0, region.Bottom)) { lg.AddColorStop(0, new Cairo.Color(1, 1, 1, .74 * opacity)); lg.AddColorStop(0.1, new Cairo.Color(1, 1, 1, 0)); lg.AddColorStop(0.9, new Cairo.Color(0, 0, 0, 0)); lg.AddColorStop(1, new Cairo.Color(0, 0, 0, .34 * opacity)); context.SetSource(lg); context.Stroke(); } using (var layout = ButtonLayout(PangoContext)) { int w, h; layout.GetPixelSize(out w, out h); RenderShadowedText(context, new Gdk.Point(corner.X + ButtonSize.Width / 2 - w / 2, corner.Y + ButtonSize.Height / 2 - h / 2 - 1), opacity, layout); } }
// public void BeginPrint(object o, BeginPrintArgs args) // { // Console.WriteLine("BeginPrint"); // } public void DrawPage(object o, DrawPageArgs args) { Console.WriteLine("DrawPage"); Pango.Layout layout; int textWidth, textHeight; double width; FontDescription desc; Cairo.Context con = args.Context.CairoContext; width = args.Context.Width; // Rectangle con.Rectangle(0, 0, width, HEADER_HEIGHT); con.Color = new Cairo.Color(1, 0.2, 0.2, 0.6); con.FillPreserve(); // Draw another thing con.Color = new Cairo.Color(0, 0, 0); con.LineWidth = 1; con.Stroke(); con.Color = new Cairo.Color(0, 0, 0); con.MoveTo(20, 200); con.CurveTo(40, 270, 120, 165, 70, 60); con.Stroke(); con.MoveTo(30, 100); con.LineTo(60, 80); con.Stroke(); con.Color = new Cairo.Color(0, 0, 0); layout = args.Context.CreatePangoLayout(); layout.SetText("Prueba con Pango"); desc = FontDescription.FromString("arial 14"); layout.FontDescription = desc; layout.GetPixelSize(out textWidth, out textHeight); if (textWidth > width) { layout.Width = (int)width; layout.Ellipsize = EllipsizeMode.Start; layout.GetPixelSize(out textWidth, out textHeight); } con.MoveTo((width - textWidth) / 2, (HEADER_HEIGHT - textHeight) / 2); Pango.CairoHelper.ShowLayout(con, layout); }
void DrawMediaBox(Context cr, PdfPage page) { cr.MoveTo(margin + page.MediaBox.X1, margin + page.MediaBox.Y2); DrawHelper.DrawBox(cr, margin + page.MediaBox.X1, margin + page.MediaBox.Y2, pageWidth, pageHeight); cr.SetSourceColor(whiteColor); cr.FillPreserve(); cr.SetSourceColor(blackColor); cr.Stroke(); /*cr.SetSourceColor(shadowColor); * cr.MoveTo(margin + page.MediaBox.X1 + 2, margin + page.MediaBox.Y1 + 2); * DrawHelper.DrawBox(cr, margin + page.MediaBox.X1 + 2, margin + page.MediaBox.Y1 + 2, pageWidth, pageHeight); * cr.Stroke (); * cr.SetSourceColor(blackColor);*/ }
void DrawProgressBar(Cairo.Context context, double progress, Gdk.Rectangle bounding, StatusArea.RenderArg arg) { LayoutRoundedRectangle(context, new Gdk.Rectangle(bounding.X, bounding.Y, (int)(bounding.Width * progress), bounding.Height), 0, 0, 1); context.Clip(); LayoutRoundedRectangle(context, bounding, 0, 0, 1); context.SetSourceColor(Styles.WithAlpha(Styles.StatusBarProgressBackgroundColor, Styles.StatusBarProgressBackgroundColor.A * arg.ProgressBarAlpha)); context.FillPreserve(); context.ResetClip(); context.SetSourceColor(Styles.WithAlpha(Styles.StatusBarProgressOutlineColor, Styles.StatusBarProgressOutlineColor.A * arg.ProgressBarAlpha)); context.LineWidth = 1; context.Stroke(); }
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 (); }
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 (); }
private static void plotArc(int centerx, int centery, int radius, double start, double end, Cairo.Context g, Cairo.Color color) { //pie chart g.MoveTo(centerx, centery); g.Arc(centerx, centery, radius, start * Math.PI, end * Math.PI); //commented because gets ugly on last radius line (specially if angle is low) //g.ClosePath(); g.SetSourceRGB(color.R, color.G, color.B); g.FillPreserve(); g.SetSourceRGB(0, 0, 0); g.LineWidth = 2; g.Stroke(); }
public override void Draw (Context context, IDrawingView view) { RectangleD rect = ViewDisplayBox(view); context.LineWidth = LineWidth; context.MoveTo (rect.Center.X, rect.Top); context.LineTo (rect.Right, rect.Center.Y); context.LineTo (rect.Center.X, rect.Bottom); context.LineTo (rect.Left, rect.Center.Y); context.LineTo (rect.Center.X, rect.Top); context.Color = new Cairo.Color (1.0, 0.0, 0.0, 0.8); context.FillPreserve (); context.Color = new Cairo.Color (0.0, 0.0, 0.0, 1.0); context.Stroke (); }
void DrawFoldSegment(Cairo.Context ctx, double x, double y, bool isCollapsed) { var drawArea = new Cairo.Rectangle(System.Math.Floor(x + (Margin.Width - foldSegmentSize) / 2) + 0.5, System.Math.Floor(y + (Editor.LineHeight - foldSegmentSize) / 2) + 0.5, foldSegmentSize, foldSegmentSize); ctx.Rectangle(drawArea); var useSolidColor = isCollapsed || FoldMarkerOcapitiy >= 1; var drawColor = background; if (!useSolidColor) { drawColor.A = FoldMarkerOcapitiy; } ctx.SetSourceColor(drawColor); ctx.FillPreserve(); drawColor = foldLine; if (!useSolidColor) { drawColor.A = FoldMarkerOcapitiy; } ctx.SetSourceColor(drawColor); ctx.Stroke(); drawColor = foreground; if (!useSolidColor) { drawColor.A = FoldMarkerOcapitiy; } ctx.DrawLine(drawColor, drawArea.X + drawArea.Width * 2 / 10, drawArea.Y + drawArea.Height / 2, drawArea.X + drawArea.Width - drawArea.Width * 2 / 10, drawArea.Y + drawArea.Height / 2); if (isCollapsed) { ctx.DrawLine(drawColor, drawArea.X + drawArea.Width / 2, drawArea.Y + drawArea.Height * 2 / 10, drawArea.X + drawArea.Width / 2, drawArea.Y + drawArea.Height - drawArea.Height * 2 / 10); } }
protected override void CreateTexture(Clutter.CairoTexture texture, int with_state) { texture.Clear(); Cairo.Context context = texture.Create(); context.Translate(texture.Width * 0.5, texture.Height * 0.5); context.Arc(0, 0, (texture.Height - 1) * 0.5, 0, 2 * Math.PI); context.ClosePath(); context.SetSourceRGBA(1.0, 1.0, 1.0, with_state == 0 ? 0.3 : (with_state == 1 ? 0.5 : 0.7)); context.FillPreserve(); context.SetSourceRGB(1.0, 1.0, 1.0); context.LineWidth = 1; context.Stroke(); ((IDisposable)context.Target).Dispose(); ((IDisposable)context).Dispose(); }
public override void Render(Node node, Context context) { ButtonNode button = node as ButtonNode; context.RoundedRectangle (0.5, 0.5, button.Width - 1, button.Height - 1, button.Rounding); if (button.Relief) { using (var lg = new global::Cairo.LinearGradient (0, 0, 0, button.Height)) { CreateGradient (lg, button.State, button.Opacity); context.Pattern = lg; context.FillPreserve (); } context.LineWidth = 1; context.Color = new Color (0.8, 0.8, 0.8, button.Opacity).ToCairo (); context.Stroke (); } }
void DrawBackground(Cairo.Context context, Gdk.Rectangle region, int radius, StateType state) { double rad = radius - 0.5; int centerX = region.X + region.Width / 2; int centerY = region.Y + region.Height / 2; context.MoveTo(centerX + rad, centerY); context.Arc(centerX, centerY, rad, 0, Math.PI * 2); double high; double low; switch (state) { case StateType.Selected: high = 0.85; low = 1.0; break; case StateType.Prelight: high = 1.0; low = 0.9; break; case StateType.Insensitive: high = 0.95; low = 0.83; break; default: high = 1.0; low = 0.85; break; } using (var lg = new LinearGradient(0, centerY - rad, 0, centerY + rad)) { lg.AddColorStop(0, new Cairo.Color(high, high, high)); lg.AddColorStop(1, new Cairo.Color(low, low, low)); context.Pattern = lg; context.FillPreserve(); } context.Color = new Cairo.Color(0, 0, 0, 0.4); context.LineWidth = 1; context.Stroke(); }
void DrawShape(Context g, int width, int height) { int inner_x = radius + border + inner; int cx = Center.X; int cy = Center.Y; g.Operator = Operator.Source; g.SetSource (new SolidPattern (new Cairo.Color (0,0,0,0))); g.Rectangle (0, 0, width, height); g.Paint (); g.NewPath (); g.Translate (cx, cy); g.Rotate (angle); g.SetSource (new SolidPattern (new Cairo.Color (0.2, 0.2, 0.2, .6))); g.Operator = Operator.Over; g.Rectangle (0, - (border + inner), inner_x, 2 * (border + inner)); g.Arc (inner_x, 0, inner + border, 0, 2 * Math.PI); g.Arc (0, 0, radius + border, 0, 2 * Math.PI); g.Fill (); g.SetSource (new SolidPattern (new Cairo.Color (0, 0, 0, 1.0))); g.Operator = Operator.DestOut; g.Arc (inner_x, 0, inner, 0, 2 * Math.PI); #if true g.Fill (); #else g.FillPreserve (); g.Operator = Operator.Over; RadialGradient rg = new RadialGradient (inner_x - (inner * 0.3), inner * 0.3 , inner * 0.1, inner_x, 0, inner); rg.AddColorStop (0, new Cairo.Color (0.0, 0.2, .8, 0.5)); rg.AddColorStop (0.7, new Cairo.Color (0.0, 0.2, .8, 0.1)); rg.AddColorStop (1.0, new Cairo.Color (0.0, 0.0, 0.0, 0.0)); g.Source = rg; g.Fill (); rg.Destroy (); #endif g.Operator = Operator.Over; g.Matrix = new Matrix (); g.Translate (cx, cy); if (source != null) CairoHelper.SetSourcePixbuf (g, source, -source.Width / 2, -source.Height / 2); g.Arc (0, 0, radius, 0, 2 * Math.PI); g.Fill (); if (overlay != null) { CairoHelper.SetSourcePixbuf (g, overlay, -overlay.Width / 2, -overlay.Height / 2); g.Arc (0, 0, radius, angle, angle + Math.PI); g.ClosePath (); g.FillPreserve (); g.SetSource (new SolidPattern (new Cairo.Color (1.0, 1.0, 1.0, 1.0))); g.Stroke (); } }
private void RenderLabels (Context cr) { if (segments.Count == 0) { return; } Pango.Layout layout = null; Color text_color = CairoExtensions.GdkColorToCairoColor (Style.Foreground (State)); Color box_stroke_color = new Color (0, 0, 0, 0.6); int x = 0; foreach (Segment segment in segments) { cr.LineWidth = 1; cr.Rectangle (x + 0.5, 2 + 0.5, segment_box_size - 1, segment_box_size - 1); LinearGradient grad = MakeSegmentGradient (segment_box_size, segment.Color, true); cr.SetSource (grad); cr.FillPreserve (); cr.SetSourceColor (box_stroke_color); cr.Stroke (); grad.Dispose (); x += segment_box_size + segment_box_spacing; int lw, lh; layout = CreateAdaptLayout (layout, false, true); layout.SetText (FormatSegmentText (segment)); layout.GetPixelSize (out lw, out lh); cr.MoveTo (x, 0); text_color.A = 0.9; cr.SetSourceColor (text_color); PangoCairoHelper.ShowLayout (cr, layout); cr.Fill (); layout = CreateAdaptLayout (layout, true, false); layout.SetText (FormatSegmentValue (segment)); cr.MoveTo (x, lh); text_color.A = 0.75; cr.SetSourceColor (text_color); PangoCairoHelper.ShowLayout (cr, layout); cr.Fill (); x += segment.LayoutWidth + segment_label_spacing; } layout.Dispose (); }
protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point) { Document doc = PintaCore.Workspace.ActiveDocument; doc.ToolLayer.Hidden = true; if (surface_modified) PintaCore.History.PushNewItem (new SimpleHistoryItem (Icon, Name, undo_surface, doc.CurrentUserLayerIndex)); else if (undo_surface != null) (undo_surface as IDisposable).Dispose (); surface_modified = false; ImageSurface surf = doc.CurrentUserLayer.Surface; using (Context g = new Context (surf)) { g.AppendPath (doc.Selection.SelectionPath); g.FillRule = FillRule.EvenOdd; g.Clip (); g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None; if (path != null) { g.AppendPath (path); (path as IDisposable).Dispose (); path = null; } g.ClosePath (); g.LineWidth = BrushWidth; g.LineJoin = LineJoin.Round; g.LineCap = LineCap.Round; g.FillRule = FillRule.EvenOdd; if (FillShape && StrokeShape) { g.Color = fill_color; g.FillPreserve (); g.Color = outline_color; g.Stroke (); } else if (FillShape) { g.Color = outline_color; g.Fill (); } else { g.Color = outline_color; g.Stroke (); } } doc.Workspace.Invalidate (); }
private void DrawAttribute(Context context, bool selected) { SetupLayout (context); RectangleD displayBox = DisplayBox; displayBox.OffsetDot5(); context.LineWidth = LineWidth + (selected == true ? 2 : 0); context.Save (); context.MoveTo (displayBox.X + displayBox.Width / 2, displayBox.Y); context.LineTo (displayBox.X + displayBox.Width, displayBox.Y + displayBox.Height / 2); context.LineTo (displayBox.X + displayBox.Width / 2, displayBox.Y + displayBox.Height); context.LineTo (displayBox.X, displayBox.Y + displayBox.Height / 2); context.LineTo (displayBox.X + displayBox.Width / 2, displayBox.Y); context.Restore (); context.Color = FillColor; context.FillPreserve (); context.Color = LineColor; context.Stroke (); DrawText (context); }
private static void DrawArrowHead(Context context, PointD tip, PointD tail) { int arrowLength = 9; //can be adjusted double dx = tip.X - tail.X; double dy = tip.Y - tail.Y; double theta = Math.Atan2(dy, dx); double rad = ConvertToRadians(20); //35 angle, can be adjusted double x = tip.X - arrowLength * Math.Cos(theta + rad); double y = tip.Y - arrowLength * Math.Sin(theta + rad); double phi2 = ConvertToRadians(-20);//-35 angle, can be adjusted double x2 = tip.X - arrowLength * Math.Cos(theta + phi2); double y2 = tip.Y - arrowLength * Math.Sin(theta + phi2); context.MoveTo (tip); context.LineTo (new PointD(x, y)); context.LineTo (new PointD(x2, y2)); context.LineTo (tip); context.ClosePath (); context.FillPreserve (); context.Stroke (); }
private void DrawEntity(Context context, bool selected) { RectangleD displayBox = BasicDisplayBox; displayBox.OffsetDot5 (); context.LineWidth = LineWidth + (selected == true ? 2 : 0); context.Save (); context.Rectangle (new PointD (displayBox.X, displayBox.Y), displayBox.Width, displayBox.Height); if (WeakEntity) { context.Rectangle (new PointD (displayBox.X - 2, displayBox.Y - 2), displayBox.Width + 4, displayBox.Height + 4); } context.Save (); if (selected == true) { context.Color = new Color (0, 0, 0, 1); } else { context.Color = FillColor; context.FillPreserve (); context.Color = LineColor; } context.Stroke (); }
public override void Draw(Context context) { context.Save(); if(typeButton==kindButton.InverseTriangle){ context.LineWidth = LineWidth; if (!_clicked) { context.MoveTo (DisplayBox.TopLeft); context.LineTo (DisplayBox.TopRight); double middlePoint = Math.Abs (DisplayBox.BottomLeft.X - DisplayBox.BottomRight.X) / 2; context.LineTo (DisplayBox.BottomLeft.X + middlePoint, DisplayBox.BottomLeft.Y); context.LineTo (DisplayBox.TopLeft); } else { context.MoveTo (DisplayBox.TopLeft); context.LineTo (DisplayBox.BottomLeft); double middlePoint = Math.Abs (DisplayBox.TopRight.Y - DisplayBox.BottomRight.Y) / 2; context.LineTo (DisplayBox.BottomRight.X, DisplayBox.TopRight.Y + middlePoint); context.LineTo (DisplayBox.TopLeft); } context.Color = FillColor; context.FillPreserve (); context.Color = LineColor; context.Stroke (); } else if(typeButton==kindButton.PlusSymbol) { //TODO: create better figure context.LineWidth = LineWidth; Cairo.PointD tl=new Cairo.PointD(DisplayBox.TopLeft.X+1,DisplayBox.TopLeft.Y+1); Cairo.PointD tr=new Cairo.PointD(DisplayBox.TopRight.X-1,DisplayBox.TopRight.Y+1); Cairo.PointD bl=new Cairo.PointD(DisplayBox.BottomLeft.X+1,DisplayBox.BottomLeft.Y-1); Cairo.PointD br=new Cairo.PointD(DisplayBox.BottomRight.X-1,DisplayBox.BottomRight.Y-1); context.MoveTo (tl); context.LineTo (bl); context.LineTo (br); context.LineTo (tr); context.LineTo (tl); context.Color = new Cairo.Color(147,112,219); context.FillPreserve (); context.Color = LineColor; context.Stroke (); context.LineWidth = context.LineWidth - 0.2; context.MoveTo (tl.X+(tr.X-tl.X)/2,tl.Y); //middleTop context.LineTo (bl.X+(br.X-bl.X)/2,bl.Y); //middleBottom context.Stroke (); context.MoveTo (tl.X,tl.Y+(bl.Y-tl.Y)/2); //middleLeft context.LineTo (tr.X,tr.Y+(br.Y-tr.Y)/2); //middleRight context.Stroke (); } else if(typeButton==kindButton.LessSymbol) { //TODO: create better figure context.LineWidth = LineWidth; Cairo.PointD tl=new Cairo.PointD(DisplayBox.TopLeft.X+1,DisplayBox.TopLeft.Y+1); Cairo.PointD tr=new Cairo.PointD(DisplayBox.TopRight.X-1,DisplayBox.TopRight.Y+1); Cairo.PointD bl=new Cairo.PointD(DisplayBox.BottomLeft.X+1,DisplayBox.BottomLeft.Y-1); Cairo.PointD br=new Cairo.PointD(DisplayBox.BottomRight.X-1,DisplayBox.BottomRight.Y-1); context.MoveTo (tl); context.LineTo (bl); context.LineTo (br); context.LineTo (tr); context.LineTo (tl); context.Color = new Cairo.Color(0.57,0.43,0.85); context.FillPreserve (); context.Color = LineColor; context.Stroke (); context.MoveTo (tl.X,tl.Y+(bl.Y-tl.Y)/2); //middleLeft context.LineTo (tr.X,tr.Y+(br.Y-tr.Y)/2); //middleRight context.Stroke (); }else if(typeButton==kindButton.ForeignKeySymbol){ context.LineWidth = LineWidth; Cairo.PointD tl=new Cairo.PointD(DisplayBox.TopLeft.X+1,DisplayBox.TopLeft.Y+1); Cairo.PointD br=new Cairo.PointD(DisplayBox.BottomRight.X-1,DisplayBox.BottomRight.Y-1); context.MoveTo (tl); context.LineTo (br); context.Stroke (); context.Arc(tl.X,tl.Y,1,0,360); context.Stroke (); context.Arc(br.X,br.Y,1,0,360); context.Stroke (); }else if(typeButton==kindButton.RemoveSymbol){ context.LineWidth = LineWidth; Cairo.PointD tl=new Cairo.PointD(DisplayBox.TopLeft.X+1,DisplayBox.TopLeft.Y+1); Cairo.PointD tr=new Cairo.PointD(DisplayBox.TopRight.X-1,DisplayBox.TopRight.Y+1); Cairo.PointD bl=new Cairo.PointD(DisplayBox.BottomLeft.X+1,DisplayBox.BottomLeft.Y-1); Cairo.PointD br=new Cairo.PointD(DisplayBox.BottomRight.X-1,DisplayBox.BottomRight.Y-1); context.Color = new Cairo.Color(1,0,0); context.MoveTo (tl); context.LineTo (br); context.Stroke (); context.MoveTo (tr); context.LineTo (bl); context.Stroke (); } context.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); }
public void curve_rectangle(Context cr, int width, int height) { // a custom shape, that could be wrapped in a function double x0 = 0.1, //< parameters like cairo_rectangle y0 = 0.1, rect_width = 0.8, rect_height = 0.8, radius = 0.4; //< and an approximate curvature radius double x1,y1; Normalize(cr, width, height); x1=x0+rect_width; y1=y0+rect_height; if (rect_width/2<radius) { if (rect_height/2<radius) { cr.MoveTo(x0, (y0 + y1)/2); cr.CurveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0); cr.CurveTo(x1, y0, x1, y0, x1, (y0 + y1)/2); cr.CurveTo(x1, y1, x1, y1, (x1 + x0)/2, y1); cr.CurveTo(x0, y1, x0, y1, x0, (y0 + y1)/2); } else { cr.MoveTo(x0, y0 + radius); cr.CurveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0); cr.CurveTo(x1, y0, x1, y0, x1, y0 + radius); cr.LineTo(x1 , y1 - radius); cr.CurveTo(x1, y1, x1, y1, (x1 + x0)/2, y1); cr.CurveTo(x0, y1, x0, y1, x0, y1- radius); } } else { if (rect_height/2<radius) { cr.MoveTo(x0, (y0 + y1)/2); cr.CurveTo(x0 , y0, x0 , y0, x0 + radius, y0); cr.LineTo(x1 - radius, y0); cr.CurveTo(x1, y0, x1, y0, x1, (y0 + y1)/2); cr.CurveTo(x1, y1, x1, y1, x1 - radius, y1); cr.LineTo(x0 + radius, y1); cr.CurveTo(x0, y1, x0, y1, x0, (y0 + y1)/2); } else { cr.MoveTo(x0, y0 + radius); cr.CurveTo(x0 , y0, x0 , y0, x0 + radius, y0); cr.LineTo(x1 - radius, y0); cr.CurveTo(x1, y0, x1, y0, x1, y0 + radius); cr.LineTo(x1 , y1 - radius); cr.CurveTo(x1, y1, x1, y1, x1 - radius, y1); cr.LineTo(x0 + radius, y1); cr.CurveTo(x0, y1, x0, y1, x0, y1- radius); } } cr.ClosePath(); // and fill/stroke it cr.Color = new Color (0.5, 0.5, 1); cr.FillPreserve(); cr.Color = new Color (0.5, 0, 0, 0.5); cr.Stroke(); }
bool DrawEffects(Context cr, uint w, uint h) { if (!SillyFlare) return false; if (FlareGradient == null) { FGRadius = Helpers.ImageWidth(FlareGradientImage); FlareGradient = Helpers.RadialGradientFromImage(FlareGradientImage); BlackGradient = new RadialGradient(0,0,0, 0,0,FGRadius); BlackGradient.AddColorStop(0, new Color(0,0,0,1)); BlackGradient.AddColorStop(1, new Color(0,0,0,0)); FlareSpike = new ImageSurface(FlareSpikeImage); RainbowSprite = new ImageSurface(RainbowSpriteImage); } cr.Save (); // double t = DateTime.Now.ToFileTime() / 1e7; double dx = flareTargetX - flareX; double dy = flareTargetY - flareY; flareX += dx / 20; flareY += dy / 20; double s = Math.Min(1, Math.Max(0.02, 0.35 / (1 + 0.002*(dx*dx + dy*dy)))); if (s < 0.03) s *= 1 + rng.NextDouble(); cr.Translate(flareX, flareY); cr.Save (); cr.Scale (s, s); /* cr.Arc(0, 0, FGRadius, 0, Math.PI * 2); cr.Source = BlackGradient; cr.Operator = Operator.Over;*/ cr.FillPreserve (); cr.Source = FlareGradient; cr.Operator = Operator.Add; cr.Fill (); cr.Restore (); cr.Save (); cr.Scale (s, s); cr.Operator = Operator.Add; using (SurfacePattern p = new SurfacePattern(RainbowSprite)) { cr.Save (); cr.Translate (10, -RainbowSprite.Height/2); cr.Rectangle (0, 0, RainbowSprite.Width, RainbowSprite.Height); cr.Source = p; cr.Fill (); cr.Restore (); cr.Save (); cr.Scale(-1, 1); cr.Translate (10, -RainbowSprite.Height/2); cr.Rectangle (0, 0, RainbowSprite.Width, RainbowSprite.Height); cr.Source = p; cr.Fill (); cr.Restore (); } cr.Restore (); cr.Save (); cr.Scale (Math.Sqrt(s), Math.Sqrt(s)); using (SurfacePattern p = new SurfacePattern(FlareSpike)) { cr.Translate (-FlareSpike.Width/2.0, -FlareSpike.Height/2.0); cr.Rectangle (0, 0, FlareSpike.Width, FlareSpike.Height); cr.Operator = Operator.Add; cr.Source = p; cr.Fill (); } cr.Restore (); cr.Restore (); if (dx*dx < 1 && dy*dy < 1) return false; return true; }
protected void PaintContour(Context ctx, PointD size) { ctx.Rectangle (0.0d, 0.0d, size.X, size.Y); ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern (size.X, this.TypeColors); ctx.FillPreserve (); ctx.Color = KnownColors.Black; ctx.Stroke (); }
public virtual void Paint(Context ctx) { PointD size = this.MeasureSize (ctx); PaintContour (ctx,size); KnownColors.SetFontFacePieceName(ctx); TextExtents te = ctx.TextExtents(this.Name), ten; double y0 = 0.5d*(size.Y-te.Width); ctx.MoveTo(0.5d*Margin,y0); ctx.Save(); ctx.Rotate(0.5d*Math.PI); ctx.ShowText(this.Name); ctx.Restore(); double x0 = Margin+te.Height; KnownColors.SetFontFaceNormal(ctx); te = ctx.TextExtents(OptionalString); y0 = 2.0d*Margin; int index = 0x00; PointD siz; foreach(IPuzzlePiece ipp in this.arguments) { ctx.Save(); ctx.Translate(x0,Margin); if(ipp == null) { siz = new PointD(MinimumWidth,size.Y-4.0d*Margin); ctx.Rectangle(Margin,Margin,siz.X,siz.Y); ctx.Pattern = KnownColors.ConstructionPattern; ctx.FillPreserve(); } else { siz = ipp.MeasureSize(ctx); } ctx.Rectangle(0.0d,0.0d,siz.X+2.0d*Margin,siz.Y+2.0d*Margin); ctx.Color = KnownColors.Black; ctx.StrokePreserve(); if(ipp == null) { ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern(siz.X+2.0d*Margin,TypeColorArguments[index]); ctx.Fill(); ctx.Translate(Margin,Margin); ctx.MoveTo(0.0d,0.0d); ctx.LineTo(MinimumWidth,0.0d); ctx.RelLineTo(0.0d,5.0d); ctx.LineTo(5.0d,5.0d); ctx.ClosePath(); ctx.Pattern = KnownColors.ShadowDownPattern; ctx.Fill(); ctx.MoveTo(0.0d,0.0d); ctx.LineTo(0.0d,siz.Y); ctx.RelLineTo(5.0d,0.0d); ctx.LineTo(5.0d,5.0d); ctx.ClosePath(); ctx.Pattern = KnownColors.ShadowRightPattern; ctx.Fill(); } else { ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern(siz.X+2.0d*Margin,TypeColorArguments[index]); ctx.Fill(); ctx.Color = KnownColors.Black; ctx.Translate(Margin,Margin); ipp.Paint(ctx); } ctx.Restore(); subpieces[index] = new Rectangle(x0+Margin,2.0d*Margin,siz.X,siz.Y); x0 += siz.X+3.0d*Margin; if(index >= NumberOfArguments-NumberOfOptionalArguments) { ctx.MoveTo(x0-2.0d*Margin-0.5d*(siz.X+te.Width),siz.Y+3.0d*Margin-2.0d); ctx.ShowText(OptionalString); } if(this.ArgumentNames != null && index < arguments.Length) { ten = ctx.TextExtents(this.ArgumentNames[index]); ctx.MoveTo(x0-2.0d*Margin-0.5d*(siz.X+ten.Width),-te.YBearing+Margin+2.0d); ctx.ShowText(this.ArgumentNames[index]); } index++; } }
protected void Draw(Context cr) { double x, y; double radius; int i; int hours, minutes, seconds; x = Allocation.Width / 2; y = Allocation.Height / 2; radius = Math.Min(Allocation.Width / 2, Allocation.Height / 2) - 5; /* clock back */ cr.Arc(x, y, radius, 0, 2 * Math.PI); cr.SetSourceRGB(1, 1, 1); cr.FillPreserve(); cr.SetSourceRGB(0, 0, 0); cr.Stroke(); /* clock ticks */ for (i = 0; i < 12; i++) { double inset; cr.Save(); /* stack-pen-size */ if (i % 3 == 0) { inset = 0.2 * radius; } else { inset = 0.1 * radius; cr.LineWidth *= 0.5; } cr.MoveTo( x + (radius - inset) * Math.Cos (i * Math.PI / 6), y + (radius - inset) * Math.Sin (i * Math.PI / 6)); cr.LineTo( x + radius * Math.Cos (i * Math.PI / 6), y + radius * Math.Sin (i * Math.PI / 6)); cr.Stroke(); cr.Restore(); /* stack-pen-size */ } /* clock hands */ hours = DateTime.Now.Hour; minutes = DateTime.Now.Minute; seconds = DateTime.Now.Second; /* hour hand: * the hour hand is rotated 30 degrees (pi/6 r) per hour + * 1/2 a degree (pi/360 r) per minute */ cr.Save(); cr.LineWidth *= 2.5; cr.MoveTo(x, y); cr.LineTo(x + radius / 2 * Math.Sin (Math.PI / 6 * hours + Math.PI / 360 * minutes), y + radius / 2 * -Math.Cos (Math.PI / 6 * hours + Math.PI / 360 * minutes)); cr.Stroke(); cr.Restore(); /* minute hand: * the minute hand is rotated 6 degrees (pi/30 r) per minute */ cr.MoveTo(x, y); cr.LineTo(x + radius * 0.75 * Math.Sin (Math.PI / 30 * minutes), y + radius * 0.75 * -Math.Cos (Math.PI / 30 * minutes)); cr.Stroke(); /* seconds hand: * operates identically to the minute hand */ cr.Save(); cr.SetSourceRGB(1, 0, 0); /* red */ cr.MoveTo(x, y); cr.LineTo(x + radius * 0.7 * Math.Sin (Math.PI / 30 * seconds), y + radius * 0.7 * -Math.Cos (Math.PI / 30 * seconds)); cr.Stroke(); cr.Restore(); }
private void RenderBarSegments (Context cr, int w, int h, int r) { LinearGradient grad = new LinearGradient (0, 0, w, 0); double last = 0.0; foreach (Segment segment in segments) { if (segment.Percent > 0) { grad.AddColorStop (last, segment.Color); grad.AddColorStop (last += segment.Percent, segment.Color); } } CairoExtensions.RoundedRectangle (cr, 0, 0, w, h, r); cr.SetSource (grad); cr.FillPreserve (); cr.GetSource ().Dispose (); grad = new LinearGradient (0, 0, 0, h); grad.AddColorStop (0.0, new Color (1, 1, 1, 0.125)); grad.AddColorStop (0.35, new Color (1, 1, 1, 0.255)); grad.AddColorStop (1, new Color (0, 0, 0, 0.4)); cr.SetSource (grad); cr.Fill (); cr.GetSource ().Dispose (); }
private void paintNodes(Context ctx, int w, int h, IEnumerable<Node> nodes) { ctx.LineWidth = 2.0d; foreach(Node node in nodes) { PointD abs = new PointD(node.Item2.X*w, node.Item2.Y*h); ctx.Arc(abs.X, abs.Y, AlgorithmRadius, 0.0d, 2.0d*Math.PI); ctx.ClosePath(); ctx.NewSubPath(); ctx.Arc(abs.X, abs.Y, AlgorithmRadius-BlueprintStyle.Thickness, 0.0d, 2.0d*Math.PI); ctx.ClosePath(); ctx.NewSubPath(); } ctx.Pattern = BlueprintStyle.FillPattern; ctx.FillPreserve(); ctx.Color = BlueprintStyle.HardWhite; ctx.Stroke(); double r_2, dx, dy; this.nodeCenters.Clear(); foreach(Node node in nodes) { PointD abs = new PointD(node.Item2.X*w, node.Item2.Y*h); this.nodeCenters.Add(abs); TextExtents te = ctx.TextExtents(node.Item1); r_2 = (AlgorithmRadius-BlueprintStyle.Thickness)/Math.Sqrt(te.Width*te.Width+te.Height*te.Height); ctx.Save(); ctx.MoveTo(abs.X-r_2*te.Width, abs.Y+r_2*te.Height); ctx.Scale(2.0d*r_2, 2.0d*r_2); ctx.ShowText(node.Item1); ctx.Restore(); } }
public override void DrawArrow(Context cr, Gdk.Rectangle alloc, SortType type) { cr.LineWidth = 1; cr.Translate (0.5, 0.5); double x1 = alloc.X; double x3 = alloc.X + alloc.Width / 2.0; double x2 = x3 + (x3 - x1); double y1 = alloc.Y; double y2 = alloc.Bottom; if (type == SortType.Ascending) { cr.MoveTo (x1, y1); cr.LineTo (x2, y1); cr.LineTo (x3, y2); cr.LineTo (x1, y1); } else { cr.MoveTo (x3, y1); cr.LineTo (x2, y2); cr.LineTo (x1, y2); cr.LineTo (x3, y1); } cr.SetSourceColor (Colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal)); cr.FillPreserve (); cr.SetSourceColor (Colors.GetWidgetColor (GtkColorClass.Text, StateType.Normal)); cr.Stroke (); cr.Translate (-0.5, -0.5); }
public void fill_and_stroke2(Context cr, int width, int height) { Normalize (cr, width, height); cr.MoveTo(0.5, 0.1); cr.LineTo(0.9, 0.9); cr.RelLineTo(-0.4, 0.0); cr.CurveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5); cr.ClosePath(); cr.MoveTo(0.25, 0.1); cr.RelLineTo(0.2, 0.2); cr.RelLineTo(-0.2, 0.2); cr.RelLineTo(-0.2, -0.2); cr.ClosePath(); cr.Color = new Color (0, 0, 1); cr.FillPreserve(); cr.Color = new Color (0, 0, 0); cr.Stroke(); }
public override void DrawArrow (Context cr, Gdk.Rectangle alloc, double rotation) { rotation -= Math.PI / 2.0; double x1 = alloc.X; double x2 = alloc.Right; double x3 = alloc.X + alloc.Width / 2.0; double y1 = alloc.Y; double y2 = alloc.Bottom; double cx = x3; double cy = alloc.Y + alloc.Height / 2.0; if (rotation != 0) { // Rotate about the center of the arrow cr.Translate (cx, cy); cr.Rotate (rotation); cr.Translate (-cx, -cy); } cr.LineWidth = 1.0; bool hz = (rotation % (Math.PI / 2.0)) == 0; double dx = hz ? 0 : 0.5; double dy = hz ? 0.5 : 0.5; cr.Translate (dx, dy); cr.MoveTo (x1, y1); cr.LineTo (x2, y1); cr.LineTo (x3, y2); cr.LineTo (x1, y1); cr.Color = Colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal); cr.FillPreserve (); cr.Color = Colors.GetWidgetColor (GtkColorClass.Text, StateType.Normal); cr.Stroke (); cr.Translate (-dx, -dy); if (rotation != 0) { cr.Translate (cx, cy); cr.Rotate (-rotation); cr.Translate (-cx, -cy); } }
public void DrawRoundedRectThumb(Context gc, double x, double y, double width, double height, double radius, double strokeWidth, Cairo.Color backgroundColor, Cairo.Color strokeColor, Gdk.Pixbuf image, double imageWidth, double imageHeight) { gc.Save (); double imagex, imagey; //double x1 = x + width; //double y1 = y + height; double pixbufScale; if (image.Width > image.Height) pixbufScale = imageWidth / image.Width; else pixbufScale = imageHeight / image.Height; Gdk.Pixbuf scaledImage = image.ScaleSimple ((int)Math.Round (image.Width * pixbufScale), (int)Math.Round (image.Height * pixbufScale), InterpType.Bilinear); imagex = GridAlign ((x + (width / 2)) - ((double) scaledImage.Width / 2)); imagey = GridAlign ((y + (height / 2)) - ((double) scaledImage.Height / 2)); this.CreateRoundedRectPath (gc, x, y, width, height, radius); gc.Color = backgroundColor; gc.LineWidth = strokeWidth; gc.FillPreserve (); Gdk.CairoHelper.SetSourcePixbuf (gc, scaledImage, imagex, imagey); gc.FillPreserve (); gc.Color = strokeColor; gc.Stroke (); gc.Restore (); scaledImage.Dispose(); }
/// <summary>Draws a ribbon.</summary> public void DrawRibbon (Context cr, Gdk.Rectangle bodyAllocation, double roundSize, double lineWidth, Ribbon widget) { double lineWidth05 = lineWidth / 2; double lineWidth15 = 3 * lineWidth05; double x0, x1, y0, y1; LinearGradient linGrad; Ribbon.RibbonPage p = widget.CurrentPage; if(p != null) { //Color c = ColorScheme.GetColor(colorScheme.Bright, 0.92); Color c = colorScheme.Normal; if(bodyAllocation.Height > 0) { /*** PAGE ***/ x0 = bodyAllocation.X; x1 = bodyAllocation.X + bodyAllocation.Width; y0 = bodyAllocation.Y; y1 = bodyAllocation.Y + bodyAllocation.Height; cr.Arc (x0 + roundSize, y1 - roundSize, roundSize - lineWidth05, Math.PI/2, Math.PI); cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3*Math.PI/2); cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3*Math.PI/2, 0); cr.Arc (x1 - roundSize, y1 - roundSize, roundSize - lineWidth05, 0, Math.PI/2); cr.LineTo (x0 + roundSize, y1 - lineWidth05); /*** BACKGOUND ***/ cr.Color = c; cr.FillPreserve (); /*** DARK BORDER ***/ cr.LineWidth = lineWidth; cr.Color = ColorScheme.GetColorAbsolute (colorScheme.Normal, 0.75); cr.Stroke (); /*** GLASS EFFECT ***/ double ymid = Math.Round(y0 + (y1 - y0) * 0.25); cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth, Math.PI, 3*Math.PI/2); cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth, 3*Math.PI/2, 0); cr.LineTo (x1 - lineWidth, ymid); cr.LineTo (x0 + lineWidth, ymid); cr.LineTo (x0 + lineWidth, y0 + roundSize); linGrad = new LinearGradient (0, y0, 0, ymid); linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.0)); linGrad.AddColorStop (1.0, new Color (0, 0, 0, 0.075)); cr.Pattern = linGrad; cr.Fill (); cr.Arc (x0 + roundSize, y1 - roundSize, roundSize - lineWidth, Math.PI/2, Math.PI); cr.LineTo (x0 + lineWidth, ymid); cr.LineTo (x1 - lineWidth, ymid); cr.Arc (x1 - roundSize, y1 - roundSize, roundSize - lineWidth, 0, Math.PI/2); cr.LineTo (x0 + roundSize, y1 - lineWidth); linGrad = new LinearGradient (0, ymid, 0, y1); linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.1)); linGrad.AddColorStop (0.5, new Color (0, 0, 0, 0.0)); cr.Pattern = linGrad; cr.Fill (); } /*** TAB ***/ Gdk.Rectangle r = p.LabelAllocation; x0 = r.X; x1 = r.X + r.Width; y0 = r.Y; y1 = r.Y + r.Height + lineWidth; /*** TAB :: BACKGROUND ***/ cr.MoveTo (x0 + lineWidth05, y1); cr.LineTo (x0 + lineWidth05, y0 + roundSize); cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3*Math.PI/2); cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3*Math.PI/2, 0); cr.LineTo (x1 - lineWidth05, y1); linGrad = new LinearGradient (0, y0, 0, y1); linGrad.AddColorStop (0.0, colorScheme.PrettyBright); linGrad.AddColorStop (1.0, c); cr.Pattern = linGrad; cr.Fill (); /*** TAB :: DARK BORDER ***/ cr.MoveTo (x0 + lineWidth05, y1); cr.LineTo (x0 + lineWidth05, y0 + roundSize); cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3*Math.PI/2); cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3*Math.PI/2, 0); cr.LineTo (x1 - lineWidth05, y1); cr.LineWidth = lineWidth; cr.Color = ColorScheme.GetColorRelative (colorScheme.Bright, -0.1); cr.Stroke (); y1 -= 1.0; /*** TAB :: HIGHLIGHT ***/ cr.MoveTo (x0 + lineWidth15, y1); cr.LineTo (x0 + lineWidth15, y0 + roundSize); cr.Arc (x0 + roundSize, y0 + roundSize, roundSize - lineWidth15, Math.PI, 3*Math.PI/2); cr.Arc (x1 - roundSize, y0 + roundSize, roundSize - lineWidth15, 3*Math.PI/2, 0); cr.LineTo (x1 - lineWidth15, y1); cr.LineWidth = lineWidth; linGrad = new LinearGradient (0, y0+lineWidth, 0, y1); linGrad.AddColorStop (0.0, colorScheme.PrettyBright); linGrad.AddColorStop (1.0, ColorScheme.SetAlphaChannel (colorScheme.Bright, 0)); cr.Pattern = linGrad; cr.Stroke (); /*** TAB :: SHADOW ***/ cr.MoveTo (x0 - lineWidth05, y1); cr.LineTo (x0 - lineWidth05, y0 + roundSize); cr.Arc (x0 + roundSize, y0 + roundSize, roundSize + lineWidth05, Math.PI, 3*Math.PI/2); cr.Arc (x1 - roundSize, y0 + roundSize, roundSize + lineWidth05, 3*Math.PI/2, 0); cr.LineTo (x1 + lineWidth05, y1); cr.LineWidth = lineWidth; cr.Color = new Color (0, 0, 0, 0.2); cr.Stroke (); } }
public void DrawRoundedRect(Context gc, double x, double y, double width, double height, double radius, double strokeWidth, Cairo.Color backgroundColor, Cairo.Color strokeColor) { gc.Save (); this.CreateRoundedRectPath (gc, x, y, width, height, radius); gc.LineWidth = strokeWidth; gc.Color = backgroundColor; gc.FillPreserve (); gc.Color = strokeColor; gc.Stroke (); gc.Restore (); }
public override void DrawBackground (Mono.TextEditor.MonoTextEditor editor, Context cr, LineMetrics metrics, int startOffset, int endOffset) { int markerStart = usage.Offset; int markerEnd = usage.EndOffset; if (markerEnd < startOffset || markerStart > endOffset) return; double @from; double to; var startXPos = metrics.TextRenderStartPosition; var endXPos = metrics.TextRenderEndPosition; var y = metrics.LineYRenderStartPosition; if (markerStart < startOffset && endOffset < markerEnd) { @from = startXPos; to = endXPos; } else { int start = startOffset < markerStart ? markerStart : startOffset; int end = endOffset < markerEnd ? endOffset : markerEnd; uint curIndex = 0, byteIndex = 0; TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex); int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale); TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex); x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; to = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } @from = Math.Max (@from, editor.TextViewMargin.XOffset); to = Math.Max (to, editor.TextViewMargin.XOffset); if (@from < to) { Mono.TextEditor.Highlighting.AmbientColor colorStyle; if ((usage.UsageType & ReferenceUsageType.Write) == ReferenceUsageType.Write || (usage.UsageType & ReferenceUsageType.Declariton) == ReferenceUsageType.Declariton) { colorStyle = editor.ColorStyle.ChangingUsagesRectangle; } else { colorStyle = editor.ColorStyle.UsagesRectangle; } using (var lg = new LinearGradient (@from + 1, y + 1, to , y + editor.LineHeight)) { lg.AddColorStop (0, colorStyle.Color); lg.AddColorStop (1, colorStyle.SecondColor); cr.SetSource (lg); cr.RoundedRectangle (@from + 0.5, y + 1.5, to - @from - 1, editor.LineHeight - 2, editor.LineHeight / 4); cr.FillPreserve (); } cr.SetSourceColor (colorStyle.BorderColor); cr.Stroke (); } }
protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point) { Document doc = PintaCore.Workspace.ActiveDocument; if ((args.Event.State & Gdk.ModifierType.Button1Mask) == Gdk.ModifierType.Button1Mask) { outline_color = PintaCore.Palette.PrimaryColor; fill_color = PintaCore.Palette.SecondaryColor; } else if ((args.Event.State & Gdk.ModifierType.Button3Mask) == Gdk.ModifierType.Button3Mask) { outline_color = PintaCore.Palette.SecondaryColor; fill_color = PintaCore.Palette.PrimaryColor; } else { last_point = point_empty; return; } int x = (int)point.X; int y = (int)point.Y; if (last_point.Equals (point_empty)) { last_point = new Point (x, y); return; } if (doc.Workspace.PointInCanvas (point)) surface_modified = true; doc.ToolLayer.Clear (); ImageSurface surf = doc.ToolLayer.Surface; using (Context g = new Context (surf)) { doc.Selection.Clip(g); g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None; if (path != null) { g.AppendPath (path); (path as IDisposable).Dispose (); } else { g.MoveTo (x, y); } g.LineTo (x, y); path = g.CopyPath (); g.ClosePath (); g.LineWidth = BrushWidth; g.LineJoin = LineJoin.Round; g.LineCap = LineCap.Round; g.FillRule = FillRule.EvenOdd; if (FillShape && StrokeShape) { g.Color = fill_color; g.FillPreserve (); g.Color = outline_color; g.Stroke (); } else if (FillShape) { g.Color = outline_color; g.Fill (); } else { g.Color = outline_color; g.Stroke (); } } doc.Workspace.Invalidate (); last_point = new Point (x, y); }