HTML Canvas: Should my app x, y values be global?
Posted
by
Joe
on Programmers
See other posts from Programmers
or by Joe
Published on 2013-06-28T15:39:51Z
Indexed on
2013/06/28
16:29 UTC
Read the original article
Hit count: 300
I have a large file of functions. Each of these functions is responsible for drawing a particular part of the application. My app has x and y parameters that I use in the setup function to move the whole app around in order to try different placements. So, naturally, I need to use these x and y values to anchor each function's component rendering so that everything moves in unison if the global x,y values ever change.
My question is, is it bad practice/architecture to have these x,y values in the global namespace and having the each function directly access them like so?
function renderFace() {
var x = App.x;
var y = App.y;
// drawing here
}
is there a better way i'm missing?
© Programmers or respective owner