为什么所有的画布示例都使用ctx? [英] Why do all canvas examples use ctx?

查看:224
本文介绍了为什么所有的画布示例都使用ctx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是要求还是约定?如果它是一个约定的原因是什么? Ctx似乎不是特别难忘或直观。

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

例如

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


推荐答案

这是单词context的缩写。

It is a shorthand for the word "context". That's it.

当然,你可以使用任何你喜欢的名字 - 在这个实例中没有真正的命名约定。

Of course you can use whatever name you like - there is no real naming convention in this instance.

这篇关于为什么所有的画布示例都使用ctx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆