mixster

mixster

Mar 25th, 2010
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.61 KB | None | 0 0
  1. const
  2.   largeRadius = 200;
  3.   smallRadius = 98;
  4.   stepSize    = 1;
  5.  
  6.   radiusDif   = largeRadius - smallRadius;
  7.  
  8. var
  9.   step, maxStep: Integer;
  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.   l := Trunc(Sqrt(Min(a, b)));
  22.   f := 2;
  23.  
  24.   repeat
  25.     if ((a mod f) = 0) then
  26.       if ((b mod f) = 0) then
  27.       begin
  28.         a := a div f;
  29.         b := b div f;
  30.         Result := Result div f;
  31.         Continue;
  32.       end;
  33.     f := f + 1;
  34.   until (f > l);
  35. end;
  36.  
  37. begin
  38.   step := -stepSize;
  39.   maxStep := Round(GetFactor(largeRadius, smallRadius) * 2 * Pi);
  40.  
  41.   repeat
  42.     step := step + stepSize;
  43.  
  44.     largeTheta := (step / (largeRadius * 1.0));
  45.     smallTheta := (step / (smallRadius * 1.0));
  46.  
  47.     x := (radiusDif * Cos(largeTheta)) + (smallRadius * Cos(smallTheta));
  48.     y := (radiusDif * Sin(largeTheta)) + (smallRadius * Sin(smallTheta));
  49.     graph[Round(y)][Round(x)] := True;
  50.     //Writeln(FloatToStr(x) + '        ' + FloatToStr(y));
  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.   FreeBitmap(bit);
  66. end.
Add Comment
Please, Sign In to add comment