Author Topic: TriangleFill for PulsarLua  (Read 2489 times)

Rick3137

  • Guest
TriangleFill for PulsarLua
« on: October 20, 2015, 01:47:51 PM »
  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()




Rick3137

  • Guest
Re: TriangleFill for PulsarLua
« Reply #1 on: October 20, 2015, 09:50:07 PM »
 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()

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: TriangleFill for PulsarLua
« Reply #2 on: October 21, 2015, 07:54:55 AM »
 ;D