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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
| using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication11
{
public partial class Form1 : Form
{
public PointF location;
public PointF resetLocation;
public PointF[] figurePoints;
public PointF[] standardPoints;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Paint += new PaintEventHandler(Form1_Paint);
}
/// <summary>
/// //////////////////////
/// </summary>
/// <param name="e"></param>
static class RasterAlgorithm
{
public static void BresenhamCircle(Graphics g, Color clr, int _x, int _y, int radius)
{
int x = 0, y = radius, gap = 0, delta = (2 - 2 * radius);
while (y >= 0)
{
PutPixel(g, clr, _x + x, _y + y, 255);
PutPixel(g, clr, _x + x, _y - y, 255);
PutPixel(g, clr, _x - x, _y - y, 255);
PutPixel(g, clr, _x - x, _y + y, 255);
gap = 2 * (delta + y) - 1;
if (delta < 0 && gap <= 0)
{
x++;
delta += 2 * x + 1;
continue;
}
if (delta > 0 && gap > 0)
{
y--;
delta -= 2 * y + 1;
continue;
}
x++;
delta += 2 * (x - y);
y--;
}
}
//Метод, устанавливающий пиксел на форме с заданными цветом и прозрачностью
private static void PutPixel(Graphics g, Color col, int x, int y, int alpha)
{
g.FillRectangle(new SolidBrush(Color.FromArgb(alpha, col)), x, y, 1, 1);
}
}
public void OnPaint(PaintEventArgs e)
{
//Отрисовка окружности, построенной по алгоритму Брезенхема
RasterAlgorithm.BresenhamCircle(
e.Graphics,
Color.Black,
150, 150, 75);
}
/// <summary>
/// //////////////////
/// </summary>
double a1;
double b1;
double c1;
double d;
double m; double n; double p; double q; double s;
Point[] points = {new Point(405, 123), new Point(264, 158), new Point(222, 10), new Point(180, 157), new Point(40, 123),
new Point(138, 235), new Point(222, 463), new Point(180, 313), new Point(264, 313), new Point(40, 350), new Point(405, 350),
new Point(306, 235), new Point(222, 235)};
Point point1 = new Point(405, 123);//правый верх вершина
Point point2 = new Point(264, 158);//вершина правй
Point point3 = new Point(222, 10); //verx
Point point11 = new Point(180, 157);
Point point12 = new Point(40, 123);//левый верх вершина 235= y = 222=x points[2].X points[5].Y
Point point13 = new Point(138, 235);//235 у centr 264 x centr
Point point4 = new Point(222, 463);//вершина низ
Point point5 = new Point(180, 313);//првый верх
Point point6 = new Point(264, 313);//правый низ
Point point7 = new Point(40, 350);
Point point8 = new Point(405, 350);
Point point9 = new Point(306, 235); //правй
Point point14 = new Point(222, 235);
Point point15 = new Point(0, -300);
Point point16 = new Point(0, 300);
Point point17 = new Point(-300, 0);
Point point18 = new Point(300, 0);
Point point19 = new Point(0, 0);
Point point20 = new Point(300, 300);
int x=138;
int y=148;
int a = 168;
int b = 175;
void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.Transform = new System.Drawing.Drawing2D.Matrix(1, 0, 0, 1, 300, 300);
e.Graphics.FillRectangle(System.Drawing.Brushes.Blue, 10, 10, 1, 1);
Pen blackPen = new Pen(Color.Blue, 3);
Pen ololo = new Pen(Color.Red, 3);
// Создал точки для звезды
//Создал круг и соединил точки
e.Graphics.DrawEllipse(blackPen, x, y, a, b);
e.Graphics.DrawLine(blackPen, points[6], points[7]);
e.Graphics.DrawLine(blackPen, points[6], points[8]);
e.Graphics.DrawLine(blackPen, points[7], points[9]);
e.Graphics.DrawLine(blackPen, points[8], points[10]);
e.Graphics.DrawLine(blackPen, points[10], points[11]);
e.Graphics.DrawLine(blackPen, points[4], points[5]);
e.Graphics.DrawLine(ololo, points[11], points[0]);
e.Graphics.DrawLine(blackPen, points[0], points[1]);
e.Graphics.DrawLine(blackPen, points[1], points[2]);
e.Graphics.DrawLine(blackPen, points[2], points[3]);
e.Graphics.DrawLine(blackPen, points[2], points[3]);
e.Graphics.DrawLine(blackPen, points[3], points[4]);
e.Graphics.DrawLine(blackPen, points[5], points[9]);
e.Graphics.DrawLine(blackPen, point15, point16);
e.Graphics.DrawLine(blackPen, point17, point18);
e.Graphics.DrawLine(blackPen, point19, point20);
}
public void textBox1_TextChanged(object sender, EventArgs e)
{
// int a21 = Convert.ToInt32(Values.Text);
}
private void textBox1_TextChanged_1(object sender, EventArgs e)
{
}
public void button1_Click(object sender, EventArgs e)
{
a1 = Convert.ToDouble(Values.Text);
x += Convert.ToInt32(a1);
for (int i = 0; i < 13; i++)
{
points[i].X = points[i].X +Convert.ToInt32(a1);
}
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 2000, 2000));
myBrush.Dispose();
formGraphics.Dispose();
Graphics g = CreateGraphics();
Rectangle rec = new Rectangle();
PaintEventArgs es = new PaintEventArgs(g, rec);
Form1_Paint(sender, es);
}
private void Down_Click(object sender, EventArgs e)
{
a1 = Convert.ToInt32(Values.Text);
x -= Convert.ToInt32(a1);
for (int i = 0; i < 13; i++)
{
points[i].X = points[i].X - Convert.ToInt32(a1);
}
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 2000, 2000));
myBrush.Dispose();
formGraphics.Dispose();
Graphics g = CreateGraphics();
Rectangle rec = new Rectangle();
PaintEventArgs es = new PaintEventArgs(g, rec);
Form1_Paint(sender, es);
}
private void button3_Click(object sender, EventArgs e)
{
b1 = Convert.ToInt32(ValuesY.Text);
y += Convert.ToInt32(b1);
for (int i = 0; i < 13; i++)
{
points[i].Y = points[i].Y + Convert.ToInt32(b1);
}
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 2000, 2000));
myBrush.Dispose();
formGraphics.Dispose();
Graphics g = CreateGraphics();
Rectangle rec = new Rectangle();
PaintEventArgs es = new PaintEventArgs(g, rec);
Form1_Paint(sender, es);
}
private void button4_Click(object sender, EventArgs e)
{
b1 = Convert.ToInt32(ValuesY.Text);
y -= Convert.ToInt32(b1);
for (int i = 0; i < 13; i++)
{
points[i].Y = points[i].Y - Convert.ToInt32(b1);
}
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 2000, 2000));
myBrush.Dispose();
formGraphics.Dispose();
Graphics g = CreateGraphics();
Rectangle rec = new Rectangle();
PaintEventArgs es = new PaintEventArgs(g, rec);
Form1_Paint(sender, es);
}
private void button5_Click(object sender, EventArgs e)
{
double z;
z = x;
a1 = Convert.ToDouble(ZoomX.Text);
b1 = Convert.ToDouble(ZoomY.Text);
x = Convert.ToInt32(a1 * x); z = y; y = Convert.ToInt32(b1 * z); z = a; a = Convert.ToInt32(a1 * z); z = b; b = Convert.ToInt32(b1*z);
for (int i = 0; i < 13; i++)
{
int s = points[i].X;
int h = points[i].Y;
points[i].X = Convert.ToInt32(s * a1 + s * c1 + s * m);
points[i].Y = Convert.ToInt32(h * b1 + h * d + h * n);
}
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 2000, 2000));
myBrush.Dispose();
formGraphics.Dispose();
Graphics g = CreateGraphics();
Rectangle rec = new Rectangle();
PaintEventArgs es = new PaintEventArgs(g, rec);
Form1_Paint(sender, es);
}
private void button6_Click(object sender, EventArgs e)
{
double z = Convert.ToDouble(Angle.Text);
//int l = Convert.ToInt32(Angle.Text);
z = z/180*3.14;
// int x = 138; 235= y = 222=x points[2].X points[5].Y
//int y = 148;
/* x1 = x0+(x-x0)*cos(L)-(y-y0)*sin(L);
y1 = y0+(x-x0)*sin(L)+(y-y0)*cos(L);
Где
x1, y1 - новые координаты
x , y - старые координаты
x0, y0 - координаты центра вращения
L - угол в градусах, если правильно помню.*/
// int x1 = points[2].X-x;
// int y1 = points[5].Y-y;
x = Convert.ToInt32(x * Math.Cos(z) - y * Math.Sin(z));
y = Convert.ToInt32(x * Math.Sin(z) + y * Math.Cos(z));
// x = Convert.ToInt32(points[2].X * Math.Cos(z) - points[5].Y * Math.Sin(z)-x1);
// y = Convert.ToInt32(points[2].X * Math.Sin(z) + points[5].Y * Math.Cos(z)-y1);
for (int i = 0; i < 13; i++)
{
int s = points[i].X;
int h = points[i].Y;
points[i].X = Convert.ToInt32(s * Math.Cos(z) - h * Math.Sin(z) );
points[i].Y = Convert.ToInt32(s * Math.Sin(z) + h * Math.Cos(z) );
}
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 2000, 2000));
myBrush.Dispose();
formGraphics.Dispose();
Graphics g = CreateGraphics();
Rectangle rec = new Rectangle();
PaintEventArgs es = new PaintEventArgs(g, rec);
Form1_Paint(sender, es);
}
private void button7_Click(object sender, EventArgs e)
{
/*point3.Y = point3.Y + (point14.Y - point3.Y) / 2; point3.X = point3.X - (point3.X - point14.X) / 2;//samiy verx
point9.X = point9.X - (point9.X - point14.X) / 2; point9.Y = point9.Y - (point9.Y - point14.Y) / 2; // praviy centr
point13.X = point13.X + (point14.X - point13.X) / 2; point13.Y = point13.Y + (point14.Y - point13.Y) / 2;// leviy centr
point4.Y = point4.Y - (point4.Y - point14.Y) / 2; point4.X = point4.X + (point14.X - point4.X) / 2;//niz vershina
point1.X = point1.X - (point1.X - point14.X) / 2; point1.Y = point1.Y + (point14.Y - point1.Y) / 2;
point8.X = point8.X - (point8.X - point14.X) / 2; point8.Y = point8.Y - (point8.Y - point14.Y) / 2;
point7.X = point7.X + (point14.Y - point7.X) / 2; point7.Y = point7.Y - (point7.Y - point14.Y) / 2;
point12.X = point12.X + (point14.X - point12.X) / 2; point12.Y = point12.Y + (point14.Y - point12.Y) / 2;
point2.X = point2.X - (point2.X - point14.X) / 2; point2.Y = point2.Y + (point14.Y - point2.Y) / 2;
point6.X = point6.X - (point6.X - point14.X) / 2; point6.Y = point6.Y - (point6.Y - point14.Y) / 2;
point5.X = point5.X + (point14.X - point5.X) / 2; point5.Y = point5.Y - (point5.Y - point14.Y) / 2;
point11.X = point11.X + (point14.X - point11.X) / 2; point11.Y = point11.Y + (point14.Y - point11.Y) / 2;
a /= 2;
b /= 2;
x = x + (point14.X - x) / 2; y = y + (point14.Y - y) / 2;
*/
double d = Convert.ToDouble(AnyDotRotate.Text);
int X1 = Convert.ToInt32(DotX.Text);
int Y1 = Convert.ToInt32(DotY.Text);
d = d / 180 * 3.14;
for (int i = 0; i < 13; i++)
{
int s = points[i].X;
int h = points[i].Y;
points[i].X = Convert.ToInt32(X1+(s-X1) * Math.Cos(d) - (h-Y1) * Math.Sin(d));
points[i].Y = Convert.ToInt32(Y1+(s-Y1) * Math.Sin(d) + (h-Y1) * Math.Cos(d));
}
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 2000, 2000));
myBrush.Dispose();
formGraphics.Dispose();
Graphics g = CreateGraphics();
Rectangle rec = new Rectangle();
PaintEventArgs es = new PaintEventArgs(g, rec);
Form1_Paint(sender, es);
}
private void button8_Click(object sender, EventArgs e)
{
/*point3.Y = point3.Y - (point14.Y - point3.Y) ; point3.X = point3.X + (point3.X - point14.X) ;//samiy verx
point9.X = point9.X + (point9.X - point14.X) ; point9.Y = point9.Y + (point9.Y - point14.Y) ; // praviy centr
point13.X = point13.X - (point14.X - point13.X) ; point13.Y = point13.Y - (point14.Y - point13.Y) ;// leviy centr
point4.Y = point4.Y + (point4.Y - point14.Y) ; point4.X = point4.X - (point14.X - point4.X) ;//niz vershina
point1.X = point1.X + (point1.X - point14.X) ; point1.Y = point1.Y - (point14.Y - point1.Y) ;
point8.X = point8.X + (point8.X - point14.X) ; point8.Y = point8.Y + (point8.Y - point14.Y) / 2;
point7.X = point7.X - (point14.Y - point7.X) ; point7.Y = point7.Y + (point7.Y - point14.Y) ;
point12.X = point12.X - (point14.X - point12.X) ; point12.Y = point12.Y - (point14.Y - point12.Y) ;
point2.X = point2.X + (point2.X - point14.X) ; point2.Y = point2.Y - (point14.Y - point2.Y) ;
point6.X = point6.X + (point6.X - point14.X) ; point6.Y = point6.Y + (point6.Y - point14.Y) ;
point5.X = point5.X - (point14.X - point5.X) ; point5.Y = point5.Y + (point5.Y - point14.Y) ;
point11.X = point11.X - (point14.X - point11.X) ; point11.Y = point11.Y - (point14.Y - point11.Y) ;
a *= 2;
b *= 2;
x = x - (point14.X - x) ; y = y - (point14.Y - y) ;
*/
for (int i = 0; i < 13; i++)
{
int s = points[i].X;
int h = points[i].Y;
points[i].X = Convert.ToInt32(s*1+h*0);
points[i].Y = Convert.ToInt32(s*0+h*(-1));
}
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 2000, 2000));
myBrush.Dispose();
formGraphics.Dispose();
Graphics g = CreateGraphics();
Rectangle rec = new Rectangle();
PaintEventArgs es = new PaintEventArgs(g, rec);
Form1_Paint(sender, es);
}
private void button9_Click(object sender, EventArgs e)
{
for (int i = 0; i < 13; i++)
{
int s = points[i].X;
int h = points[i].Y;
points[i].X = Convert.ToInt32(s*(-1)+h*0);
points[i].Y = Convert.ToInt32(s*0+h*1);
}
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 2000, 2000));
myBrush.Dispose();
formGraphics.Dispose();
Graphics g = CreateGraphics();
Rectangle rec = new Rectangle();
PaintEventArgs es = new PaintEventArgs(g, rec);
Form1_Paint(sender, es);
}
private void textBox1_TextChanged_2(object sender, EventArgs e)
{
}
private void textBox1_TextChanged_3(object sender, EventArgs e)
{
}
private void ololol_Click(object sender, EventArgs e)
{
}
private void label8_Click(object sender, EventArgs e)
{
}
private void button10_Click(object sender, EventArgs e)
{
for (int i = 0; i < 13; i++)
{
int s = points[i].X;
int h = points[i].Y;
points[i].X = Convert.ToInt32(s*0+h*1);
points[i].Y = Convert.ToInt32(s*1+h*0);
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 2000, 2000));
myBrush.Dispose();
formGraphics.Dispose();
Graphics g = CreateGraphics();
Rectangle rec = new Rectangle();
PaintEventArgs es = new PaintEventArgs(g, rec);
Form1_Paint(sender, es);
}
}
}
/* static class RasterAlgorithm
{
public static void BresenhamCircle(Graphics g, Color clr, int _x, int _y, int radius)
{
int x = 0, y = radius, gap = 0, delta = (2 - 2 * radius);
while (y >= 0)
{
PutPixel(g, clr, _x + x, _y + y, 255);
PutPixel(g, clr, _x + x, _y - y, 255);
PutPixel(g, clr, _x - x, _y - y, 255);
PutPixel(g, clr, _x - x, _y + y, 255);
gap = 2 * (delta + y) - 1;
if (delta < 0 && gap <= 0)
{
x++;
delta += 2 * x + 1;
continue;
}
if (delta > 0 && gap > 0)
{
y--;
delta -= 2 * y + 1;
continue;
}
x++;
delta += 2 * (x - y);
y--;
}
}
//Метод, устанавливающий пиксел на форме с заданными цветом и прозрачностью
private static void PutPixel(Graphics g, Color col, int x, int y, int alpha)
{
g.FillRectangle(new SolidBrush(Color.FromArgb(alpha, col)), x, y, 1, 1);
}
}
*/
}
//double x=1, y=1;
// float fi = 25f;
// for (int n = 0; n <= 2; n++)
// {
// double c;
// c *= point1.X* Math.Cos(fi) -point1.Y* Math.Sin(fi);
// point1.X = c;
///
// y *= polygon[n].X * Math.Sin(fi) + polygon[n] .Y* Math.Cos(fi);
// polygon[n].X = x;
// polygon[n].Y = y |