ericdrowell / KineticJS

KineticJS is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://www.kineticjs.com
3.98k stars 752 forks source link

context.fillStyle & context.fill() not working in Kinetic.Shape #1011

Closed SLyHuy closed 10 years ago

SLyHuy commented 10 years ago

The Rect have back color, not red color in v5.1.0

new Kinetic.Shape({
    drawFunc: function(context) {
        var i = 0;
        var j = 0;

        context.rect(0 + i * 10 * 5, 0 + j * 10 * 5, 10 * 5, 10 * 5);
        context.fillStyle = 'red';
        context.fill();

    },
    x: 0,
    y: 0
});

Can you have any idea to quick fix this issue?

lavrton commented 10 years ago

context argument is not native canvas context. It is KineticJS wrapper. Use: context.setAttr('fillStyle', 'red');

SLyHuy commented 10 years ago

Thanks, Lavrton.