Advertisement
Nikitaantiov

Untitled

Mar 26th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp15
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20.  
  21. private void Form1_Paint(object sender, PaintEventArgs e)
  22. {
  23. Pen pen = new Pen(Color.Red, 2);
  24. Graphics graphics = CreateGraphics();
  25.  
  26. Random r = new Random();
  27. int color = r.Next(7);
  28. int color = 0;
  29. if (color < 3)
  30. {
  31. color = Color.Red;
  32. }
  33.  
  34. for (int i = 0; i <100 ; i++)
  35. {
  36. graphics.Clear(Color.White);
  37. int x = r.Next(200);
  38. int y = r.Next(200);
  39. Quad(graphics, pen, x, y);
  40. System.Threading.Thread.Sleep(1000);
  41.  
  42. }
  43.  
  44.  
  45.  
  46. }
  47. private void Quad(Graphics graphics, Pen pen,int x=200,int y=200)
  48. {
  49. graphics.DrawRectangle(pen, x-10, y-10, x+10, y+10);
  50.  
  51.  
  52. }
  53. }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement