I'm probably missing something very obvious here. I can use p5.js in global mode and use constants for textAlign with no problem, e.g. CENTER.
Here is global mode code where it works fine:
function setup() {
var canvas = createCanvas(720, 400);
canvas.parent('main_canvas');
};
function draw() {
textSize(32);
textAlign(CENTER);
text("word", 50, 50);
};
However when I try using CENTER in instance mode I get:
Uncaught ReferenceError: CENTER is not defined:
Here is instance mode code where it fails:
var s = function (p) {
p.setup = function() {
p.createCanvas(720, 400);
};
p.draw = function() {
p.textSize(32);
p.textAlign(CENTER);
p.text("word", 50, 50);
};
};
var myp5 = new p5(s,'main_canvas');
Any ideas on what I am missing here?
CENTER, so this is by design.