123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>JSDoc: Source: Viewport.js</title>
- <script src="scripts/prettify/prettify.js"> </script>
- <script src="scripts/prettify/lang-css.js"> </script>
- <!--[if lt IE 9]>
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
- <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
- <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
- </head>
- <body>
- <div id="main">
- <h1 class="page-title">Source: Viewport.js</h1>
-
-
- <section>
- <article>
- <pre class="prettyprint source linenums"><code>"use strict";
- import {Vector2} from "./math/Vector2.js";
- import {Matrix} from "./math/Matrix.js";
- import {UUID} from "./math/UUID.js";
- import {Pointer} from "./input/Pointer.js";
- /**
- * Used to indicate how the user views the content inside of the canvas.
- *
- * @class
- */
- function Viewport()
- {
- /**
- * UUID of the object.
- */
- this.uuid = UUID.generate();
- /**
- * Position of the object.
- */
- this.position = new Vector2(0, 0);
- /**
- * Scale of the object.
- */
- this.scale = 1.0
- /**
- * Rotation of the object relative to its center.
- */
- this.rotation = 0.0;
- /**
- * Local transformation matrix applied to the object.
- */
- this.matrix = new Matrix();
- /**
- * Inverse of the local transformation matrix.
- */
- this.inverseMatrix = new Matrix();
- /**
- * If true the matrix is updated before rendering the object.
- */
- this.matrixNeedsUpdate = true;
- /**
- * Flag to indicate if the viewport should move when scalling.
- *
- * For some application its easier to focus the target if the viewport moves to the pointer location while scalling.
- */
- this.moveOnScale = true;
- /**
- * Value of the initial point of rotation if the viewport is being rotated.
- *
- * Is set to null when the viewport is not being rotated.
- */
- this.rotationPoint = null;
- }
- /**
- * Calculate and update the viewport transformation matrix.
- *
- * Also updates the inverse matrix of the viewport.
- */
- Viewport.prototype.updateMatrix = function()
- {
- if(this.matrixNeedsUpdate)
- {
- this.matrix.compose(this.position.x, this.position.y, this.scale, this.scale, 0, 0, this.rotation);
- this.inverseMatrix = this.matrix.getInverse();
- //this.matrixNeedsUpdate = false;
- }
- };
- /**
- * Center the viewport relative to a object.
- *
- * The position of the object is used a central point, this method does not consider "box" attributes or other strucures in the object.
- *
- * @param {Object2D} object Object to be centered on the viewport.
- * @param {DOM} canvas Canvas element where the image is drawn.
- */
- Viewport.prototype.centerObject = function(object, canvas)
- {
- var position = object.globalMatrix.transformPoint(new Vector2());
- position.multiplyScalar(-this.scale);
- position.x += canvas.width / 2;
- position.y += canvas.height / 2;
- this.position.copy(position);
- };
- export {Viewport};
- </code></pre>
- </article>
- </section>
- </div>
- <nav>
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BezierCurve.html">BezierCurve</a></li><li><a href="Box.html">Box</a></li><li><a href="Box2.html">Box2</a></li><li><a href="BoxMask.html">BoxMask</a></li><li><a href="Circle.html">Circle</a></li><li><a href="DOM.html">DOM</a></li><li><a href="EventManager.html">EventManager</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Helpers.html">Helpers</a></li><li><a href="Image.html">Image</a></li><li><a href="Key.html">Key</a></li><li><a href="Line.html">Line</a></li><li><a href="Mask.html">Mask</a></li><li><a href="Matrix.html">Matrix</a></li><li><a href="Object2D.html">Object2D</a></li><li><a href="Pattern.html">Pattern</a></li><li><a href="Pointer.html">Pointer</a></li><li><a href="Renderer.html">Renderer</a></li><li><a href="Text.html">Text</a></li><li><a href="UUID.html">UUID</a></li><li><a href="Vector2.html">Vector2</a></li><li><a href="Viewport.html">Viewport</a></li><li><a href="ViewportControls.html">ViewportControls</a></li></ul>
- </nav>
- <br class="clear">
- <footer>
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Thu Jun 13 2019 09:46:06 GMT+0100 (Western European Summer Time)
- </footer>
- <script> prettyPrint(); </script>
- <script src="scripts/linenumber.js"> </script>
- </body>
- </html>
|