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 x = DrawAreaX + 0.1, y = DrawAreaY + 0.2; const double witdh = 0.6, height = 0.5; base.Draw (gr, area_width, area_height, rtl); gr.MoveTo (x, y); gr.LineTo (x + witdh, y); gr.LineTo (x + witdh / 2, y + height / 2); gr.LineTo (x, y); gr.LineTo (x + 0.45, y + height /4); gr.Stroke (); if (type == 0) { gr.MoveTo (x + witdh / 2, y); gr.LineTo (x + witdh / 2, y + height / 2); gr.Stroke (); } gr.MoveTo (x + 0.152, y + 0.125); gr.LineTo (x + witdh, y); gr.Stroke (); if (Answer.Draw == false) return; // References gr.MoveTo (x - 0.02, y); gr.ShowPangoText ("a"); gr.MoveTo (x + witdh /2 - 0.02, y); gr.ShowPangoText ("b"); gr.MoveTo (x + witdh, y); gr.ShowPangoText ("c"); gr.MoveTo (x + witdh /2 - 0.03, y + 0.07 - 0.02); gr.ShowPangoText ("d"); gr.MoveTo (x + 0.11, y + 0.16); gr.ShowPangoText ("e"); gr.MoveTo (x + 0.47, y + 0.16); gr.ShowPangoText ("f"); gr.MoveTo (x + (witdh /2) - 0.01, y + 0.26); gr.ShowPangoText ("g"); }
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 DrawPossibleAnswers(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x= DrawAreaX + 0.125, y = DrawAreaY + 0.1; int cnt = 0; for (int i = 0; i < showed; i++) { if (i == answer) continue; gr.MoveTo (x, y); gr.ShowPangoText (animals[animals_order[i]]); gr.Stroke (); if ((cnt + 1) % 3 == 0) { y += 0.2; x = DrawAreaX + 0.125; } else { x+= 0.25; } cnt++; } gr.Color = new Color (0.9, 0.9, 0.9); gr.DrawTextCentered (0.5, DrawAreaY, "This is an extension sample"); }
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 void DrawTimeBar(CairoContextEx gr, double x, double y, double percentage) { double width = 0.04, height = 0.6; const double w = 0.003, h = 0.003; gr.DrawTextCentered(x + (width / 2), y + height + 0.05, ServiceLocator.Instance.GetService <ITranslations> ().GetString("Time left")); gr.Stroke(); gr.Save(); gr.Color = new Color(0, 0, 0); gr.MoveTo(x, y); gr.LineTo(x, y + height); gr.LineTo(x + width, y + height); gr.LineTo(x + width, y); gr.LineTo(x, y); gr.Stroke(); x += w; y += h; width -= w * 2; height -= h * 2; y += height * (100 - percentage) / 100; height *= percentage / 100; if (gradient == null) { gradient = new LinearGradient(x, y, x + width, y + height); gradient.AddColorStop(0, new Color(1, 0, 0, 1)); gradient.AddColorStop(1, new Color(0.2, 0, 0, 1)); } gr.Source = gradient; gr.MoveTo(x, y); gr.LineTo(x, y + height); gr.LineTo(x + width, y + height); gr.LineTo(x + width, y); gr.LineTo(x, y); gr.FillPreserve(); gr.Stroke(); gr.Restore(); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = DrawAreaX + 0.1, y = DrawAreaY + 0.05; base.Draw (gr, area_width, area_height, rtl); for (int i = 0; i < circles.Length; i++) { gr.Arc (x + circles[i].x + 0.1, y + circles[i].y + 0.1, circles[i].rad, 0, 2 * Math.PI); gr.Stroke (); } }
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 DrawObjectToMemorize(CairoContextEx gr, int area_width, int area_height, bool rtl) { base.DrawObjectToMemorize (gr, area_width, area_height, rtl); if (Answer.Draw == false) { for (int i = 0; i < indications.Length; i++) { gr.MoveTo (0.3, 0.2 + i * 0.08); gr.ShowPangoText (indications[i].ToString ()); gr.Stroke (); } } else { for (int i = 0; i < indications.Length; i++) { gr.MoveTo (0.1, 0.2 + i * 0.08); gr.ShowPangoText (indications[i].ToString ()); gr.Stroke (); } DrawPossibleAnswers (gr, 0.7, 0.3, WhichAnswer (answers[ans])); gr.MoveTo (0.7, 0.5); gr.ShowPangoText (Answer.GetFigureName (ans)); gr.Stroke (); } }
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 void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { gr.Scale (area_width, area_height); gr.LineWidth = 0.01; gr.Color = new Cairo.Color (0, 0, 0, 1); gr.SetPangoLargeFontSize (); gr.DrawTextCentered (0.5, 0.1, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Get ready to memorize the next objects...")); gr.Stroke (); gr.SetPangoFontSize (0.35); gr.DrawTextCentered (0.5, 0.5, countdown_time.ToString ()); gr.Stroke (); gr.Arc (0.5, 0.5, 0.25, 0, 2 * Math.PI); gr.Stroke (); gr.Arc (0.5, 0.5, 0.28, 0, 2 * Math.PI); gr.Stroke (); }
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) { const double aligned_pos = 0.58; base.Draw (gr, area_width, area_height, rtl); gr.SetPangoLargeFontSize (); gr.DrawTextAlignedRight (aligned_pos, DrawAreaY + 0.2, number_a.ToString ()); gr.DrawTextAlignedRight (aligned_pos, DrawAreaY + 0.3, number_b.ToString ()); gr.DrawTextAlignedRight (aligned_pos, DrawAreaY + 0.4, number_c.ToString ()); gr.MoveTo (DrawAreaX + 0.2, DrawAreaY + 0.5); gr.LineTo (DrawAreaX + 0.5, DrawAreaY + 0.5); gr.Stroke (); gr.DrawTextAlignedRight (aligned_pos, DrawAreaY + 0.55, total.ToString ()); gr.MoveTo (DrawAreaX + 0.2, DrawAreaY + 0.25); gr.ShowPangoText ((Answer.Draw == true) ? oper1.ToString () : "?"); gr.MoveTo (DrawAreaX + 0.2, DrawAreaY + 0.35); gr.ShowPangoText ((Answer.Draw == true) ? oper2.ToString () : "?"); }
public override void DrawPossibleAnswers(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x= DrawAreaX + 0.125, y = DrawAreaY + 0.1; int cnt = 0; for (int i = 0; i < showed; i++) { if (i == answer) continue; gr.MoveTo (x, y); gr.ShowPangoText (words[words_order[i]]); gr.Stroke (); if ((cnt + 1) % 3 == 0) { y += 0.2; x = DrawAreaX + 0.125; } else { x+= 0.25; } cnt++; } }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = DrawAreaX + 0.22, y = DrawAreaY + 0.2; double pos_x = x; double pos_y = y; Circle[] circles = null; base.Draw (gr, area_width, area_height, rtl); circles = new Circle [] { new Circle (0.01, 0.06), new Circle (0.27, 0.06), new Circle (0.01, 0.21), new Circle (0.27, 0.21), new Circle (0.14, 0), new Circle (0.14, 0.29) }; // Circle gr.Arc (pos_x + figure_size, pos_y + figure_size, figure_size, 0, 2 * Math.PI); gr.Stroke (); const double point_size = 0.01; for (int i = 0; i < circles.Length; i++) { gr.Arc (x + point_size + circles[i].x, y + point_size + circles[i].y, point_size, 0, 2 * Math.PI); gr.Fill (); gr.Stroke (); } gr.MoveTo (x + circles[2].x + 0.01, y + circles[2].y + 0.01); gr.LineTo (x + circles[1].x + 0.01, y + circles[1].y + 0.01); gr.Stroke (); gr.DrawTextCentered (pos_x + figure_size, pos_y + 0.08 + figure_size * 2, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Two people in the table sitting across each other")); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = DrawAreaX, y = 0.05; base.Draw (gr, area_width, area_height, rtl); gr.MoveTo (0.05, y); gr.SetPangoLargeFontSize (); gr.ShowPangoText (Translations.GetString ("Numbers")); y += 0.08; for (int n = 0; n < numbers.Length; n++) { gr.MoveTo (x, y); gr.ShowPangoText (numbers[n].ToString ()); gr.Stroke (); x += 0.17; } y += 0.16; gr.MoveTo (0.05, y); gr.ShowPangoText (Translations.GetString ("Possible divisors")); }
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 (); } }
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 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 override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { base.Draw (gr, area_width, area_height, rtl); gr.MoveTo (0.1, 0.3); gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:")); gr.Stroke (); }
void GenerateAnswers(CairoContextEx cr, Game [] games, int columns, int rows) { int x, y, page; string str; int column, row; const int space_lines = 80; x = y = page = 0; column = row = 0; // Draw solution title cr.SetPangoFontSize(20); cr.DrawStringWithWrapping(x + margin, y + margin, Translations.GetString("Solutions"), width - margin); y += space_lines; cr.Stroke(); cr.SetPangoFontSize(12); cr.UseMarkup = true; for (int i = 0; i < games.Length; i++) { str = String.Format(Translations.GetString("Game #{0}. {1}"), i + 1, games[i].AnswerText); // Draw Solution cr.DrawStringWithWrapping(x + margin, y + margin, str, width - margin); cr.Stroke(); y += space_lines; // Next lateral page (right) if (y + space_lines >= page_height * (row + 1) && x + page_width < page_width * columns) { column++; x = column * page_width; y = row * page_height; page++; } else { // No more space (right), new row if (y + space_lines >= page_height * (row + 1) && x + page_width >= page_width * columns) { row++; column = 0; x = column * page_width; y = row * page_height; page++; } } if (page >= rows * columns) { cr.ShowPage(); page = x = y = 0; column = row = 0; } } if (y > 0) { cr.ShowPage(); } }
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 (); }
private static void DrawSlice(CairoContextEx gr, double x, double y) { double degrees, x1, y1; degrees = 0; gr.MoveTo (x, y); x1 = x + radius * Math.Cos (degrees); y1 = y + radius * Math.Sin (degrees); gr.LineTo (x1, y1); gr.Stroke (); degrees = radian * 60; gr.MoveTo (x, y); x1 = x + radius * Math.Cos (degrees); y1 = y + radius * Math.Sin (degrees); gr.LineTo (x1, y1); gr.Stroke (); gr.Arc (x, y, radius, 0, radian * 60); gr.Stroke (); }
public void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double y = 0.04, x = 0.05; const double space_small = 0.02; List <PlayerPersonalRecord> records; string s, tip, played; double width, height; gr.Scale (area_width, area_height); gr.Color = new Cairo.Color (0, 0, 0, 1); gr.MoveTo (x, y); gr.ShowPangoText (Translations.GetString ("Score"), false, -1, 0); DrawBand (gr, 0.03, y - 0.01); y += 0.08; gr.MoveTo (x, y); s = session.History.GetResult (Translations); // Translator: This will be part of the sentence "Games won: 10 (6 played)" played = String.Format (Translations.GetPluralString ("{0} played", "{0} played", session.History.GamesPlayed), session.History.GamesPlayed); if (s == string.Empty) { gr.ShowPangoText (String.Format (Translations.GetPluralString ("Games won: {0} ({1})", "Games won: {0} ({1})", session.History.GamesWon), session.History.GamesWon, played)); } else { gr.ShowPangoText (String.Format (Translations.GetPluralString ("{0}. Games won: {1} ({2})", "{0}. Games won: {1} ({2})", session.History.GamesWon), s, session.History.GamesWon, played)); } y += 0.06; gr.MoveTo (x, y); gr.ShowPangoText (String.Format (Translations.GetString ("Time played {0} (average per game {1})"), session.GameTime, session.TimePerGame)); y += 0.09; DrawColumnBarGraphic (gr, x, y); y += 0.36; gr.MoveTo (x, y); gr.SetPangoFontSize (smaller_font); // Translators: translated string should not be longer that the English original (space restriction on the UI) gr.ShowPangoText (Translations.GetString ("For details on how gbrainy's scoring works refer to the help.")); y += 0.07; gr.SetPangoNormalFontSize (); records = session.PlayerHistory.GetLastGameRecords (); gr.MoveTo (x, y); if (records.Count == 0) { bool caching = cached_sessionid != session.ID; gr.ShowPangoText (Translations.GetString ("Tips for your next games"), false, -1, 0); DrawBand (gr, 0.03, y - 0.01); y += 0.08; if (caching) tips.Clear (); for (int i = 0; i < tips_shown; i++) { if (caching) tips.Add (game_tips.Tip); tip = "- " + tips [i]; gr.MeasureString (tip, 1.0 - x, true, out width, out height); if (y + height > 0.98) break; gr.DrawStringWithWrapping (x, y, tip , 1.0 - x); y += height + space_small; } if (caching) cached_sessionid = session.ID; } else { gr.ShowPangoText (Translations.GetString ("Congratulations! New personal record"), false, -1, 0); DrawBand (gr, 0.03, y - 0.01); y += 0.08; for (int i = 0; i < records.Count; i++) { switch (records[i].GameType) { case GameTypes.LogicPuzzle: s = String.Format (Translations. GetString ("By scoring {0} in logic puzzle games you have established a new personal record. Your previous record was {1}."), records[i].NewScore, records[i].PreviousScore); break; case GameTypes.Calculation: s = String.Format (Translations. GetString ("By scoring {0} in calculation games you have established a new personal record. Your previous record was {1}."), records[i].NewScore, records[i].PreviousScore); break; case GameTypes.Memory: s = String.Format (Translations. GetString ("By scoring {0} in memory games you have established a new personal record. Your previous record was {1}."), records[i].NewScore, records[i].PreviousScore); break; case GameTypes.VerbalAnalogy: s = String.Format (Translations. GetString ("By scoring {0} in verbal analogies you have established a new personal record. Your previous record was {1}."), records[i].NewScore, records[i].PreviousScore); break; default: break; } tip = "- " + s; gr.MeasureString (tip, 1.0 - x, true, out width, out height); if (y + height > 0.98) break; gr.DrawStringWithWrapping (x, y, tip , 1.0 - x); y += height + space_small; } } gr.Stroke (); }
void DrawColumnBarGraphic(CairoContextEx gr, double x, double y) { const double area_w = 0.85, area_h = 0.28; const double bar_w = 0.05, bar_h = area_h - 0.02; const double space_x = 0.08; gr.LineWidth = 0.005; // Draw X reference values gr.SetPangoFontSize (smaller_font); gr.DrawTextAlignedRight (x + 0.05, y, "100"); gr.DrawTextAlignedRight (x + 0.05, y + area_h - 0.02, "0"); x += 0.06; // Axis gr.MoveTo (x, y); gr.LineTo (x, y + area_h); gr.LineTo (x + area_w, y + area_h); gr.Stroke (); x = x + space_x; DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.TotalScore); gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, Translations.GetString ("Total")); x = x + space_x * 2; if (session.History.LogicPlayed > 0) DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.LogicScore); gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, Translations.GetString ("Logic")); x = x + space_x * 2; if (session.History.MathPlayed > 0) DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.MathScore); gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, Translations.GetString ("Calculation")); x = x + space_x * 2; if (session.History.MemoryPlayed > 0) DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.MemoryScore); gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, Translations.GetString ("Memory")); x = x + space_x * 2; if (session.History.VerbalPlayed > 0) DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.VerbalScore); gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, Translations.GetString ("Verbal")); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { base.Draw (gr, area_width, area_height, rtl); if (gametype == GameType.Present) { gr.DrawImageFromAssembly ("present.svg", 0.2, 0.4, 0.6, 0.2); } else { if (gametype == GameType.Fence) { double x105, y105, y; const double x = 0.35; const double figure_size = 0.4; x105 = figure_size * Math.Cos (105 * Math.PI / 180); y105 = figure_size * Math.Sin (105 * Math.PI / 180); y = (1 - y105) / 2; 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); gr.Stroke (); } } }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { const double size = 0.05; const double radian = Math.PI / 180; const int degrees = -45; const double radius = 0.035; const double size_y = 0.025; double x = DrawAreaX + 0.1; double y = DrawAreaY + 0.3; double x0, y0, offset_y; double offset_x = 0; base.Draw (gr, area_width, area_height, rtl); x = 1 - (2 * DrawAreaX) - (columns * size * 1.5); x = DrawAreaX + x /2; // Front face for (int pos_y = 0; pos_y < rows; pos_y++) { // | // | // gr.MoveTo (x, y + (pos_y * size)); gr.LineTo (x, y + ((pos_y + 1) * size)); gr.Stroke (); for (int pos_x = 0; pos_x < columns; pos_x++) { // ---| // | // gr.MoveTo (x + (size * pos_x) , y + (pos_y * size)); gr.LineTo (x + (size * (pos_x + 1)), y + (pos_y * size)); gr.LineTo (x + (size * (pos_x + 1)), y + (pos_y + 1) * size); gr.Stroke (); } } gr.MoveTo (x , y + (rows * size)); gr.LineTo (x + (columns * size) , y + (rows * size)); gr.Stroke (); // Back face for (int pos_y = 0; pos_y < rows; pos_y++) { offset_x = (0.025 * pos_y); // | // | // gr.MoveTo (x + offset_x, y - (pos_y * size_y)); gr.LineTo (x + offset_x + 0.025, y - ((pos_y + 1) * size_y)); gr.Stroke (); for (int pos_x = 0; pos_x < columns; pos_x++) { gr.MoveTo (x + offset_x + (size * pos_x) , y - (pos_y * size_y)); gr.LineTo (x + offset_x + (size * (pos_x + 1)), y - (pos_y * size_y)); gr.LineTo (x + offset_x + 0.025 + (size * (pos_x + 1)), y - (pos_y + 1) * size_y); gr.Stroke (); } } offset_x = (0.025 * columns); gr.MoveTo (x + offset_x, y - (rows * size_y)); gr.LineTo (x + offset_x + (size * columns) , y - (rows * size_y)); gr.Stroke (); // Lateral face for (int pos_y = 0; pos_y < rows; pos_y++) { for (int pos_x = 0; pos_x < columns; pos_x++) { offset_x = (size * columns) + (0.025 * pos_x); offset_y = size_y * pos_x; gr.MoveTo (x + offset_x, y - offset_y + (pos_y * size)); gr.LineTo (x + offset_x, y - offset_y + (pos_y + 1) * size); x0 = radius * Math.Cos (degrees * radian); y0 = radius * Math.Sin (degrees * radian); gr.LineTo (x + offset_x + x0, y - offset_y + y0 + (pos_y + 1) * size); gr.Stroke (); } } offset_x = (size * columns) + (0.025 * columns); offset_y = size_y * rows; gr.MoveTo (x + offset_x, y - offset_y); gr.LineTo (x + offset_x, y - offset_y + (rows * size)); gr.Stroke (); }
private static void DrawLine(CairoContextEx gr, double x, double y, double w, double h) { gr.MoveTo (x, y); gr.LineTo (x + w, y + h); gr.Stroke (); }
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, int area_width, int area_height, bool rtl) { double x = DrawAreaX + 0.2, y = DrawAreaY; double x0, y0, degrees; int pos; base.Draw (gr, area_width, area_height, rtl); gr.Arc (x + arc_centerx, y + arc_centery, radius, 0, 2 * Math.PI); gr.Stroke (); for (int slice = 0; slice < total_slices; slice++) { degrees = radian * slice * (360 / total_slices); gr.MoveTo (x + arc_centerx, y + arc_centery); gr.LineTo (x + arc_centerx + (radius * Math.Cos (degrees)), y + arc_centery + (radius * Math.Sin (degrees))); if (slice > total_slices - 1) continue; if (slice == 0) { degrees = radian * (slice * ((360 / total_slices)) + (360 / 12)); x0 = 0.5 * radius * Math.Cos (degrees); y0 = 0.5 * radius * Math.Sin (degrees); gr.DrawTextCentered (x + arc_centerx + x0, y + arc_centery + y0, "?"); continue; } if (slice < half_slices) { pos = random_indices [slice]; DrawSliceText (gr, x + arc_centerx, y + arc_centery, slice, (sum_offset + slices [pos * items_per_slice]).ToString (), (sum_offset + slices [1 + (pos * items_per_slice)]).ToString (), (sum_offset + slices [2 + (pos * items_per_slice)]).ToString ()); } else { pos = random_indices [slice - half_slices]; DrawSliceText (gr, x + arc_centerx, y + arc_centery, slice, slices_opposite [pos * items_per_slice].ToString (), slices_opposite [2 + (pos * items_per_slice)].ToString (), slices_opposite [1 + (pos * items_per_slice)].ToString ()); } } gr.MoveTo (0.1, 0.55); gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:")); gr.Stroke (); }
static void GenerateAnswers(CairoContextEx cr, Game [] games, int columns, int rows) { int x, y, page; string str; int column, row; const int space_lines = 80; x = y = page = 0; column = row = 0; // Draw solution title cr.SetPangoFontSize (20); cr.DrawStringWithWrapping (x + margin, y + margin, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Solutions"), width - margin); y += space_lines; cr.Stroke (); cr.SetPangoFontSize (12); cr.UseMarkup = true; for (int i = 0; i < games.Length; i++) { str = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Game #{0}. {1}"), i + 1, games[i].AnswerText); // Draw Solution cr.DrawStringWithWrapping (x + margin, y + margin, str, width - margin); cr.Stroke (); y += space_lines; // Next lateral page (right) if (y + space_lines >= page_height * (row + 1) && x + page_width < page_width * columns) { column++; x = column * page_width; y = row * page_height; page++; } else { // No more space (right), new row if (y + space_lines >= page_height * (row + 1) && x + page_width >= page_width * columns) { row++; column = 0; x = column * page_width; y = row * page_height; page++; } } if (page >= rows * columns) { cr.ShowPage (); page = x = y = 0; column = row = 0; } } if (y > 0) cr.ShowPage (); }
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; } }
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(); } }