diff options
Diffstat (limited to 'playgrounds/matrix/matrix.js')
-rw-r--r-- | playgrounds/matrix/matrix.js | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/playgrounds/matrix/matrix.js b/playgrounds/matrix/matrix.js index 33e21d1..fb74717 100644 --- a/playgrounds/matrix/matrix.js +++ b/playgrounds/matrix/matrix.js @@ -1,6 +1,5 @@ - -function print (mat) { - let {a, b, c, d} = mat +function print(mat) { + let { a, b, c, d } = mat console.log(` a: ${a.toFixed(2)} b: ${b.toFixed(2)} @@ -9,14 +8,19 @@ function print (mat) { `) } -function moveit () { - - let {cx: x0, cy: y0} = or.rbox(svg) - let {cx: x1, cy: y1} = b1.rbox(svg) - let {cx: x2, cy: y2} = b2.rbox(svg) +function moveit() { + let { cx: x0, cy: y0 } = or.rbox(svg) + let { cx: x1, cy: y1 } = b1.rbox(svg) + let { cx: x2, cy: y2 } = b2.rbox(svg) let m = new SVG.Matrix( - (x1 - x0) / 50, (y1 - y0) / 50, (x2 - x0) / 50, (y2 - y0) / 50, x0, y0) + (x1 - x0) / 50, + (y1 - y0) / 50, + (x2 - x0) / 50, + (y2 - y0) / 50, + x0, + y0 + ) let com = m.decompose() let g = new SVG.Matrix().compose(com) @@ -24,18 +28,18 @@ function moveit () { target.transform(m) mover.transform(g) - console.log(com); + console.log(com) print(m) print(g) } // Declare the two points let svg = SVG('svg') -var or = SVG("#or").draggable(moveit) -var b1 = SVG("#b1").draggable(moveit) -var b2 = SVG("#b2").draggable(moveit) +var or = SVG('#or').draggable(moveit) +var b1 = SVG('#b1').draggable(moveit) +var b2 = SVG('#b2').draggable(moveit) // Declare the squares -let target = SVG("#true") -let mover = SVG("#guess") -let tester = SVG("#tester") +let target = SVG('#true') +let mover = SVG('#guess') +let tester = SVG('#tester') |