share/hedgewars/Data/Scripts/Draw.lua
author nemo
Tue, 02 Dec 2014 14:26:16 -0500
changeset 10604 f2f9928ea2e7
permissions -rw-r--r--
Sheepluva thought this was worth adding.

local PointsBuffer = ''  -- A string to accumulate points in

function AddPoint(x, y, width, erase)
 PointsBuffer = PointsBuffer .. string.char(band(x,0xff00) / 256 , band(x,0xff) , band(y,0xff00) / 256 , band(y,0xff))
 if width then
     width = bor(width,0x80)
     if erase then
         width = bor(width,0x40)
     end
     PointsBuffer = PointsBuffer .. string.char(width)
 else
     PointsBuffer = PointsBuffer .. string.char(0)
 end
 if #PointsBuffer > 245 then
     ParseCommand('draw '..PointsBuffer)
     PointsBuffer = ''
 end
end

function FlushPoints()
 if #PointsBuffer > 0 then
     ParseCommand('draw '..PointsBuffer)
     PointsBuffer = ''
 end
end