### Author Topic: TriangleFill for PulsarLua  (Read 678 times)

#### Rick3137

• Full Member
• Posts: 114
##### TriangleFill for PulsarLua
« on: 20. October 2015, 15:47:51 »
Here's an example of a simple Fill function for equilateral triangles that I came up with to use in another program.

function TriangleFill(x1,y1,d)       -- x1,y1 is the bottom left point
d2 = d/2
dx = 1
dy =  math.tan(math.pi/3)
x2 = x1 + d
y2 = y1
x3 = x2 + d
while x1 < x2
do
line( x1,y1,x2,y2)
line( x2,y2,x3,y2)
x1 = x1 + .5
y1 = y1 - dy/2
y2 = y1
x3 = x3 - .5
end
end
------------ START OF PROGRAM ---------------
win = openwindow ("Hexagon",-1,-1,1000,700)
setactivewindow (win)
textsize(2)
backcolor (0,0,0,255)
color (0,0,255,255)
TriangleFill(100,600,200)
drawtext("Press any key to exit ..",0,0)
sync()
key=inkey()
closewindow(win)             -- This ends the program.
closeapplication()

http://rb23.yolasite.com  Ricks Programs
http://rb27.synthasite.com   Sight and Sound

#### Rick3137

• Full Member
• Posts: 114
##### Re: TriangleFill for PulsarLua
« Reply #1 on: 20. October 2015, 23:50:07 »
Silly me, Pulsarlua already has a filltriangle command.

Code: [Select]
` ------------ START OF PROGRAM --------------- win = openwindow ("filltriangle",-1,-1,1000,700)       setactivewindow (win)       textsize(2)       backcolor (0,0,0,255) color (0,0,255,255)         filltriangle(100,600,300,600,300,200)drawtext("Press any key to exit ..",0,0)sync()key=inkey()closewindow(win)             -- This ends the program.closeapplication()`
http://rb23.yolasite.com  Ricks Programs
http://rb27.synthasite.com   Sight and Sound

#### Cybermonkey

• Administrator
• Hero Member
• Posts: 585
##### Re: TriangleFill for PulsarLua
« Reply #2 on: 21. October 2015, 09:54:55 »

Best regards,
Cybermonkey