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

pxcan

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pxcan - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

2

package.json
{
"name": "pxcan",
"version": "0.0.6",
"version": "0.0.7",
"description": "ESM-ready pixel library",

@@ -5,0 +5,0 @@ "keywords": [

@@ -7,7 +7,12 @@ function coords(evt, canvas, zero = false) {

const { offsetX, offsetY } = (canvas.width/canvas.height > canvas.clientWidth/canvas.clientHeight) ?
// canvas aspect ratio wider than screen aspect ratio -> leftovers on top and bottom
{ offsetX: 0, offsetY: (canvas.clientHeight - canvas.height*upscaling)/2 } :
// canvas aspect ratio taller than screen aspect ratio -> leftovers on sides
{ offsetY: 0, offsetX: (canvas.clientWidth - canvas.width*upscaling)/2 };
// derive the screen's position in the canvas element from the object-position css prop
let offsetX = 0;
let offsetY = 0;
const [, xPercent, yPercent] = getComputedStyle(canvas).objectPosition.match(/^(\d+)% (\d+)%$/) || [];
const aspect = canvas.width/canvas.height > canvas.clientWidth/canvas.clientHeight;
if (aspect < 1) {
offsetX = (canvas.clientWidth - canvas.width*upscaling) * (+xPercent/100);
} else if (aspect > 1) {
offsetY = (canvas.clientHeight - canvas.height*upscaling) * (+yPercent/100);
}

@@ -14,0 +19,0 @@ const coords = {

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