tri - winnichenko/BLOB-87 GitHub Wiki
tri
tri x1 y1 x2 y2 x3 y3 color
Parameters
- x1 : the x coordinate of the first triangle corner
- y1 : the y coordinate of the first triangle corner
- x2 : the x coordinate of the second triangle corner
- y2 : the y coordinate of the second triangle corner
- x3 : the x coordinate of the third triangle corner
- y3 : the y coordinate of the third triangle corner
- color: the index of the desired color in the current palette
Description
This function draws a triangle filled with color, using the supplied vertices.
Example
-- title: triangle demo
-- author: Filippo
-- desc: wiki demo for tri
-- script: lua
-- input: gamepad
-- pal: ARNE16
function Pir(x,y,w,h,cx,cy)
tri(x,y,w/2+cx,h/2+cy,x+w,y,1)
tri(x+w,y,w/2+cx,h/2+cy,x+w,y+h,2)
tri(x,y,w/2+cx,h/2+cy,x,y+h,8)
tri(x,y+h,w/2+cx,h/2+cy,x+w,y+h,15)
end
cls()
function TIC()
for x=0,240,28 do
for y=0,136,28 do
cx=12*math.sin(time()/30000*(x+y+1))
cy=12*math.cos(time()/30000*(x+y+1))
Pir(x,y,25,25,x+cx,y+cy)
end
end
end