var star = document.getElementById("star");
var color = "#ef6360";
bonsai.run(star, {
code: function() {
new Star(30, 30, 20, 5, 0.7).attr({
fillColor: color
}).addTo(stage);
}
});
it doesn't work, but it'll work if I remove the variable and directly use the string, like fillColor:"#ef6360"
. Why?
As far as I know, you cannot access variables inside
code
because its context has limited access to browser as per the documentation here (read the first note).This is what the docs say exactly.
If there is way to access the window scope from inside a web worker, then it is possible. (I do not know if it is possible)
Hope this helps.