--------------------------------------------------- 
-- FBA Tutorials
--
-- Tutorial / 14 / Manual elementar drawing
--
--------------------------------------------------- 
--
-- This sample shows how to use elementar draw functions to draw
-- simple geometric shapes
--
--------------------------------------------------- 




function onmainloop()

        
        clear(0,0,0)
        

        -- draw some random shapes all around the screen!
        for c=0, 5 do 
                -- circles
                circle(math.random(16, screenwidth()-16), math.random(16, screenheight()-16), math.random(4, 15),
                        math.random(0,255), math.random(0,255), math.random(0,255))
                fillcircle(math.random(16, screenwidth()-16), math.random(16, screenheight()-16), math.random(4, 15),
                        math.random(0,255), math.random(0,255), math.random(0,255))

                -- rectangles
                x=math.random(0, screenwidth()-16)
                y=math.random(0, screenheight()-16)
                rect(x, y, x+math.random(8, 15), y+math.random(8,15), math.random(0,255), math.random(0,255), math.random(0,255))

                x=math.random(0, screenwidth()-16)
                y=math.random(0, screenheight()-16)
                fillrect(x, y, x+math.random(8, 15), y+math.random(8,15), math.random(0,255), math.random(0,255), math.random(0,255))
        
                -- lines
                x=math.random(16, screenwidth()-16)
                y=math.random(16, screenheight()-16)
                line(x, y, x+math.random(-15, 15), y+math.random(-15,15), math.random(0,255), math.random(0,255), math.random(0,255))

                -- points
                point(math.random(0, screenwidth()), math.random(0, screenheight()), math.random(0,255), math.random(0,255), math.random(0,255))
        
                -- poly
                -- (use fillpoly if you want a filled polygon)
                poly(math.random(0,255), math.random(0,255), math.random(0,255),
                        math.random(0, screenwidth()), math.random(0, screenheight()),
                        math.random(0, screenwidth()), math.random(0, screenheight()),
                        math.random(0, screenwidth()), math.random(0, screenheight()),
                        math.random(0, screenwidth()), math.random(0, screenheight()),
                        math.random(0, screenwidth()), math.random(0, screenheight()),
                        math.random(0, screenwidth()), math.random(0, screenheight())
                        )

        end
        
        if (mousedown() > 0) then
                quit()
        end

end
