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 = document.getElementById('canvas').getContext('2d');
It is just name for variable. It could be anything. Ctx is just short word for ConTeXt.
It typically stands for "context". Usually this is some structure that gets passed around to functions in a library, used to maintain state (i.e., the context of the function call).
getContext() method returns a drawing context on the canvas, or null if the context identifier is not supported, or the canvas has already been set to a different context mode.
The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a <canvas> element. It is used for drawing shapes, text, images, and other objects.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With