Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

canvas-app

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-app - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

demo/main.js

39

index.js

@@ -67,2 +67,7 @@ var getGL = require('webgl-context');

//FPS counter
this.fps = 60;
this._frames = 0;
this._prevTime = this._then;
if (!this._ignoreResize) {

@@ -79,3 +84,3 @@ window.addEventListener("resize", function() {

if (typeof render === "function") {
this.onRender = render;
this.onRender = render.bind(this);
} else {

@@ -90,2 +95,10 @@ //dummy render function

this._frames++;
if (now > this._prevTime + 1000) {
this.fps = Math.round((this._frames * 1000) / (now - this._prevTime));
this._prevTime = now;
this._frames = 0;
}
if (!this.isWebGL) {

@@ -120,2 +133,22 @@ this.context.save();

Object.defineProperty(CanvasApp.prototype, 'retinaEnabled', {
set: function(v) {
this._retina = v;
this._DPR = this._retina ? (window.devicePixelRatio||1) : 1;
this.resize(this.width, this.height);
},
get: function() {
return this._retina;
}
});
CanvasApp.prototype.resetFPS = function() {
this._frames = 0;
this._prevTime = Date.now();
this._then = this._prevTime;
this.fps = 60;
};
CanvasApp.prototype.start = function() {

@@ -128,4 +161,6 @@ if (this.running)

//reset FPS counter
this.resetFPS();
this.running = true;
this._then = Date.now();
this._lastFrame = requestAnimationFrame(this._renderHandler);

@@ -132,0 +167,0 @@ };

3

package.json
{
"name": "canvas-app",
"version": "1.0.0",
"version": "1.1.0",
"description": "sets up a retina-scaled canvas with render loop",

@@ -12,2 +12,3 @@ "main": "index.js",

"devDependencies": {
"domready": "^1.0.5",
"tape": "~2.13.2"

@@ -14,0 +15,0 @@ },

@@ -12,2 +12,3 @@ # canvas-app

- start/stop handling
- current FPS

@@ -20,3 +21,5 @@ Simplest use might look like this:

context.clearRect(0, 0, width, height);
context.fillRect(0, 0, 25, 25);
context.fillRect(20, 50, 25, 25);
context.fillText("FPS: "+this.fps, 20, 20);
}

@@ -23,0 +26,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc