share/hedgewars/Data/Scripts/Draw.lua
changeset 10604 f2f9928ea2e7
equal deleted inserted replaced
10603:bda5c7caf396 10604:f2f9928ea2e7
       
     1 local PointsBuffer = ''  -- A string to accumulate points in
       
     2 
       
     3 function AddPoint(x, y, width, erase)
       
     4  PointsBuffer = PointsBuffer .. string.char(band(x,0xff00) / 256 , band(x,0xff) , band(y,0xff00) / 256 , band(y,0xff))
       
     5  if width then
       
     6      width = bor(width,0x80)
       
     7      if erase then
       
     8          width = bor(width,0x40)
       
     9      end
       
    10      PointsBuffer = PointsBuffer .. string.char(width)
       
    11  else
       
    12      PointsBuffer = PointsBuffer .. string.char(0)
       
    13  end
       
    14  if #PointsBuffer > 245 then
       
    15      ParseCommand('draw '..PointsBuffer)
       
    16      PointsBuffer = ''
       
    17  end
       
    18 end
       
    19 
       
    20 function FlushPoints()
       
    21  if #PointsBuffer > 0 then
       
    22      ParseCommand('draw '..PointsBuffer)
       
    23      PointsBuffer = ''
       
    24  end
       
    25 end