I am stuck on a question because I am not fully sure how the matrix stack works in this case.
If someone can give me step by step process that indicates what happens in this example here:
The answer is given with the question.
I am stuck on a question because I am not fully sure how the
Share
Let us refer to the balls in the correct answer as such (the number is also the drawing order):
We starts from (0, 0) and translate to (2, 0). And we draw the ball 1. Nothing fancy here.
We save the current transformation matrix.
Then we translate by vector (2, 2) from (2, 0), so we end up at (4, 2). And we draw the ball 2. Also not tricky.
The we pop the matrix. It means that it discards all transformation up until the last push. So we end up back to (2, 0), which is where we push the transformation matrix earlier.
We translate by vector (-2, 0) from (2, 0), so we end up at (0, 0), and we draw ball 3.
Then we translate by vector (0, 2) from (0, 0), so we end up at (0, 2), and we draw ball 4.