-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraphic.cs
62 lines (49 loc) · 1.37 KB
/
Graphic.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Drawing;
using System.Windows.Forms;
namespace NeuralNetworkExample2
{
public class Graphic
{
Graphics g;
Pen pen = new Pen(Color.Red, 1);
int GraphicStep;
int x_current = 0;
float x_previous = 0;
float y_previous = 0;
Panel pnl_graphic;
public Graphic(Panel panelToDrawGraphicOn, int graphicStep)
{
pnl_graphic = panelToDrawGraphicOn;
g = pnl_graphic.CreateGraphics();
GraphicStep = graphicStep;
}
/// <summary>
/// Draw new point on graphic
/// </summary>
/// <param name="value"> percent </param>
public void DrawPoint(float value)
{
value = pnl_graphic.Height * value;
x_current += GraphicStep;
if (x_current > pnl_graphic.Width - GraphicStep)
{
ClearGraphic();
}
value = (int)value;
DrawPoint(x_current, value - 10);
}
void ClearGraphic()
{
g.Clear(pnl_graphic.BackColor);
x_current = GraphicStep;
x_previous = 0;
}
void DrawPoint(float x, float y)
{
g.DrawLine(pen, x_previous, y_previous, x, Math.Abs(y));
x_previous = x;
y_previous = y;
}
}
}