rohan_vg
rohan_vg

Reputation: 1129

Raphaeljs javascript error

I want to draw a rectangle using raphael.js inside a function. What is wrong with my code?

JsFiddle Code

window.onload = function(){
    var paper = Raphael(0,0,100,200);

    var x = 0;
    var y = 0;
    var a = 10;
    var b = 20;

    function drawRect(x,y,a,b){            
        paper.rect(x,y,a,b);
    }        
}​

Upvotes: 0

Views: 204

Answers (1)

Sean Vaughn
Sean Vaughn

Reputation: 3932

window.onload = function(){
    var paper = Raphael(0,0,100,200);

    var x = 0;
    var y = 0;
    var a = 10;
    var b = 20;

    function drawRect(x,y,a,b){            
        paper.rect(x,y,a,b);
    }

    drawRect(x,y,a,b);  //Call the function that you just defined!!
}​

Upvotes: 2

Related Questions