Reputation: 2285
Why does this work,
var color = Math.sin( time ) * 128;
color = 128;
context.fillStyle = "rgb(" + color + ", " + color + ", " + color + ")";
But this does not?
var color = Math.sin( time ) * 128;
color += 128;
context.fillStyle = "rgb(" + color + ", " + color + ", " + color + ")";
For some reason, the variable stops working once it becomes dynamic.
Upvotes: 0
Views: 84
Reputation: 2285
Figured this out. I'm sending a floating value where canvas is looking for an integer.
It should be Math.floor(Math.sin( time ) * 128);
Upvotes: 1