Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以存储fillRect到变量吗?之后使用变量切出一个矩形'c'?除了必须写fillRect两次。
fillRect
'c'
var c = ctx.fillRect(x, y, width, height);
不确定内置功能,但作为替代方案,您可以执行以下操作
var c = function() { ctx.fillRect(x, y, width, height); }
然后调用它两次:
c(); c();