public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = DrawAreaX + 0.2, y = DrawAreaY + 0.2, width = 0.4, height = 0.4; base.Draw (gr, area_width, area_height, rtl); gr.Rectangle (x, y, width, height); gr.Stroke (); gr.MoveTo (x, y + 0.1); gr.LineTo (x + width, y + 0.1); // First horizontal gr.Stroke (); gr.MoveTo (x, y + 0.3); gr.LineTo (x + width - 0.1, y + 0.3); // Second horizontal gr.Stroke (); gr.MoveTo (x + 0.1, y); gr.LineTo (x + 0.1, y + height); // First vertical gr.Stroke (); gr.MoveTo (x + 0.3, y); gr.LineTo (x + 0.3, y + height - 0.1); // Second vertical gr.Stroke (); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double rect_w = DrawAreaWidth / rows; double rect_h = DrawAreaHeight / columns; base.Draw (gr, area_width, area_height, rtl); for (int column = 0; column < columns; column++) { for (int row = 0; row < rows; row++) { gr.Color = DefaultDrawingColor; gr.Rectangle (DrawAreaX + row * rect_w, DrawAreaY + column * rect_h, rect_w, rect_h); gr.Stroke (); gr.DrawTextCentered (DrawAreaX + (rect_w / 2) + column * rect_w, (rect_h / 2) + DrawAreaY + row * rect_h, (numbers[column + (row * 4)]).ToString() ); if (numbers[column + (row * 4)] % divisor == 0 && good_pos != column + (row * 4)) { gr.Arc (DrawAreaX + (rect_w / 2) + column * rect_w, (rect_h / 2) + DrawAreaY + row * rect_h, 0.05, 0, 2 * Math.PI); gr.FillGradient (DrawAreaX + (rect_w / 2) + column * rect_w, (rect_h / 2) + DrawAreaY + row * rect_h, 0.05, 0.05); } gr.Stroke (); } } }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { #if DESIGN_MODE gr.Save (); gr.Color = new Cairo.Color (1, 0, 0); gr.Rectangle (0, 0, Width, Height); gr.Stroke (); gr.Restore (); #endif if (hoover == true) { double lw = gr.LineWidth; double [] dashes = {0.01, /* ink */ 0.01, /* skip */ }; gr.Save (); gr.Color = new Cairo.Color (0.5, 0.5, 0.5, 1); gr.SetDash (dashes, 0); if (SelectedArea.Width == 0 && SelectedArea.Height == 0) gr.Rectangle (-lw, -lw, Width + lw * 2, Height + lw * 2); else gr.Rectangle (SelectedArea.X -lw, SelectedArea.Y -lw, SelectedArea.Width + lw * 2, SelectedArea.Height + lw * 2); gr.Stroke (); gr.Restore (); } if (DrawEventHandler == null) return; DrawEventHandler (this, new DrawEventArgs (gr, Width, Height, rtl, Data)); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = X, y = Y; this.rtl = rtl; #if DESIGN_MODE gr.Save (); gr.Color = new Cairo.Color (0, 0, 1); gr.Rectangle (X, Y, Width, Height); gr.Stroke (); gr.Restore (); double width = 0; foreach (Widget child in children) { width += child.Width; if (Height < child.Height) throw new InvalidOperationException (String.Format ("Container height too small {0} < {1}", Height, child.Height)); } if (Width < width) throw new InvalidOperationException (String.Format ("Container witdh too small {0} < {1}", Width, width)); #endif // // Coordinates are stored right to left // if (rtl == false) { for (int i = 0; i < children.Count; i++) { gr.Save (); gr.Translate (x, y); children[i].Draw (gr, area_width, area_height, rtl); gr.Restore (); x += children[i].Width; } } else { x += Width; for (int i = 0; i < children.Count; i++) { x -= children[i].Width; gr.Save (); gr.Translate (x, y); children[i].Draw (gr, area_width, area_height, rtl); gr.Restore (); } } }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double rect_w = DrawAreaWidth / rows; double rect_h = DrawAreaHeight / columns; base.Draw (gr, area_width, area_height, rtl); for (int column = 0; column < columns; column++) { for (int row = 0; row < rows; row++) { gr.Rectangle (DrawAreaX + row * rect_w, DrawAreaY + column * rect_h, rect_w, rect_h); } } gr.Stroke (); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = 0.25, y = 0.25; base.Draw (gr, area_width, area_height, rtl); gr.Rectangle (x, y, width, height); gr.Stroke (); gr.MoveTo (x, y + height / 2); gr.LineTo (x + width, y + height / 2); gr.Stroke (); gr.MoveTo (x + width / 2, y); gr.LineTo (x + width / 2, y + height); gr.Stroke (); if (cover_zone1) CoverZone (gr, x, y); if (cover_zone2) CoverZone (gr, x + width / 2, y); if (cover_zone3) CoverZone (gr, x, y + height / 2); if (cover_zone4) CoverZone (gr, x + width / 2, y + height / 2); switch (partial_zone) { case 1: break; case 2: x += width / 2; break; case 3: y += height / 2; break; case 4: y += height / 2; x += width / 2; break; } DrawSection (gr, x, y); }
public virtual void Draw(CairoContextEx gr, int width, int height, bool rtl) { InitDraw(gr, width, height, rtl); foreach (Toolkit.Container container in containers) { container.Draw(gr, width, height, rtl); } #if DESIGN_MODE gr.Save(); gr.Color = new Cairo.Color(0, 1, 0); gr.Rectangle(0, 0, 1, 1); gr.Stroke(); gr.Restore(); #endif }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = X, y = Y; this.rtl = rtl; #if DESIGN_MODE gr.Save (); gr.Color = new Cairo.Color (0, 0, 1); gr.Rectangle (X, Y, Width, Height); gr.Stroke (); gr.Restore (); ValidateDimensions (); #endif // // Coordinates are stored right to left // if (rtl == false) { for (int i = 0; i < children.Count; i++) { gr.Save (); gr.Translate (x, y); children[i].Draw (gr, area_width, area_height, rtl); gr.Restore (); x += children[i].Width; } } else { x += Width; for (int i = 0; i < children.Count; i++) { x -= children[i].Width; gr.Save (); gr.Translate (x, y); children[i].Draw (gr, area_width, area_height, rtl); gr.Restore (); } } }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { int rows = 7, columns = 9; double rect_w = DrawAreaWidth / columns; double rect_h = DrawAreaHeight / rows; int first_column; string text; base.Draw (gr, area_width, area_height, rtl); gr.SetPangoLargeFontSize (); for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { gr.Rectangle (DrawAreaX + column * rect_w, DrawAreaY + row * rect_h, rect_w, rect_h); gr.Stroke (); if (row >= lines.Length) continue; first_column = (columns - lines[row].TotalNumbers) / 2; if (column < first_column || column - first_column >= lines [row].TotalNumbers) continue; if (row + 1 == lines.Length && lines [row].IsMiddle (column - first_column)) text = "?"; else text = lines [row].GetNumber (column - first_column).ToString (); gr.DrawTextCentered (DrawAreaX + (column * rect_w) + rect_w / 2, DrawAreaY + (row * rect_h) + rect_h / 2, text.ToString()); } } }
private void DrawSquare(CairoContextEx gr, double x, double y, int[] nums, int index) { for (int column = 0; column < columns; column++) { for (int row = 0; row < rows; row++) { gr.Rectangle (x + row * rect_w, y + column * rect_h, rect_w, rect_h); gr.Stroke (); gr.DrawTextCentered (x + (rect_w / 2) + column * rect_w, y + (rect_h / 2) + row * rect_h, (nums[index + column + (row * columns)]).ToString ()); gr.Stroke (); } } }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double first_x = DrawAreaX + 0.05; double first_y = DrawAreaY + 0.1; const double space_fromrect = 0.02, space_fromcircle = 0.01; int circles = 8; const double unit = 0.0625; base.Draw (gr, area_width, area_height, rtl); gr.Rectangle (first_x, first_y, unit * 8, unit * 8); gr.Stroke (); // |-------| gr.MoveTo (first_x, first_y - 0.04 - space_fromrect); gr.LineTo (first_x, first_y - space_fromrect); gr.Stroke (); gr.MoveTo (first_x, first_y - 0.02 - space_fromrect); gr.LineTo (first_x + 0.5, first_y - 0.02 - space_fromrect); gr.Stroke (); gr.MoveTo (first_x + 0.5, first_y - 0.04 - space_fromrect); gr.LineTo (first_x + 0.5, first_y - space_fromrect); gr.Stroke (); gr.MoveTo (first_x + 0.2, first_y - 0.06 - space_fromrect); gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("8 units")); gr.Stroke (); // --- // | // | // | // --- gr.MoveTo (first_x - space_fromrect, first_y); gr.LineTo (first_x - space_fromrect - 0.04, first_y); gr.Stroke (); gr.MoveTo (first_x - space_fromrect - 0.02, first_y); gr.LineTo (first_x - space_fromrect - 0.02, first_y + 0.5); gr.Stroke (); gr.MoveTo (first_x - space_fromrect, first_y + 0.5); gr.LineTo (first_x - space_fromrect - 0.04, first_y + 0.5); gr.Stroke (); gr.MoveTo (first_x - space_fromrect - 0.07, first_y + 0.3); gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("8 units"), false, -1, 270 * Math.PI/180); gr.Stroke (); // Sample circle gr.Arc (first_x + 0.7, first_y + 0.1, unit / 2, 0, 2 * Math.PI); gr.Stroke (); // |-------| gr.MoveTo (first_x + 0.65, first_y + 0.05 - 0.04 - space_fromcircle); gr.LineTo (first_x + 0.65, first_y + 0.05 - space_fromcircle); gr.Stroke (); gr.MoveTo (first_x + 0.65, first_y + 0.05 - 0.02 - space_fromcircle); gr.LineTo (first_x + 0.65 + 0.1, first_y + 0.05 - 0.02 - space_fromcircle); gr.Stroke (); gr.MoveTo (first_x + 0.65 + 0.1, first_y + 0.05 - 0.04 - space_fromcircle); gr.LineTo (first_x + 0.65 + 0.1, first_y + 0.05 - space_fromcircle); gr.Stroke (); gr.MoveTo (first_x + 0.65, first_y - 0.04 - space_fromcircle); gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("1 unit")); gr.Stroke (); // --- // | // | // | // --- gr.MoveTo (first_x + 0.65 - space_fromcircle, first_y + 0.05); gr.LineTo (first_x + 0.65 - space_fromcircle - 0.04, first_y + 0.05); gr.Stroke (); gr.MoveTo (first_x + 0.65 - space_fromcircle - 0.02, first_y + 0.05); gr.LineTo (first_x + 0.65 - space_fromcircle - 0.02, first_y + 0.05 + 0.1); gr.Stroke (); gr.MoveTo (first_x + 0.65 - space_fromcircle, first_y + 0.1 + 0.05); gr.LineTo (first_x + 0.65 - space_fromcircle - 0.04, first_y + 0.1 + 0.05); gr.Stroke (); gr.MoveTo (first_x + 0.65 - space_fromcircle - 0.08, first_y + 0.15); gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("1 unit"), false, -1, 270 * Math.PI/180); gr.Stroke (); if (Answer.Draw == false) return; double x; for (int line = 0; line < 9; line++) { for (int circle = 0; circle < circles; circle++) { x = first_x + (unit / 2) + (circle * unit); if (circles == 7) x+= unit / 2; gr.Arc (x, (unit / 2) + first_y + (unit * line) - (unit / 8) * line, (unit / 2), 0, 2 * Math.PI); gr.Stroke (); } if (circles ==8) circles = 7; else circles = 8; } }
void DrawQuestion(CairoContextEx gr, double x, double y) { gr.Rectangle (x, y, width, height); gr.Stroke (); gr.MoveTo (x, y + 0.1); gr.LineTo (x + width, y + 0.1); // Container square gr.Stroke (); gr.MoveTo (x, y + 0.3); gr.LineTo (x + width - 0.1, y + 0.3); // Second horizontal gr.Stroke (); gr.MoveTo (x + 0.1, y); gr.LineTo (x + 0.1, y + height); // First vertical gr.Stroke (); gr.MoveTo (x + 0.3, y); gr.LineTo (x + 0.3, y + height - 0.1); // Second vertical gr.Stroke (); }
void DrawAnswer(CairoContextEx gr, double x, double y) { ColorPalette palette = new ColorPalette (Translations); gr.Save (); // A full sized square of paper gr.Color = palette.Cairo (ColorPalette.Id.Yellow); gr.Rectangle (x, y, width, height); gr.Fill (); gr.Stroke (); // 3/4 of the whole size square of paper in the bottom right corner gr.Color = palette.Cairo (ColorPalette.Id.Blue); double w = 3d/4d * width; double h = 3d/4d * height; gr.Rectangle (x + (width - w), y + (height - h), w, h); gr.Fill (); gr.Stroke (); // 3/4 square of paper in the top left corner gr.Color = palette.Cairo (ColorPalette.Id.Green); gr.Rectangle (x, y, 3d/4d * width, 3d/4d * height); gr.Fill (); gr.Stroke (); // 1/4 square of paper in the top left corner gr.Color = palette.Cairo (ColorPalette.Id.Red); gr.Rectangle (x, y, 1d/4d * width, 1d/4d * height); gr.Fill (); gr.Stroke (); gr.Restore (); }
static void GenerateQuestions(CairoContextEx cr, Game [] games, int columns, int rows) { int x, y, page; Game puzzle; string str; x = y = page = 0; for (int i = 0; i < games.Length; i++) { puzzle = games [i]; puzzle.Begin (); page++; cr.Save (); cr.Translate (x, y); cr.Rectangle (0, 0, width, height + question_height); cr.Clip (); // Translators: {0} is the game number and {1} the game question or answer // The number is used as reference when looking for the game solution in the PDF str = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Game #{0}. {1}"), i + 1, puzzle.Question); // Draw question cr.SetPangoFontSize (12); cr.UseMarkup = true; cr.DrawStringWithWrapping (margin, 10, str, width - margin); cr.Stroke (); cr.UseMarkup = false; // Draw from question_height up height since from 0 to question_height is the question // Translate adds always to previous matrix's transformation cr.Translate (0, question_height); puzzle.DrawPreview (cr, width, height, false); if (i == 0) { cr.Save (); cr.SetPangoFontSize (0.02); cr.MoveTo (0.05, 0.95); cr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Created by gbrainy {0}"), Defines.VERSION)); cr.Stroke (); cr.Restore (); } x += width + margin; if (x > width + margin) { x = 0; y += height + margin + question_height; } cr.Restore (); cr.Stroke (); if (page >= columns * rows) { cr.ShowPage (); page = x = y = 0; } } if (y > 0) cr.ShowPage (); }
public override void Draw(CairoContextEx gr, double x, double y, double size) { gr.Rectangle ((size - width) / 2, (size - heigth) / 2, width, heigth); gr.Stroke (); }
static void DrawFigure(CairoContextEx gr, double x, double y, Figures figure) { switch (figure) { case Figures.FigureA: double x105, y105; x105 = figure_size * Math.Cos (105 * Math.PI / 180); y105 = figure_size * Math.Sin (105 * Math.PI / 180); gr.MoveTo (x, y); gr.LineTo (x + x105, y + y105); gr.LineTo (x + x105 + figure_size, y + y105); gr.Stroke (); gr.MoveTo (x + figure_size, y); gr.LineTo (x + figure_size + x105, y + y105); gr.Stroke (); gr.MoveTo (x, y); gr.LineTo (x + figure_size, y); break; case Figures.FigureB: gr.Rectangle (x, y, figure_size * 0.8, figure_size * 1.2); break; case Figures.FigureC: gr.MoveTo (x, y); gr.LineTo (x + figure_size * 1.3, y); gr.LineTo (x + figure_size * 1.3, y + figure_size); gr.LineTo (x , y + figure_size); gr.LineTo (x, y); break; case Figures.FigureD: gr.MoveTo (x + 0.03, y); gr.LineTo (x + figure_size - 0.03, y); gr.LineTo (x + figure_size, y + figure_size); gr.LineTo (x , y + figure_size); gr.LineTo (x + 0.03, y); break; case Figures.FigureE: gr.MoveTo (x + 0.03, y); gr.LineTo (x + figure_size - 0.04, y); gr.LineTo (x + figure_size - 0.04, y + figure_size * 1.2); gr.LineTo (x , y + figure_size * 1.2); gr.LineTo (x + 0.03, y); break; case Figures.FigureF: gr.MoveTo (x, y); gr.LineTo (x, y + figure_size); gr.LineTo (x + figure_size, y + figure_size); gr.LineTo (x + figure_size - 0.02, y); gr.LineTo (x, y); break; } gr.Stroke (); }
void DrawSolution(CairoContextEx cr, int height, double max_width) { if (UseSolutionArea == false || String.IsNullOrEmpty (Solution) == true) return; double width_str, height_str, x_text, icon_x, icon_w, icon_h, box_height_scaled; cr.Save (); cr.LineWidth = 0.001; icon_w = icon_size * (cr.Matrix.Xx > cr.Matrix.Yy ? cr.Matrix.Yy / cr.Matrix.Xx : 1); icon_h = icon_size * (cr.Matrix.Yy > cr.Matrix.Xx ? cr.Matrix.Xx / cr.Matrix.Yy : 1); cr.MeasureString (Solution, max_width - icon_w, true, out width_str, out height_str); // In case that the string to show is longer than the space reserved (long translations for example) // allow the box to grow taking part of the lower part of the graphic box_height_scaled = Math.Max (height_str, (double) solution_high / (double) height); // Draw black box cr.Color = new Color (0.1, 0.1, 0.1); cr.Rectangle (text_margin, 1 - box_height_scaled - text_margin, max_width, box_height_scaled); cr.Fill (); cr.Stroke (); // Draw text and icon cr.Color = new Color (1, 1, 1); if (Direction == Gtk.TextDirection.Rtl) { x_text = 0; icon_x = max_width - icon_w; } else { x_text = icon_w + text_margin; icon_x = 0; } cr.DrawStringWithWrapping (x_text, (1 - box_height_scaled - text_margin) + ((box_height_scaled - height_str) / 2), Solution, max_width - icon_w); cr.Stroke (); DrawSolutionIcon (cr, icon_x, (1 - box_height_scaled - text_margin) + ((box_height_scaled - icon_h) / 2), icon_w, icon_h); cr.Restore (); }
public void DrawBalance(CairoContextEx gr, double x, double y, int index, bool full) { const double width = 0.5; double fig_x = x + 0.1, fig_y = y - 0.11; int total = (full == true) ? (elements * 2) : elements; gr.Rectangle (x + 0.05, y - 0.12, 0.38, 0.08); gr.Stroke (); gr.Rectangle (x + 0.5, y - 0.12, 0.38, 0.08); gr.Stroke (); for (int i = 0; i < total; i++) { switch (balances[i + index]) { case 1: gr.DrawEquilateralTriangle (fig_x, fig_y, 0.05); break; case 2: gr.Arc (fig_x + (0.05 / 2), fig_y + (0.05 / 2) + 0.003, (0.05 / 2), 0, 2 * Math.PI); gr.Stroke (); break; case 3: gr.Rectangle (fig_x, fig_y + 0.005, 0.045, 0.045); gr.Stroke (); break; } if (i == elements - 1) fig_x = x + 0.54; else fig_x += 0.07; } x += 0.2; y += 0.01; gr.MoveTo (x, y); gr.LineTo (x + width, y); gr.LineTo (x + width, y - 0.05); gr.Stroke (); gr.MoveTo (x , y); gr.LineTo (x , y - 0.05); gr.Stroke (); gr.DrawEquilateralTriangle (x + (width / 2) - 0.04, y, 0.08); gr.Stroke (); }
private void DrawPossibleAnswer(CairoContextEx gr, double x, double y, char [] portions, int figure, int seq) { const int columns = 3, rows = 3; const double rect_w = 0.05, rect_h = 0.05; int index = figure * columns * rows; for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { if (portions [index + column + (3 * row)] != X) { gr.Rectangle (x + column * rect_w, y + row * rect_h, rect_w, rect_h); gr.FillGradient (x + column * rect_w, y + row * rect_h, rect_w, rect_h, ColorForPortion (portions [index + column + (3 * row)])); } gr.Rectangle (x + column * rect_w, y + row * rect_h, rect_w, rect_h); gr.Stroke (); } } }
private static void Fill(CairoContextEx gr, double x, double y, double w, double h) { gr.Rectangle (x, y, w, h); gr.FillGradient (x, y, w, h); }
void GenerateQuestions(CairoContextEx cr, Game [] games, int columns, int rows) { int x, y, page; Game puzzle; string str; x = y = page = 0; for (int i = 0; i < games.Length; i++) { puzzle = games [i]; puzzle.Begin(); page++; cr.Save(); cr.Translate(x, y); cr.Rectangle(0, 0, width, height + question_height); cr.Clip(); // Translators: {0} is the game number and {1} the game question or answer // The number is used as reference when looking for the game solution in the PDF str = String.Format(Translations.GetString("Game #{0}. {1}"), i + 1, puzzle.Question); // Draw question cr.SetPangoFontSize(12); cr.UseMarkup = true; cr.DrawStringWithWrapping(margin, 10, str, width - margin); cr.Stroke(); cr.UseMarkup = false; // Draw from question_height up height since from 0 to question_height is the question // Translate adds always to previous matrix's transformation cr.Translate(0, question_height); puzzle.DrawPreview(cr, width, height, false); if (i == 0) { cr.Save(); cr.SetPangoFontSize(0.02); cr.MoveTo(0.05, 0.95); cr.ShowPangoText(String.Format(Translations.GetString("Created by gbrainy {0}"), Defines.VERSION)); cr.Stroke(); cr.Restore(); } x += width + margin; if (x > width + margin) { x = 0; y += height + margin + question_height; } cr.Restore(); cr.Stroke(); if (page >= columns * rows) { cr.ShowPage(); page = x = y = 0; } } if (y > 0) { cr.ShowPage(); } }
public override void Draw(CairoContextEx gr, double x, double y, double size) { gr.Rectangle ((size - side) / 2, (size - side) / 2, side, side); gr.Stroke (); }
static void DrawBand(CairoContextEx gr, double x, double y) { gr.Save (); gr.Rectangle (x, y, 1 - 0.06, 0.06); gr.Color = new Cairo.Color (0, 0, 0.2, 0.2); gr.Fill (); gr.Restore (); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double rect_w = DrawAreaWidth / rows; double rect_h = DrawAreaHeight / columns; base.Draw (gr, area_width, area_height, rtl); for (int column = 0; column < columns; column++) { for (int row = 0; row < rows; row++) { gr.Rectangle (DrawAreaX + row * rect_w, DrawAreaY + column * rect_h, rect_w, rect_h); if (row != 3 || column != 3) { gr.DrawTextCentered (DrawAreaX + column * rect_w + rect_w / 2, DrawAreaY + row * rect_h + rect_h / 2, (numbers[column + (row * 4)]).ToString()); } } } gr.DrawTextCentered (DrawAreaX + 3 * rect_w + rect_w / 2, DrawAreaY + 3 * rect_h + rect_h / 2, "?"); gr.Stroke (); }
static void DrawBar(CairoContextEx gr, double x, double y, double w, double h, double percentage) { double per = percentage / 100; gr.Rectangle (x, y - h * per, w, h * per); gr.FillGradient (x, y - h * per, w, h * per, new Cairo.Color (0, 0, 1)); gr.DrawTextCentered (x + w / 2, (y - 0.03) - h * per, String.Format ("{0}", percentage)); gr.Save (); gr.Color = new Cairo.Color (0, 0, 0); gr.MoveTo (x, y); gr.LineTo (x, y - h * per); gr.LineTo (x + w, y - h * per); gr.LineTo (x + w, y); gr.LineTo (x, y); gr.Stroke (); gr.Restore (); }
private static void DrawFigure(CairoContextEx gr, double x, double y, Figures figure) { switch (figure) { case Figures.TriangleA: gr.DrawEquilateralTriangle (x, y, figure_size); break; case Figures.TriangleB: gr.MoveTo (x, y); gr.LineTo (x, y + figure_size); gr.LineTo (x + figure_size, y); gr.LineTo (x, y); gr.Stroke (); break; case Figures.TriangleC: gr.MoveTo (x, y); gr.LineTo (x, y + figure_size); gr.LineTo (x + figure_size, y + figure_size); gr.LineTo (x, y); gr.Stroke (); break; case Figures.Square: gr.Rectangle (x, y, figure_size, figure_size); gr.Stroke (); break; case Figures.LongRectangle: gr.Rectangle (x, y + figure_size / 2, figure_size, figure_size / 2); gr.Stroke (); break; case Figures.LongRectangleUp: gr.Rectangle (x, y, figure_size, figure_size / 2); gr.Stroke (); break; case Figures.Diamon: gr.DrawDiamond (x, y, figure_size); break; case Figures.TriangleD: gr.MoveTo (x, y); gr.LineTo (x, y + figure_size * 0.7); gr.LineTo (x + figure_size * 0.7, y + figure_size * 0.7); gr.LineTo (x, y); gr.Stroke (); break; } }
private void DrawLShape(CairoContextEx gr, double x, double y) { // XXX // X // X for (int i = 0; i < 3; i++) { // XXXX if (quest2 [i] != X) { gr.Rectangle (x + i * rect_witdh, y, rect_witdh, rect_height); gr.FillGradient (x + i * rect_witdh, y, rect_witdh, rect_height, ColorForPortion (quest2 [i])); } gr.Rectangle (x + i * rect_witdh, y, rect_witdh, rect_height); gr.Stroke (); } for (int i = 0; i < 2; i++) { if (quest2 [(i + 1) * 3] != X) { gr.Rectangle (x, y + rect_height * (i + 1), rect_witdh, rect_height); gr.FillGradient (x, y + rect_height * (i + 1), rect_witdh, rect_height, ColorForPortion (quest2 [(i + 1) * 3])); } gr.Rectangle (x, y + rect_height * (i + 1), rect_witdh, rect_height); gr.Stroke (); } }
public void DrawFigure(CairoContextEx gr, double x, double y, bool [] puzzle, int index) { double pos_x = x, pos_y = y; double square_size = figure_size / lines; double center_square = square_size / 2; double radius_square = (square_size - (LineWidth *2)) / 2.5; gr.Rectangle (pos_x, pos_y, figure_size, figure_size); gr.Stroke (); for (int line = 0; line < lines - 1; line++) // Horizontal { pos_y += square_size; gr.MoveTo (pos_x, pos_y); gr.LineTo (pos_x + figure_size, pos_y); gr.Stroke (); } pos_y = y; for (int column = 0; column < columns - 1; column++) // Vertical { pos_x += square_size; gr.MoveTo (pos_x, pos_y); gr.LineTo (pos_x, pos_y + figure_size); gr.Stroke (); } pos_y = y + center_square; pos_x = x + center_square; for (int line = 0; line < lines; line++) // Circles { for (int column = 0; column < columns; column++) { if (puzzle[index + (columns * line) + column] == false) continue; gr.Arc (pos_x + (square_size * column), pos_y, radius_square, 0, 2 * Math.PI); gr.Fill (); gr.Stroke (); } pos_y += square_size; } }
private void DrawSquare(CairoContextEx gr, double x, double y) { // XX // XX for (int i = 0; i < 2; i++) { if (quest1 [i] != X) { gr.Rectangle (x + i * rect_witdh, y, rect_witdh, rect_height); gr.FillGradient (x + i * rect_witdh, y, rect_witdh, rect_height, ColorForPortion (quest1 [i])); } gr.Rectangle (x + i * rect_witdh, y, rect_witdh, rect_height); gr.Stroke (); if (quest1 [i + 2] != X) { gr.Rectangle (x + i * rect_witdh, y + rect_height, rect_witdh, rect_height); gr.FillGradient (x + i * rect_witdh, y + rect_height, rect_witdh, rect_height, ColorForPortion (quest1 [i + 2])); } gr.Rectangle (x + i * rect_witdh, y + rect_height, rect_witdh, rect_height); gr.Stroke (); } }
public void Draw(CairoContextEx cr, int width, int height, bool rtl) { double x = 0, y = 0; // Background cr.Color = new Cairo.Color (1, 1, 1); cr.Paint (); cr.Stroke (); cr.LineWidth = point_size; cr.Rectangle (x, y, area_w, area_h); cr.Clip (); DrawLines (cr, grid_x, grid_y); cr.ResetClip (); DrawLegend (cr, x + grid_offsetx, y + area_h + 0.06); DrawGrid (cr, grid_x, grid_y); DrawAxisDescription (cr, x + area_w + 0.01, 0.78, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Time")); DrawAxisDescription (cr, 0, 0.03, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Score")); }
private static void DrawQuestionFigures(CairoContextEx gr, double x, double y, int figure) { switch (figure) { case 0: // XX // XX for (int i = 0; i < 2; i++) { gr.Rectangle (x + i * rect_witdh, y, rect_witdh, rect_height); gr.Rectangle (x + i * rect_witdh, y - rect_height, rect_witdh, rect_height); } gr.Stroke (); break; case 1: // X // XXX for (int i = 0; i < 3; i++) { gr.Rectangle (x + i * rect_witdh, y, rect_witdh, rect_height); } gr.Rectangle (x + 1 * rect_witdh, y - rect_height, rect_witdh, rect_height); gr.Stroke (); break; case 2: // X // XXX for (int i = 0; i < 3; i++) { gr.Rectangle (x + i * rect_witdh, y, rect_witdh, rect_height); } gr.Rectangle (x + 2 * rect_witdh, y - rect_height, rect_witdh, rect_height); gr.Stroke (); break; case 3: // XXXX for (int i = 0; i < 4; i++) { gr.Rectangle (x + i * rect_witdh, y, rect_witdh, rect_height); } gr.Stroke (); break; } }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = DrawAreaX + 0.1, y = DrawAreaY + 0.1, w = 0.6, h = 0.6; base.Draw (gr, area_width, area_height, rtl); gr.Rectangle (x, y, w, h); gr.Stroke (); // Lines gr.MoveTo (x + w /2, y); gr.LineTo (x + w /2, y + h); gr.Stroke (); gr.MoveTo (x, y + h /2); gr.LineTo (x + w, y + h / 2); gr.Stroke (); // Diagonals gr.MoveTo (x, y); gr.LineTo (x + w, y + h); gr.Stroke (); if (type == 1) { gr.MoveTo (x + w, y); gr.LineTo (x, y + h); gr.Stroke (); } if (Answer.Draw == false) return; // References gr.MoveTo (x - 0.04, y - 0.05); gr.ShowPangoText ("a"); gr.Stroke (); gr.MoveTo (x + w / 2 - 0.02, y - 0.05); gr.ShowPangoText ("b"); gr.Stroke (); gr.MoveTo (x + w + 0.02, y - 0.05); gr.ShowPangoText ("c"); gr.Stroke (); gr.MoveTo (x - 0.04, y + h /2 - 0.02); gr.ShowPangoText ("d"); gr.Stroke (); gr.MoveTo (x + w / 2 - 0.04, y + h /2 - 0.04); gr.ShowPangoText ("e"); gr.Stroke (); gr.MoveTo (x + w + 0.02, y + h /2 - 0.02); gr.ShowPangoText ("f"); gr.Stroke (); gr.MoveTo (x - 0.04, y + h + 0.02); gr.ShowPangoText ("g"); gr.Stroke (); gr.MoveTo (x + w / 2 - 0.02, y + h + 0.02); gr.ShowPangoText ("h"); gr.Stroke (); gr.MoveTo (x + w + 0.02, y + h + 0.02); gr.ShowPangoText ("i"); gr.Stroke (); }