[chronojump] cairo xy can have a grid of integers
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] cairo xy can have a grid of integers
- Date: Thu, 6 Aug 2020 15:20:40 +0000 (UTC)
commit 369f2dcc0d488f959a7f630d0c57239f3606947e
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Aug 6 17:19:58 2020 +0200
cairo xy can have a grid of integers
src/gui/cairo/xy.cs | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
---
diff --git a/src/gui/cairo/xy.cs b/src/gui/cairo/xy.cs
index c4a5232c..a4d3fab4 100644
--- a/src/gui/cairo/xy.cs
+++ b/src/gui/cairo/xy.cs
@@ -574,6 +574,34 @@ public abstract class CairoXY
g.Restore();
}
+ //for a grid of integers
+ protected void paintGridInt (double minX, double maxX, double minY, double maxY, int by, gridTypes
gridType)
+ {
+ g.Save();
+ g.SetDash(new double[]{1, 2}, 0);
+ if(gridType != gridTypes.HORIZONTALLINES)
+ for(double i = Math.Floor(minX); i <= Math.Ceiling(maxX) ; i += by)
+ {
+ int xtemp = Convert.ToInt32(calculatePaintX(i));
+ if(xtemp <= outerMargins || xtemp >= graphWidth - outerMargins)
+ continue;
+
+ paintVerticalGridLine(xtemp, Util.TrimDecimals(i, 2));
+ }
+
+ if(gridType != gridTypes.VERTICALLINES)
+ for(double i = Math.Floor(minX); i <= Math.Ceiling(maxY) ; i += by)
+ {
+ int ytemp = Convert.ToInt32(calculatePaintY(i));
+ if(ytemp <= outerMargins || ytemp >= graphHeight - outerMargins)
+ continue;
+
+ paintHorizontalGridLine(ytemp, Util.TrimDecimals(i, 2));
+ }
+ g.Stroke ();
+ g.Restore();
+ }
+
protected void paintHorizontalGridLine(int ytemp, string text)
{
g.MoveTo(outerMargins, ytemp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]