/
ClassFigure.cs
58 lines (53 loc) · 2.1 KB
/
ClassFigure.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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApp7
{
public class ClassFigure : Drower
{
public ClassFigure(Brush brush, IFigur figur, IFill fill) : base(brush, figur, fill)
{
}
public override void Draw(Point first, Point last,int nAngle,CreatedFigure cf)
{
cf.poin = cf.figur.Drow(first.X, first.Y, last.X, last.Y, nAngle);
cf.f = first;
cf.centr = cf.figur.centr;
cf.start = cf.figur.start;
cf.l = last;
for(int i = 0; i<cf.poin.Count-1;i++)
{
brush.DrawLine(cf.poin[i].X, cf.poin[i].Y, cf.poin[i + 1].X, cf.poin[i + 1].Y);
}
brush.DrawLine(cf.poin[0].X, cf.poin[0].Y, cf.poin[cf.poin.Count-1].X, cf.poin[cf.poin.Count-1].Y);
int x = (cf.poin[0].X + cf.poin[cf.poin.Count / 3].X + cf.poin[2 * cf.poin.Count / 3].X) / 3;//ищем куда лить
int y = (cf.poin[0].Y + cf.poin[cf.poin.Count / 3].Y + cf.poin[2 * cf.poin.Count / 3].Y) / 3;
if (cf.fill != null)
{
fill.SetColor(x, y);
fill.Casting(x, y);
}
}
public override void Draw(CreatedFigure cf)
{
for (int i = 0; i < cf.poin.Count - 1; i++)
{
brush.DrawLine(cf.poin[i].X, cf.poin[i].Y, cf.poin[i + 1].X, cf.poin[i + 1].Y);
}
if (cf.figur != null)
{
brush.DrawLine(cf.poin[0].X, cf.poin[0].Y, cf.poin[cf.poin.Count - 1].X, cf.poin[cf.poin.Count - 1].Y);
}
int x = (cf.poin[0].X + cf.poin[cf.poin.Count / 3].X + cf.poin[2 * cf.poin.Count / 3].X) / 3;//ищем куда лить
int y = (cf.poin[0].Y + cf.poin[cf.poin.Count / 3].Y + cf.poin[2 * cf.poin.Count / 3].Y) / 3;
if (cf.fill != null)
{
fill.SetColor(x, y);
fill.Casting(x, y);
}
}
}
}