2D graphic - Drawing a grid




  • Drawing a grid
    • cartesian
      rectangular grid

      CheckBoard

      Code for pf8bit color bitmap ( without mapping) is here :
      for iY:=0 to bitmap.Height-1 do
        begin
          Pointer := Bitmap.ScanLine[iY];
          if not Odd(trunc(iY div 10)) then bY:=true
            else bY:=false;
          for iX:=0 to bitmap.Width-1 do
            begin
              if Odd(trunc(iX div 10)) then bX:=true
                else bX:=false;
              if bX=bY then Pointer[iX]:=0 //white
                else Pointer[iX]:=19; //black
            end; // for iX
         end; // for iY
    • polar
      • bad version
        Here You see fat lines due to round function.
        See the code:
        angle:=round(RadToDeg(pi+ArcTan2(iy-srodek.Y,srodek.X-ix)));
        if (angle mod 45 = 0) then Pointer[iX]:=16;
      • good version

      • And here is improved version ( without edge detection):
        angle:=round(10*RadToDeg(pi+ArcTan2(iy-srodek.Y,srodek.X-ix)));
        if (angle mod (10*45) = 0) then Pointer[iX]:=16;
      • checkboard in polar coordinates


    Main Page



    Feel free to e-mail me!

    Author: Adam Majewski adammaj1-at-o2-dot-pl

    About

    http://republika.pl/fraktal/