private void Logic() { // Point p2 = new Point(Points[Points.Count - 4], Points[Points.Count - 3]); // Point p1 = new Point(Points[Points.Count - 2], Points[Points.Count - 1]); var p2 = Points[Points.Count - 2]; var p1 = Points[Points.Count - 1]; Drawing.LineBresenham(p2, p1, Color.Black); drawBox.Image = Drawing.Canvas; }
private void DrawLines() { var p1 = Points[1]; var p2 = Points.TakeAt(0); Drawing.LineBresenham(p1, p2, CurrentColor); }
private void Logic() { var p1 = Points[1]; var p2 = Points.TakeAt(0); Drawing.LineBresenham(p1, p2, Color.Black); drawBox.Image = Drawing.Canvas; }
void DrawBoxClick(object sender, MouseEventArgs @event) { MouseClicks++; if (MouseClicks % 2 == 1) { A.X = @event.Location.X; A.Y = @event.Location.Y; using (var gr = Graphics.FromImage(BobRoss.Canvas)) { gr.DrawRectangle(new Pen(Color.Gray, 1), A.X, A.Y, 1, 1); } if (radioButton3.Checked && textBoxA.Text != string.Empty) { BobRoss.Circle(A, int.Parse(textBoxA.Text)); MouseClicks = 0; } else if (radioButton4.Checked && textBoxA.Text != string.Empty && textBoxB.Text != string.Empty) { BobRoss.NewEllipse(A, int.Parse(textBoxA.Text), int.Parse(textBoxB.Text)); MouseClicks = 0; } } if (MouseClicks % 2 == 0) { B.X = @event.Location.X; B.Y = @event.Location.Y; using (var gr = Graphics.FromImage(BobRoss.Canvas)) { gr.DrawRectangle(new Pen(Color.Gray, 1), B.X, B.Y, 1, 1); } if (radioButton1.Checked) { BobRoss.LineDDA(A, B); } else if (radioButton2.Checked) { BobRoss.LineBresenham(A, B); } } drawBox.Image = BobRoss.Canvas; }
private void Form1_KeyDown(object sender, KeyEventArgs e) { int centY = Center.Y; int centX = Center.X; int angle = 0, distance = 0; if (e.KeyCode == Keys.Q) { angle = 360; distance = -1; } else if (e.KeyCode == Keys.E) { angle = 361; distance = 1; } else { return; } if ((X.Count >= 3) && (Y.Count >= 3)) { Drawing.LineBresenham( new Point(X[X.Count - 1], Y[Y.Count - 1]), new Point(X[0], Y[0]), Color.Black); while (true) { for (int i = 0; i < X.Count; i++) { X_[i] = (int)(centX + ((X[i] - centX) * Math.Cos(angle * Math.PI / 180) - (Y[i] - centY) * Math.Sin(angle * Math.PI / 180))); Y_[i] = (int)(centY + ((X[i] - centX) * Math.Sin(angle * Math.PI / 180) + (Y[i] - centY) * Math.Cos(angle * Math.PI / 180))); } for (int i = 0; i < X.Count - 1; i++) { Drawing.LineBresenham( new Point(X_[i], Y_[i]), new Point(X_[i + 1], Y_[i + 1]), Color.Black); } Drawing.LineBresenham( new Point(X_[X_.Count - 1], Y_[Y_.Count - 1]), new Point(X_[0], Y_[0]), Color.Black); angle += distance; label1.Text = $"Degrees: {angle}"; Thread.Sleep(50); drawBox.Refresh(); if (angle % 360 == 0) { return; } else { drawBox.Image = Drawing.Clear(); } } } }