Why do all canvas examples use ctx?

后端 未结 5 542
长情又很酷
长情又很酷 2020-12-24 11:38

Is this a requirement or a convention? If it\'s a convention what\'s the reason? Ctx doesn\'t seem especially memorable or intuitive.

e.g.

var ctx =          


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-24 12:08

    it's exactly the same if you do

    var context = document.getElementById('canvas').getContext('2d');
    

    or

    var whatever = document.getElementById('canvas').getContext('2d');
    

    I think "ctx" is really explanatory and short enough :)

提交回复
热议问题