Canvas Library
Basic start to the library let me know if you think this is useful and should be turned into an open source Git Hub project.
HTML
<body onload="load()">
<canvas onmousedown="mouseState = 1;" onmouseup="mouseState = 0;" onclick="canvasClick()" id="canv" width="500px" height="500px">Not supported</canvas>
</body>
JavaScript
function load()
{
//Initializing the library below by calling this initializeEngine()
initializeEngine();
//Once the library has been loaded you can use the simple features to create simple buttons and progress bars!
button("Reset",155,0,50,100,function() {progressBars[0].value = 0;});
button("Start",260,0,50,100,function() {if(buttons[1].text == "Start"){buttons[1].text = "Stop";myVar = setInterval(function() {progressBars[0].value += 1;if(progressBars[0].value>=100){clearInterval(myVar);buttons[1].text = "Start";}}, 50)}else{clearInterval(myVar);buttons[1].text = "Start";}});
button("Enable Text",50,55,50,100,function() {if(buttons[2].text == "Enable Text"){progressBars[0].enableTxt = true;buttons[2].text = "Disable Text"}else{progressBars[0].enableTxt = false;buttons[2].text = "Enable Text"}});
button("Square",155,55,50,100,function() {if(buttons[3].text == "Square"){progressBars[0].rounded = true;buttons[3].text = "Rounded"}else{progressBars[0].rounded = false;buttons[3].text = "Square"}});
button("Info",260,55,50,100,function() {alert("Basic canvas library with simple buttons and progress bars should this project be continued?");});
progressBar(100,100,20,10,100,20,false,false);
}
//########################################//
//########################################//
//LIBRARY STUFF DON'T EDIT BELOW THIS LINE//
//########################################//
//########################################//
var canvas;
var ctx;
var buttons = [];
var progressBars = [];
//FPS counter
var fps = 30;
var now;
var then = Date.now();
var interval = 1000/fps;
var delta;
//Mouse position
var mouseX = 0;
var mouseY = 0;
var mouseState = 0;
var myVar;
function button(text,x,y,height,width,func)
{
buttons[buttons.length] = [];
buttons[buttons.length - 1].text = text;
buttons[buttons.length - 1].x = x;
buttons[buttons.length - 1].y = y;
buttons[buttons.length - 1].height = height;
buttons[buttons.length - 1].width = width;
buttons[buttons.length - 1].event...