Coordinate System Updated

1 week ago

PyAngelo News

We have updated the default PyAngelo coordinate system to match the regular cartesian coordinate system taught in maths. What this means is that as you increase the y value, you move up the screen. As you decrease the y value, you move down the screen. The x stays the same in that as x increases you move to the right and as x decreases you move to the left.

The coordinate system can be set by providing a third parameter to the setCanvasSize() function. This function sets the size of the canvas that all drawings are written to. The first parameter specifies the width in pixels and the second the height. The third parameter is optional and specifies the direction of the y-axis. The constant CARTESIAN can be used to specify a y-axis that is used in maths and a constant of JAVASCRIPT can be used to specify the regular javascript y-axis which moves down the screen. If no value is provided as the third parameter, a default of CARTESIAN is used.

If you have some old programs that are now longer working due to this change, you can simply update the call to setCanvasSize(). For example if you previously had:

setCanvasSize(640, 360)

then you can update the call to be:

setCanvasSize(640, 360, JAVASCRIPT)
and this will update your code to work exactly as before the change.

Hopefully this will make it easier for people to learn about the coordinate system. It also means that if you are creating a game and have a y coordinate of zero, your object will essentially be on the floor. I find this is easier to explain to people new to graphics.

Happy coding!

 


No comments yet!

Notify me of updates

Become a free member to post a comment about this blog.