Advertisement
mixster

mixster

Jul 23rd, 2010
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.58 KB | None | 0 0
  1. const
  2.   largeRadius = 600;
  3.   smallRadius = 299;
  4.   stepSize    = 0.1;
  5.  
  6.   radiusDif   = largeRadius - smallRadius;
  7.  
  8. var
  9.   step, maxStep: Extended;
  10.   smallTheta, largeTheta, x, y: Extended;
  11.  
  12.   graph: array [-largeRadius..largeRadius] of array [-largeRadius..largeRadius] of Boolean;
  13.   bit, a, b: Integer;
  14.  
  15. function GetFactor(a, b: Integer): Integer;
  16. var
  17.   f, l: Integer;
  18. begin
  19.   Result := a * b;
  20.  
  21.   f := 2;
  22.  
  23.   repeat
  24.     if ((a mod f) = 0) then
  25.       if ((b mod f) = 0) then
  26.       begin
  27.         a := a div f;
  28.         b := b div f;
  29.         Result := Result div f;
  30.         Continue;
  31.       end;
  32.  
  33.     f := f + 1;
  34.     l := Min(a, b);
  35.   until (f > l);
  36. end;
  37.  
  38. begin
  39.   step := -stepSize;
  40.   maxStep := GetFactor(largeRadius, smallRadius) * 2 * Pi;
  41.  
  42.   repeat
  43.     step := step + stepSize;
  44.  
  45.     largeTheta := (step / (largeRadius * 1.0));
  46.     smallTheta := (step / (smallRadius * 1.0));
  47.  
  48.     x := (radiusDif * Cos(largeTheta)) + (smallRadius * Cos(smallTheta));
  49.     y := (radiusDif * Sin(largeTheta)) + (smallRadius * Sin(smallTheta));
  50.     graph[Round(y)][Round(x)] := True;
  51.   until (step > maxStep);
  52.  
  53.   DisplayDebugImgWindow(largeRadius * 2 + 1, largeRadius * 2 + 1);
  54.  
  55.   bit := CreateBitmap(largeRadius * 2 + 1, largeRadius * 2 + 1);
  56.   FastDrawClear(bit, clWhite);
  57.   DrawBitmapDebugImg(bit);
  58.  
  59.   for a := -largeRadius to largeRadius do
  60.     for b := -largeRadius to largeRadius do
  61.       if (graph[a][b]) then
  62.         FastSetPixel(bit, b + largeRadius, a + largeRadius, clRed);
  63.  
  64.   DrawBitmapDebugImg(bit);
  65.   SaveBitmap(bit, AppPath + 'maow.bmp');
  66.   FreeBitmap(bit);
  67. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement