Dynamically calling Canvas Functions

Is there any way to call canvas functions using apply() or a similar method, as to dynamically call canvas methods or to be able to pass an array of arguments?

Im looking for this effect context.fillRect.apply(this,args);

Answers


If I understand you correctly:

var op = "fillRect";    
var args = [
  10, 10, 180, 180  
];
ctx[op].apply(ctx, args);

Example: http://jsfiddle.net/eZwYQ/


Need Your Help

Must an SMTP client provide the MTA a globally resolvable hostname in the HELO?

smtp postfix-mta email-spam

In short: I'm trying to figure out if I should tell a mail administrator of a friend's employer whether their mail configuration should be fixed, or if I should revise my own policy to be more libe...

How I can set a session in codeigniter 3 database?

php mysql codeigniter session codeigniter-3

I'm using the new version(3.0.0). of CodeIgniter and I have a new problem, my sessions doesn't work. I mean, the code in the controller is correct because there are not errors but, when I try to p...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.