FANDOM


New in PICO-8 0.2.0.

tline( x0, y0, x1, y1, mx, my, [mdx,] [mdy] )
Draws a textured line between two points, sampling the map for texture data.
x0
The x coordinate of the start of the line.

y0
The y coordinate of the start of the line.

x1
The x coordinate of the end of the line.

y1
The y coordinate of the end of the line.

mx
The x coordinate to begin sampling the map, expressed in (fractional) map tiles.

my
The y coordinate to begin sampling the map, expressed in (fractional) map tiles.

mdx
The amount to add to mx after each pixel is drawn, expressed in (fractional) map tiles. Default is 1/8 (move right one map pixel).

mdy
The amount to add to mx after each pixel is drawn, expressed in (fractional) map tiles. Default is 0 (a horizontal line).

The tline() function draws a line while sampling colors from the map to provide a texture for the line. The mx and my parameters are similar to u,v coordinates used in 3D texture mapping, with the exception that they are expressed in units of map tiles. For example, a coordinate of 4.5,10 would sample from the pixel at 4.5*8,10*8 = 36,80 in the map.

The mdx and mdy parameters are effectively the slope of the line being sampled in the map. They can be fractional, they can be negative, and they can be 0. If both are 0, the whole line will sample from the same pixel on the map.

Examples Edit

-- draw 20 textured lines in random locations, 
-- sampling from the first pixel row of the map
for x=1,20 do
  tline(rnd(128), rnd(128), rnd(128), rnd(128))
end
 
-- draw 20 textured lines in random locations, 
-- sampling from the tenth pixel column of the map
for x=1,20 do
  tline(rnd(128), rnd(128), rnd(128), rnd(128), 10/8, 0, 0, 1/8)
end

See also Edit

Community content is available under CC-BY-SA unless otherwise noted.