google / codeworld

Educational computer programming environment using Haskell
http://code.world
Apache License 2.0
1.24k stars 197 forks source link

Issues with DrawState #994

Closed sjakobi closed 5 years ago

sjakobi commented 5 years ago

https://github.com/google/codeworld/blob/657bf8d3f9a98002cef11fc3e7bbb2f3e8386efd/codeworld-api/src/CodeWorld/Driver.hs#L291-L293

Issues:

  1. It's not obvious how the affine transformation matrix is represented.
  2. The fields are all lazy, increasing chances of a space leak.
  3. The comment is outdated: We have a Maybe Color instead of a Bool.

So my understanding is that (a, b, c, d, e, f, _mcolor) represents the following matrix: (Linear algebra is not my strongest point though)

a b e
c d f
0 0 1

Can we simply replace the tuple with a more descriptive record with strict fields?

cdsmith commented 5 years ago

Sounds good to me.

cdsmith commented 5 years ago

More details about the trasnformation nmatrix are at https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform