-
• #2
Yes,
g
is just built-in. I was going to have 'Pixl.getGraphics()' or something, but then I wanted people to be able to connect and start using it immediately without much typing, so I keptg
as that's what pretty much all the graphics examples do anyway.I'll add a section on it to the Pixl reference at http://www.espruino.com/Pixl.js in the next few hours.
-
• #3
TBH - I'd prefer an explicit assignment myself - but understand the thinking. Hopefully no one uses 'g' as a variable name!
-
• #5
We need to remember we are on a micro here... any long name takes up precious jsvars. Length 1-4 still fits in a var, however I'm not sure
gfx
or similar would be any better! -
• #6
well yes, but how much extra (compiled) space does an explicit assignment take?
ie:
g = Pixl.getGraphics();
-
• #7
how much extra (compiled) space does an explicit assignment take?
It's not about the compiled space, it was about allowing people to take it out the box and start using the graphics right away with the minimum amount of boilerplate required.
reserving a single char variable name is a no-no for me... I tried to come up with a solution... but cannot really think of one.
var gfx = g;delete g;
? Or just write your code such that the scoping means you don't overwrite the globalg
.I can add
Pixl.getGraphics()
in a firmware update - or maybeE.getGraphics()
makes more sense so it can be handled on other platforms as well. At least then it's not a big deal to just delete/overwrite the built-ing
if you don't like it.
In most of the demos there is a variable 'g' that refers to the graphics display. In the Pixl, where is that defined? Is it 'built-in' in some way?
see: http://www.espruino.com/Pico+Flappy+BirdÂ+Game