public static void ShadowedText(Cairo.Context g, Cairo.Color c, string text, double x, double y) { g.Save(); g.MoveTo(x + SHADOW_SPACING, y + SHADOW_SPACING); g.Color = Colors.BLACK; g.ShowText(text); g.MoveTo(x, y); g.Color = c; g.ShowText(text); g.Restore(); }
public static void ShadowedText(Cairo.Context g, Cairo.Color c, string text, double x, double y, string font, int point) { g.Save(); g.SelectFontFace(font, FontSlant.Normal, FontWeight.Normal); g.SetFontSize(point); g.MoveTo(x + SHADOW_SPACING, y + SHADOW_SPACING); g.Color = Colors.BLACK; g.ShowText(text); g.MoveTo(x, y); g.Color = c; g.ShowText(text); g.Restore(); }
public static void Draw(Cairo.Context ctx, object backend, double x, double y) { var la = (LayoutBackend) backend; var text = la.Text; var h = ctx.FontExtents.Ascent; y += h; ctx.MoveTo (x, y); if (la.Font != null) { ctx.SelectFont (la.Font); ctx.SetFontSize (la.Font.Size); } if (la.Width == -1) { ctx.ShowText (text); return; } if (!la.Measured) Measure (backend); // Render word by word int lastStart = 0; for (int i=0; i < la.LineBreaks.Count; i++) { if (la.Heigth != -1 && h > la.Heigth) break; var n = la.LineBreaks [i]; string s = text.Substring (lastStart, n - lastStart).TrimEnd('\n','\r'); ctx.ShowText (s); var lh = la.LineHeights [i]; h += lh; y += lh; ctx.MoveTo (x, y); lastStart = n; } }
static void draw (Cairo.Context gr, int width, int height) { gr.Scale (width, height); gr.LineWidth = 0.04; gr.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold); gr.SetFontSize (0.35); gr.MoveTo ( new PointD(0.04, 0.53) ); gr.ShowText ("Hello"); gr.MoveTo ( new PointD(0.27, 0.65) ); gr.TextPath ("void"); gr.ColorRgb = new Color (0.5, 0.5, 1, 0); gr.FillPreserve (); gr.ColorRgb = new Color (0, 0, 0, 0); gr.LineWidth = 0.01; gr.Stroke (); gr.Color = new Color (1,0.2,0.2, 0.6); gr.Arc (0.04, 0.53, 0.02, 0, 2*M_PI); gr.Arc (0.27, 0.65, 0.02, 0, 2*M_PI); gr.Fill (); }
void draw_grid(Cairo.Context gr, int w, int h) { double y_interval, y_spacing; double pixels = 80; double num_ticks = h/pixels; double interval = max_y/num_ticks; double min_size = 1; while (true) { double new_size = min_size * 10; if (new_size < interval) { min_size = new_size; continue; } break; } y_spacing = pixels * min_size/interval; y_interval = min_size; gr.Color = new Color (0.4, 0.4, 0.4, 1); gr.LineWidth = .5; double y_label = 0; for (double i = h; i >= 0; i -= y_spacing) { gr.MoveTo (0, i); gr.LineTo (w, i); gr.Stroke (); gr.LineTo (5, i); gr.ShowText (GetLabel (y_label)); y_label += y_interval; } }
public void DrawIcon(TextEditor editor, Cairo.Context cr, DocumentLine lineSegment, int lineNumber, double x, double y, double width, double height) { if (BookmarkService.Instance.CheckLineForBookmark (editor.FileName, lineSegment.LineNumber)) { Cairo.Color color1 = editor.ColorStyle.Bookmarks.Color; Cairo.Color color2 = editor.ColorStyle.Bookmarks.SecondColor; if (Bookmark.BookmarkType == BookmarkType.Local) DrawRoundRectangle (cr, x + 1, y + 1, 8, width - 4, height - 4); else DrawCircle (cr, x + (width / 2), y + (height / 2), 6); using (var pat = new Cairo.LinearGradient (x + width / 4, y, x + width / 2, y + height - 4)) { pat.AddColorStop (0, color1); pat.AddColorStop (1, color2); cr.Pattern = pat; cr.FillPreserve (); } using (var pat = new Cairo.LinearGradient (x, y + height, x + width, y)) { pat.AddColorStop (0, color2); //pat.AddColorStop (1, color1); cr.Pattern = pat; cr.Stroke (); } cr.Color = new Cairo.Color (0, 0, 0); cr.SelectFontFace (DesktopService.DefaultMonospaceFont, Cairo.FontSlant.Normal, Cairo.FontWeight.Bold); cr.SetFontSize (12); var te = cr.TextExtents (Bookmark.Number.ToString ()); cr.MoveTo (x + 5, y + 1 + te.Height); cr.ShowText (Bookmark.Number.ToString ()); } }
private static unsafe void DrawWindow(GuiRequest *request, byte[] xData) { request->Type = RequestType.NewWindow; request->Error = ErrorType.None; var window = (NewWindow *)request; window->X = 340; window->Y = 159; window->Width = 600; window->Height = 450; Compositor.Server.Write(xData); SystemClient.Read(xData); if (request->Error != ErrorType.None) { Debug.Write("Error5: %d\n", (int)request->Error); return; } string HashCode = new string(window->Buffer); var aBuffer = SHM.Obtain(HashCode, 0, false); int winID = window->WindowID; Debug.Write("winID: %d\n", winID); uint surface = Cairo.ImageSurfaceCreateForData(600 * 4, 450, 600, ColorFormat.ARGB32, aBuffer); uint cr = Cairo.Create(surface); Cairo.SetOperator(Operator.Over, cr); Cairo.Rectangle(450, 600, 0, 0, cr); Cairo.SetSourceRGBA(1, 0.41, 0.41, 0.41, cr); Cairo.Fill(cr); Cairo.Rectangle(446, 596, 2, 2, cr); Cairo.SetSourceRGBA(1, 0.87, 0.87, 0.87, cr); Cairo.Fill(cr); Cairo.Rectangle(410, 580, 30, 10, cr); Cairo.SetSourceRGBA(1, 1, 1, 1, cr); Cairo.Fill(cr); Cairo.SetSourceRGBA(1, 0.41, 0.41, 0.41, cr); Cairo.SelectFontFace(FontWeight.Normal, FontSlant.Normal, Marshal.C_String(""), cr); Cairo.SetFontSize(15, cr); Cairo.MoveTo(18, 215, cr); Cairo.ShowText(Marshal.C_String("Atom OS : Installation Guide"), cr); Cairo.SelectFontFace(FontWeight.Bold, FontSlant.Normal, Marshal.C_String(""), cr); Cairo.MoveTo(18, 580, cr); Cairo.ShowText(Marshal.C_String("X"), cr); Cairo.SurfaceFlush(surface); Cairo.Destroy(cr); Cairo.SurfaceDestroy(surface); request->Type = RequestType.Redraw; var req = (Redraw *)request; req->WindowID = winID; req->X = 0; req->Y = 0; req->Width = 600; req->Height = 450; Compositor.Server.Write(xData); Debug.Write("Time: %d\n", Timer.TicksFromStart); while (true) { SystemClient.Read(xData); if (request->Error != ErrorType.None) { continue; } if (request->Type != RequestType.MouseEvent) { continue; } var mreq = (MouseEvent *)request; if (mreq->WindowID != winID) { continue; } if ((mreq->Function & MouseFunction.Click) != 0) { int x = mreq->Xpos; int y = mreq->Ypos; if (y < 40) { request->Type = RequestType.DragRequest; var mv = (DragRequest *)request; mv->WindowID = winID; Compositor.Server.Write(xData); } } } }
private void DrawCoords (Cairo.Context cairo) { cairo.Color = colors.CoordColor; cairo.Rectangle (start_x - space - size / 5, start_y - space - size / 5, (size + space) * 8 + 2 * size / 5, (size + space) * 8 + 2 * size / 5); cairo.Stroke (); string letters = "abcdefgh"; //cairo.Color = new Cairo.Color (0, 0, 0); cairo.Color = colors.CoordColor; double scale = Pango.Scale.PangoScale; for (int i = 0; i < 8; i++) { layout.SetText ((letters[i]).ToString ()); Pango.Rectangle logical, ink; layout.GetExtents (out ink, out logical); int width = (int) Math.Round (logical.Width / scale); int height = (int) Math.Round (logical.Height / scale); cairo.MoveTo (start_x + size / 2 + (size + space) * i - (width / 4), start_y - size / 5 - 2 * space + height - 4); cairo.ShowText (letters[i].ToString ()); cairo.MoveTo (start_x + size / 2 + (size + space) * i - (width / 4), start_y + (size + space) * 8 - 2 * space + height - 4); cairo.ShowText (letters[i].ToString ()); } string numbers = "12345678"; if (!side) numbers = "87654321"; for (int i = 0; i < 8; i++) { layout.SetText ((numbers[i]).ToString ()); Pango.Rectangle logical, ink; layout.GetExtents (out ink, out logical); //int width = (int) Math.Round(logical.Width / scale); int height = (int) Math.Round (logical.Height / scale); cairo.MoveTo (start_x - size / 5, start_y + size / 2 + (size + space) * i + (height / 4)); cairo.ShowText (numbers[i].ToString ()); cairo.MoveTo (start_x + (size + space) * 8, start_y + size / 2 + (size + space) * i + (height / 4)); cairo.ShowText (numbers[i].ToString ()); } }
/// <summary> /// Draws the label flat. /// </summary> /// <param name="context">Context.</param> /// <param name="bordertype">Bordertype.</param> /// <param name="labelposition">Labelposition.</param> /// <param name="pin">Pin.</param> /// <param name="xpos">Xpos.</param> /// <param name="ypos">Ypos.</param> private static void DrawLabelFlat(Cairo.Context context, BorderType bordertype, LabelPosition labelposition, IPin pin, int xpos = 0, int ypos = 0) { string displaytext = ""; var color = GdkToCairo (pin.PlotColor); displaytext = pin.DisplayNumberShort + " " + pin.Name; if (displaytext.Length > 12) { displaytext = displaytext.Substring (0, 12); displaytext += "..."; } if (bordertype == BorderType.Line) { DrawRoundedRectangle (context, xpos, ypos, LabelWidth - LabelBorderWeight, FlatHeight, 5); context.SetSourceRGBA (color.R, color.G, color.B, color.A); context.LineWidth = LabelBorderWeight; context.Stroke (); } //PinToLabelLine int xposlabelline = 0; int yposlabelline = 0; switch (labelposition) { case LabelPosition.Left: xposlabelline = xpos + LabelWidth; yposlabelline = ypos + (FlatHeight / 2); break; case LabelPosition.Right: xposlabelline = xpos; yposlabelline = ypos + (FlatHeight / 2); break; case LabelPosition.Bottom: xpos = xpos + LabelWidth / 2; yposlabelline = ypos; break; default: break; } if (PinLocations.ContainsKey ((int)pin.RealNumber)) { DrawLines ( context, xposlabelline, yposlabelline, (int)(MCUImageXZero + PinLocations [(int)pin.RealNumber].x), (int)(MCUImageYZero + PinLocations [(int)pin.RealNumber].y), color ); } //Number context.SetSourceRGB (0, 0, 0); context.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold); context.SetFontSize (LabelFontSize); context.MoveTo (xpos + 5, ypos + LabelFontSize + LabelBorderWeight); context.ShowText (displaytext); }
private static unsafe void DrawTaskbar(GuiRequest *request, byte[] xData) { request->Type = RequestType.NewWindow; request->Error = ErrorType.None; var taskbar = (NewWindow *)request; int height = 30; taskbar->X = 0; taskbar->Y = 0; taskbar->Width = VBE.Xres; taskbar->Height = height; Compositor.Server.Write(xData); SystemClient.Read(xData); if (request->Error != ErrorType.None) { Debug.Write("Error4: %d\n", (int)request->Error); return; } string HashCode = new string(taskbar->Buffer); var aBuffer = SHM.Obtain(HashCode, 0, false); int winID = taskbar->WindowID; Debug.Write("winID: %d\n", winID); uint surface = Cairo.ImageSurfaceCreateForData(VBE.Xres * 4, height, VBE.Xres, ColorFormat.ARGB32, aBuffer); uint cr = Cairo.Create(surface); uint pattern = Cairo.PatternCreateLinear(height, 0, 0, 0); Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 0, pattern); Cairo.PatternAddColorStopRgba(0.6, 0.36, 0.36, 0.36, 0.5, pattern); Cairo.PatternAddColorStopRgba(0.7, 0.42, 0.42, 0.42, 1, pattern); Cairo.SetOperator(Operator.Over, cr); Cairo.Rectangle(height, VBE.Xres, 0, 0, cr); Cairo.SetSource(pattern, cr); Cairo.Fill(cr); Cairo.Rectangle(2, VBE.Xres, height - 2, 0, cr); Cairo.SetSourceRGBA(0.7, 0.41, 0.41, 0.41, cr); Cairo.Fill(cr); Cairo.SetSourceRGBA(1, 1, 1, 1, cr); Cairo.SelectFontFace(FontWeight.Bold, FontSlant.Normal, Marshal.C_String(""), cr); Cairo.SetFontSize(20, cr); Cairo.MoveTo(20, 1215, cr); Cairo.ShowText(Marshal.C_String("20:10"), cr); Cairo.PatternDestroy(pattern); Cairo.Destroy(cr); Cairo.SurfaceDestroy(surface); request->Type = RequestType.Redraw; var req = (Redraw *)request; req->WindowID = winID; req->X = 0; req->Y = 0; req->Width = VBE.Xres; req->Height = height; Compositor.Server.Write(xData); }
public override void Draw(Cairo.Context cr) { int dir = X1 > X0 ? 1 : -1; cr.Save(); cr.SetFontSize(8); if(arrow_kind == ArrowKind.Return) { double[] returnDash = new double[]{ 3.0, 3.0 }; cr.SetDash(returnDash, 0); } cr.MoveTo(X0, Y0); cr.LineTo(X1, Y1); cr.Stroke(); cr.MoveTo(X1 - dir*7, Y1 - 3); cr.LineTo(X1, Y1); cr.LineTo(X1 - dir*7, Y1 + 3); if(arrow_kind == ArrowKind.Async) { cr.Stroke(); } else { cr.MoveTo(X1 - dir*7, Y1 - 3); cr.Fill(); } if((text != null) && !text.Equals("")) { if(dir > 0) { cr.MoveTo(XText + 5, Y0 - 5); cr.ShowText(text); } else { TextExtents te = cr.TextExtents(text); cr.MoveTo(XText - 5 - te.Width, Y0 - 5); cr.ShowText(text); } } cr.Restore(); }
public override void Draw(Cairo.Context cr) { cr.Save(); cr.SetFontSize(8); if(ArrowKind == ArrowKind.Return) { double[] returnDash = new double[]{ 3.0, 3.0 }; cr.SetDash(returnDash, 0); } cr.MoveTo(X0, Y0); cr.LineTo(X1, Y0); cr.LineTo(X1, Y1); cr.LineTo(X0b, Y1); cr.Stroke(); cr.MoveTo(X0b + 7, Y1 - 3); cr.LineTo(X0b, Y1); cr.LineTo(X0b + 7, Y1 + 3); if(ArrowKind == ArrowKind.Async) { cr.Stroke(); } else { cr.MoveTo(X0b + 7, Y1 - 3); cr.Fill(); } if((Text != null) && !Text.Equals("")) { cr.MoveTo(XText + 5, Y0 - 5); cr.ShowText(Text); } cr.Restore(); }
void DrawVersionNumber (Cairo.Context c, ref Cairo.PointD bottomRight, string text) { c.SelectFontFace (SplashFontFamily, Cairo.FontSlant.Normal, Cairo.FontWeight.Normal); c.SetFontSize (SplashFontSize); var extents = c.TextExtents (text); c.MoveTo (bottomRight.X - extents.Width - 1, bottomRight.Y - extents.Height); c.Color = new Cairo.Color (1, 1, 1); c.ShowText (text); }
protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged) { g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold); g.SetFontSize(24); #region Slots MateriaSlots.Render(g, MenuState.Party.Selected.Weapon, X + x_slots, Y + y_slots_weapon); MateriaSlots.Render(g, MenuState.Party.Selected.Armor, X + x_slots, Y + y_slots_armor); #endregion #region Character Status Images.RenderProfile(d, X + xpic, Y + ypic, MenuState.Party.Selected); Graphics.Stats.RenderCharacterStatus(d, g, MenuState.Party.Selected, X + x_status, Y + y_status, false); #endregion Status #region Equipment g.Color = Colors.TEXT_TEAL; g.MoveTo(X + x_labels, Y + y_weapon); g.ShowText("Wpn."); g.MoveTo(X + x_labels, Y + y_armor); g.ShowText("Arm."); g.Color = Colors.WHITE; Text.ShadowedText(g, "Check", X + x_labels, Y + y_check); Text.ShadowedText(g, "Arr.", X + x_labels, Y + y_arrange); string weapon, armor; weapon = MenuState.Party.Selected.Weapon.Name; armor = MenuState.Party.Selected.Armor.Name; Text.ShadowedText(g, MenuState.Party.Selected.Weapon.Name, X + x_names, Y + y_weapon); Text.ShadowedText(g, MenuState.Party.Selected.Armor.Name, X + x_names, Y + y_armor); #endregion if (IsControl) { Shapes.RenderCursor(g, X + cx, Y + cy); } }
private static void printText(int x, int y, int height, int textHeight, string text, Cairo.Context g) { g.MoveTo(x, ((y+y+height)/2) + textHeight/2.0); g.ShowText(text); }
public static void ShadowedText(Cairo.Context g, Cairo.Color c, string text, double x, double y) { g.Save(); g.MoveTo(x + Graphics.SHADOW_SPACING, y + Graphics.SHADOW_SPACING); g.Color = new Cairo.Color(0, 0, 0); g.ShowText(text); g.MoveTo(x, y); g.Color = c; g.ShowText(text); g.Restore(); }
protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged) { g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold); g.SetFontSize(24); TextExtents te; string exp, next, llvl; #region Top Row DrawCharacterStatus(d, g); exp = Party.Selected.Exp.ToString(); next = Party.Selected.ExpToNextLevel.ToString(); llvl = Party.Selected.LimitLevel.ToString(); Text.ShadowedText(g, "Exp:", X + x8, Y + ya); Text.ShadowedText(g, "Next lvl:", X + x8, Y + yb); Text.ShadowedText(g, "Limit lvl:", X + x8, Y + yc); te = g.TextExtents(exp); Text.ShadowedText(g, exp, X + x11 - te.Width, Y + ya); te = g.TextExtents(next); Text.ShadowedText(g, next, X + x11 - te.Width, Y + yb); te = g.TextExtents(llvl); Text.ShadowedText(g, llvl, X + x11 - te.Width, Y + yc); #endregion Top #region Left string str, vit, dex, mag, spi, lck; string atk, atkp, def, defp, mat, mdf, mdfp; str = Party.Selected.Strength.ToString(); vit = Party.Selected.Vitality.ToString(); dex = Party.Selected.Dexterity.ToString(); mag = Party.Selected.Magic.ToString(); spi = Party.Selected.Spirit.ToString(); lck = Party.Selected.Luck.ToString(); atk = Ally.Attack(Party.Selected).ToString(); atkp = Ally.AttackPercent(Party.Selected).ToString(); def = Ally.Defense(Party.Selected).ToString(); defp = Ally.DefensePercent(Party.Selected).ToString(); mat = Ally.MagicAttack(Party.Selected).ToString(); mdf = Ally.MagicDefense(Party.Selected).ToString(); mdfp = Ally.MagicDefensePercent(Party.Selected).ToString(); Cairo.Color greenish = Colors.TEXT_TEAL; Text.ShadowedText(g, greenish, "Strength", X + x0, Y + yq + (line * 0)); Text.ShadowedText(g, greenish, "Vitality", X + x0, Y + yq + (line * 1)); Text.ShadowedText(g, greenish, "Dexterity", X + x0, Y + yq + (line * 2)); Text.ShadowedText(g, greenish, "Magic", X + x0, Y + yq + (line * 3)); Text.ShadowedText(g, greenish, "Spirit", X + x0, Y + yq + (line * 4)); Text.ShadowedText(g, greenish, "Luck", X + x0, Y + yq + (line * 5)); Text.ShadowedText(g, greenish, "Attack", X + x0, Y + yr + (line * 0)); Text.ShadowedText(g, greenish, "Attack %", X + x0, Y + yr + (line * 1)); Text.ShadowedText(g, greenish, "Defense", X + x0, Y + yr + (line * 2)); Text.ShadowedText(g, greenish, "Defense %", X + x0, Y + yr + (line * 3)); Text.ShadowedText(g, greenish, "Magic", X + x0, Y + yr + (line * 4)); Text.ShadowedText(g, greenish, "Magic def", X + x0, Y + yr + (line * 5)); Text.ShadowedText(g, greenish, "Magic def %", X + x0, Y + yr + (line * 6)); te = g.TextExtents(str); Text.ShadowedText(g, str, X + x1 - te.Width, Y + yq + (line * 0)); te = g.TextExtents(vit); Text.ShadowedText(g, vit, X + x1 - te.Width, Y + yq + (line * 1)); te = g.TextExtents(dex); Text.ShadowedText(g, dex, X + x1 - te.Width, Y + yq + (line * 2)); te = g.TextExtents(mag); Text.ShadowedText(g, mag, X + x1 - te.Width, Y + yq + (line * 3)); te = g.TextExtents(spi); Text.ShadowedText(g, spi, X + x1 - te.Width, Y + yq + (line * 4)); te = g.TextExtents(lck); Text.ShadowedText(g, lck, X + x1 - te.Width, Y + yq + (line * 5)); te = g.TextExtents(atk); Text.ShadowedText(g, atk, X + x1 - te.Width, Y + yr + (line * 0)); te = g.TextExtents(atkp); Text.ShadowedText(g, atkp, X + x1 - te.Width, Y + yr + (line * 1)); te = g.TextExtents(def); Text.ShadowedText(g, def, X + x1 - te.Width, Y + yr + (line * 2)); te = g.TextExtents(defp); Text.ShadowedText(g, defp, X + x1 - te.Width, Y + yr + (line * 3)); te = g.TextExtents(mat); Text.ShadowedText(g, mat, X + x1 - te.Width, Y + yr + (line * 4)); te = g.TextExtents(mdf); Text.ShadowedText(g, mdf, X + x1 - te.Width, Y + yr + (line * 5)); te = g.TextExtents(mdfp); Text.ShadowedText(g, mdfp, X + x1 - te.Width, Y + yr + (line * 6)); #endregion Left #region Right MateriaSlots.Render(g, Party.Selected.Weapon, X + x9, Y + yi); MateriaSlots.Render(g, Party.Selected.Armor, X + x9, Y + yk); g.Color = Colors.TEXT_TEAL; g.MoveTo(X + x7, Y + yh); g.ShowText("Wpn."); g.MoveTo(X + x7, Y + yj); g.ShowText("Arm."); g.MoveTo(X + x7, Y + yl); g.ShowText("Acc."); g.Color = Colors.WHITE; Text.ShadowedText(g, Party.Selected.Weapon.Name, X + x8, Y + yh); Text.ShadowedText(g, Party.Selected.Armor.Name, X + x8, Y + yj); Text.ShadowedText(g, Party.Selected.Accessory.Name, X + x8, Y + yl); #endregion Right }
protected override void PaintWidget (Cairo.Context ctx, int w, int h) { ctx.SetFill (0.0d, 0.0d, 0.0d); ctx.Rectangle (0.0d, Offset, w, h - Offset); ctx.Fill (); ctx.SetFill (BlueprintStyle.BluePrint); ctx.Rectangle (0.0d, 0.0d, w, Offset); ctx.Fill (); double wr = w - 2.0d * Offset; double ew = wr / (max - min + 1 + shaft * (max - min)); this.flapWidth = ew; double xc = Offset; for (int i = min; i <= max; i++) { if (i != current) { ctx.Rectangle (xc, Offset, ew, h - 2.0d * Offset); } xc += (1.0d + shaft) * ew; } ctx.FillPreserve (); LinearGradient p = new LinearGradient (0.0d, Offset, 0.0d, Offset + 10.0d); double fctr = 0.5d; for (double y = 0.0d; y <= 1.0d; y += 0.1d) { p.AddColorStopRgb (y, new Color (fctr * BlueprintStyle.BluePrintShadow.R, fctr * BlueprintStyle.BluePrintShadow.G, fctr * BlueprintStyle.BluePrintShadow.B)); fctr += 0.05d; } ctx.SetFill (p); ctx.Fill (); ctx.Rectangle (Offset + (1.0d + shaft) * ew * (current - min), Offset, ew, h - 2.0d * Offset); ctx.SetFill (BlueprintStyle.BluePrint); ctx.Fill (); xc = Offset; ctx.SetFill (BlueprintStyle.HardWhite); ctx.MoveTo (0.0d, Offset); ctx.LineTo (Offset, Offset); for (int i = min; i <= max; i++) { ctx.LineTo (xc, h - Offset); ctx.LineTo (xc + ew, h - Offset); ctx.LineTo (xc + ew, Offset); xc += (1.0d + shaft) * ew; if (i < max) { ctx.LineTo (xc, Offset); } } ctx.LineTo (w - Offset, Offset); ctx.LineTo (w, Offset); ctx.MoveTo (Offset, Offset); ctx.LineTo (Offset + (1.0d + shaft) * ew * (current - min), Offset); ctx.MoveTo (w - Offset, Offset); ctx.LineTo (w - Offset + (1.0d + shaft) * ew * (current - max), Offset); ctx.Stroke (); xc = Offset + 0.5d * ew; IEnumerable<string> namei = this.names.Skip (this.min); IEnumerator<string> enume = namei.GetEnumerator (); for (int i = min; i <= max && enume.MoveNext (); i++) { string name = enume.Current; if (name != null) { #if PANGO Pango.Layout pglay = Pango.CairoHelper.CreateLayout (ctx); pglay.SetText (name); Pango.Rectangle ra, rb; pglay.GetExtents (out ra, out rb); double tew = rb.Width / 1024.0d; double teh = rb.Height / 1024.0d; #else TextExtents te = ctx.TextExtents (name); double tew = te.Width; double teh = te.Height; #endif ctx.MoveTo (xc - 0.5d * tew, 0.5d * (h + teh)); ctx.ShowText (name); xc += (1.0d + shaft) * ew; } } }
const int yc = yb + 25; // subrow 3 #endregion Fields #region Methods public static void RenderCharacterStatus(Gdk.Drawable d, Cairo.Context g, Character c, int x, int y, bool showFurySadness = true) { TextExtents te; string lvl, hp, hpm, mp, mpm; g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Normal); g.Color = Colors.TEXT_TEAL; g.MoveTo(x + x3, y + ya); g.ShowText("LV"); g.MoveTo(x + x3, y + yb); g.ShowText("HP"); g.MoveTo(x + x3, y + yc); g.ShowText("MP"); g.Color = Colors.WHITE; if (showFurySadness) { if (c.Fury) { Text.ShadowedText(g, Colors.TEXT_MAGENTA, "[Fury]", x + x7, y); } else if (c.Sadness) { Text.ShadowedText(g, Colors.TEXT_MAGENTA, "[Sadness]", x + x7, y); } } Color namec = Colors.WHITE; if (c.Death) { namec = Colors.TEXT_RED; } else if (c.NearDeath) { namec = Colors.TEXT_YELLOW; } Text.ShadowedText(g, namec, c.Name, x + x3, y); lvl = c.Level.ToString(); te = g.TextExtents(lvl); Text.ShadowedText(g, lvl, x + x4 - te.Width, y + ya); hp = c.HP.ToString() + "/"; te = g.TextExtents(hp); Text.ShadowedText(g, hp, x + x5 - te.Width, y + yb); hpm = c.MaxHP.ToString(); te = g.TextExtents(hpm); Text.ShadowedText(g, hpm, x + x6 - te.Width, y + yb); mp = c.MP.ToString() + "/"; te = g.TextExtents(mp); Text.ShadowedText(g, mp, x + x5 - te.Width, y + yc); mpm = c.MaxMP.ToString(); te = g.TextExtents(mpm); Text.ShadowedText(g, mpm, x + x6 - te.Width, y + yc); }
void DrawAlphaBetaMarker (Cairo.Context c, ref Cairo.PointD bottomRight, string text) { c.SelectFontFace (SplashFontFamily, Cairo.FontSlant.Normal, Cairo.FontWeight.Bold); c.SetFontSize (SplashFontSize); // Create a rectangle larger than the text so we can have a nice border var extents = c.TextExtents (text); var x = bottomRight.X - extents.Width * 1.3; var y = bottomRight.Y - extents.Height * 1.5; var rectangle = new Cairo.Rectangle (x, y, bottomRight.X - x, bottomRight.Y - y); // Draw the background color the text will be overlaid on DrawRoundedRectangle (c, rectangle); // Calculate the offset the text will need to be at to be centralised // in the border x = x + extents.XBearing + (rectangle.Width - extents.Width) / 2; y = y - extents.YBearing + (rectangle.Height - extents.Height) / 2; c.MoveTo (x, y); // Draw the text c.Color = new Cairo.Color (1, 1, 1); c.ShowText (text); bottomRight.Y -= rectangle.Height - 2; }
private void DrawCoords(Cairo.Context cairo) { cairo.Color = coordColor; // x-axis cairo.MoveTo (start_x, start_y); cairo.LineTo (start_x + graph_area_width, start_y); cairo.Stroke (); // y-axis cairo.MoveTo (start_x, start_y); cairo.LineTo (start_x, offset_y); cairo.Stroke (); int max_height = 0; for (int i = 0; i < x_marks.Length; i++) { TextExtents extents = cairo. TextExtents (x_marks[i]. name); int height = (int) Math.Round (extents. Height); if (height > max_height) max_height = height; } for (int i = 0; i < x_marks.Length; i++) { if (i != 0) { cairo.MoveTo (start_x + x_marks[i]. x, start_y); cairo.LineTo (start_x + x_marks[i]. x, offset_y); cairo.Stroke (); } cairo.MoveTo (start_x + x_marks[i].x, start_y + offset + max_height); cairo.ShowText (x_marks[i].name); cairo.Stroke (); } for (int i = 0; i < y_marks.Length; i++) { TextExtents extents = cairo. TextExtents (y_marks[i]. name); int width = (int) Math.Round (extents. Width); int height = (int) Math.Round (extents. Height); cairo.MoveTo (start_x - offset / 2, start_y - y_marks[i].y); cairo.LineTo (start_x + offset / 2, start_y - y_marks[i].y); cairo.Stroke (); cairo.MoveTo (start_x - offset - width, start_y - y_marks[i].y + height / 2); cairo.ShowText (y_marks[i].name); cairo.Stroke (); } }
protected void DrawTextAt(Cairo.Context gr, double x, double y, string text, bool HCenter = false, bool VCenter = false) { TextExtents extents = gr.TextExtents(text); if (HCenter) { x = (this.WidthRequest / 2) - (extents.Width / 2); } if (VCenter) { y = (this.HeightRequest / 2) + (extents.Height / 2); } gr.MoveTo(this._x + x, this._y + y); gr.ShowText(text); }
private void DrawText(Cairo.Context cr, string text, double lineSpacing) { string [] lines = text.Split('\n'); double [] cuml_heights = new double[lines.Length]; double y_start = 0.0; for(int i = 0; i < lines.Length; i++) { TextExtents extents = cr.TextExtents(lines[i]); double height = extents.Height + (i > 0 ? lineSpacing : 0); cuml_heights[i] = i > 0 ? cuml_heights[i - 1] + height : height; } y_start = (Allocation.Height / 2) - (cuml_heights[cuml_heights.Length - 1] / 2); for(int i = 0; i < lines.Length; i++) { TextExtents extents = cr.TextExtents(lines[i]); double x = (Allocation.Width / 2) - (extents.Width / 2); double y = y_start + cuml_heights[i]; cr.MoveTo(x, y); cr.ShowText(lines[i]); } }
/// <summary> /// Draws the label. /// </summary> /// <param name="context">Context.</param> /// <param name="bordertype">Bordertype.</param> /// <param name="pin">Pin.</param> /// <param name="xpos">Xpos.</param> /// <param name="ypos">Ypos.</param> private static void DrawLabel(Cairo.Context context, BorderType bordertype, IPin pin, int xpos = 0, int ypos = 0) { const int widht = 100; const int height = BoldHeight; const int fontsize = 12; //Rect context.Rectangle (xpos, ypos, widht, 26); context.SetSourceRGBA (BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A); context.Fill (); string displaytext = pin.Name; if (displaytext.Length > 12) { displaytext = displaytext.Substring (0, 12); displaytext += "..."; } if (bordertype == BorderType.Line) { //Border context.SetSourceRGB (0, 0, 0); context.LineWidth = .5; context.Rectangle (xpos, ypos, widht, height); context.Stroke (); } //ColorFlag context.Rectangle (xpos, ypos, 5, height); context.SetSourceRGB (pin.PlotColor.Red, pin.PlotColor.Green, pin.PlotColor.Blue); context.Fill (); //Number context.SetSourceRGB (0, 0, 0); context.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold); context.SetFontSize (fontsize); context.MoveTo (xpos + 5, ypos + fontsize); context.ShowText (pin.DisplayNumberShort); context.MoveTo (xpos + 5, ypos + fontsize * 2); context.ShowText (displaytext); }
private void DrawText(Cairo.Context g, string text, int top, int left) { g.SetSourceRGB(0, 0, 0); g.SetFontSize(cellHeight / 1.5); FontExtents fe = g.FontExtents; TextExtents te = g.TextExtents(text); g.MoveTo(left * cellWidth +(cellWidth - te.Width) / 2, top * cellHeight + (cellHeight + te.YBearing + fe.Height) / 2); g.ShowText(text); }