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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10604
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     1
local PointsBuffer = ''  -- A string to accumulate points in
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     2
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     3
function AddPoint(x, y, width, erase)
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     4
 PointsBuffer = PointsBuffer .. string.char(band(x,0xff00) / 256 , band(x,0xff) , band(y,0xff00) / 256 , band(y,0xff))
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     5
 if width then
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     6
     width = bor(width,0x80)
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     7
     if erase then
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     8
         width = bor(width,0x40)
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     9
     end
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    10
     PointsBuffer = PointsBuffer .. string.char(width)
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    11
 else
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    12
     PointsBuffer = PointsBuffer .. string.char(0)
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    13
 end
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    14
 if #PointsBuffer > 245 then
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    15
     ParseCommand('draw '..PointsBuffer)
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    16
     PointsBuffer = ''
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    17
 end
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    18
end
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    19
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    20
function FlushPoints()
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    21
 if #PointsBuffer > 0 then
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    22
     ParseCommand('draw '..PointsBuffer)
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    23
     PointsBuffer = ''
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    24
 end
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    25
end