uxebu / bonsai

BonsaiJS is a graphics library and renderer
http://bonsaijs.org
Other
1.96k stars 189 forks source link

Rookie Question: How to use variable in the attr? #229

Closed slmjkdbtl closed 9 years ago

slmjkdbtl commented 9 years ago
var color = "#ef6360";

bonsai.run($("#star"), {
    code: function() {
        new Star(30, 30, 20, 5).attr({
            fillColor: color
    }).addTo(stage);
    }
});

It doesn't work.

iamdustan commented 9 years ago

@Voyga the code inside the code key is stringified and passed to a webworker, therefore not having access to the files scope.

basecode commented 9 years ago

Additional infos are available here: http://docs.bonsaijs.org/overview/Execution.html