1

Why on earth would you create an entire new HTMLImageElement in the javascript file just to get the width and height of an image and never render it to the DOM. FFS use MS Paint, 3D Paint or ANY OTHER IMAGE EDITING SOFTWARE to get the size.

Seriously you over engineered the shit out of the easiest const you'll ever write in JavaScript.

And for the record, the width and height of the image used are only used in formulas which produce the actual width and height of the mock buttons that get drawn onto the canvas element. And don't worry, the click event handler for these mock buttons is actually the click event handler for the canvas...which checks the coordinates of where the click was made on the canvas. And if the click is over where the button is drawn in, congrats you clicked the button.

Comments
Add Comment