How to use the gl-matrix-vec2.create function in gl-matrix-vec2

To help you get started, we’ve selected a few gl-matrix-vec2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tmpvar / ctx-get-transform / demo.js View on Github external
var mat3 = require('gl-matrix-mat3');
var vec2 = require('gl-matrix-vec2');
var mouse = vec2.create();
var scale = 1;

var v2scratch = vec2.create();
var m3scratch = mat3.create();

var ctx = require('fc')(function() {
  ctx.fillStyle = "red";
  ctx.clear();
  ctx.save();
    ctx.translate(window.innerWidth/2, window.innerHeight/2);
    ctx.scale(scale, scale);

    // compute where the mouse is in the scene
    var mat = ctx.getTransform();
    mat3.invert(m3scratch, mat)
    vec2.transformMat3(v2scratch, mouse, m3scratch);
github tmpvar / ctx-get-transform / demo.js View on Github external
var mat3 = require('gl-matrix-mat3');
var vec2 = require('gl-matrix-vec2');
var mouse = vec2.create();
var scale = 1;

var v2scratch = vec2.create();
var m3scratch = mat3.create();

var ctx = require('fc')(function() {
  ctx.fillStyle = "red";
  ctx.clear();
  ctx.save();
    ctx.translate(window.innerWidth/2, window.innerHeight/2);
    ctx.scale(scale, scale);

    // compute where the mouse is in the scene
    var mat = ctx.getTransform();
    mat3.invert(m3scratch, mat)
    vec2.transformMat3(v2scratch, mouse, m3scratch);

    // draw the mouse!
    ctx.fillRect(v2scratch[0] - 5, v2scratch[1] - 5, 10, 10);

gl-matrix-vec2

Standalone Vector2 component of gl-matrix

MIT
Latest version published 10 years ago

Package Health Score

63 / 100
Full package analysis

Popular gl-matrix-vec2 functions

Similar packages