Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1.             while (bActive)
  2.             {
  3.                 xDir += RND.Next(-ResX * Scale, ResY * Scale);
  4.                 yDir += RND.Next(-ResY * Scale, ResY * Scale);
  5.  
  6.                 float distance = (float)Math.Sqrt(xDir * xDir + yDir * yDir);
  7.                 xDir = xDir / distance;
  8.                 yDir = yDir / distance;
  9.  
  10.                 pX += xDir*Scale;
  11.                 pY += yDir*Scale;
  12.  
  13.                 if (pX > ResX-1)
  14.                     pX = ResX-1;
  15.  
  16.                 if (pY > ResY-1)
  17.                     pY = ResY-1;
  18.  
  19.                 if (pY < 0)
  20.                     pY = ResY-1;
  21.  
  22.                 if (pX < 0)
  23.                     pX = ResY-1;
  24.  
  25.                 tBmp.SetPixel((int)(pX), (int)(pY), Color.Blue);
  26.                 Iterations++;
  27.                
  28.                 if (Iterations >= MaxIterations)
  29.                 {
  30.                     bActive = false;
  31.                     pictureBox1.Image = tBmp;
  32.                 }
  33.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement