2D graphic - Drawing a grid

  • Drawing a grid
    • cartesian
      rectangular grid


      Code for pf8bit color bitmap ( without mapping) is here :
      for iY:=0 to bitmap.Height-1 do
          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
              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:
        if (angle mod 45 = 0) then Pointer[iX]:=16;
      • good version

      • And here is improved version ( without edge detection):
        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