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

@thi.ng/adapt-dpi

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/adapt-dpi - npm Package Compare versions

Comparing version 2.2.27 to 2.2.28

2

CHANGELOG.md
# Change Log
- **Last updated**: 2023-12-09T19:12:03Z
- **Last updated**: 2023-12-11T10:07:09Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -5,0 +5,0 @@

@@ -1,25 +0,14 @@

/**
* Sets the canvas size to given `width` & `height` (given as CSS pixels,
* applied as device pixels) and adjusts canvas' `style` to compensate for HDPI
* devices. Note: For 2D canvases, this will automatically clear any prior
* canvas content. Returns given `dpr` (presumably [and also default] the
* window's devicePixelRatio or 1, if not available).
*
* @param canvas -
* @param width - uncompensated pixel width
* @param height - uncompensated pixel height
* @param dpr - device pixel ratio
*/
export const adaptDPI = (canvas, width, height, dpr = window.devicePixelRatio || 1) => {
if (dpr !== 1) {
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
}
canvas.width = width * dpr;
canvas.height = height * dpr;
return dpr;
const adaptDPI = (canvas, width, height, dpr = window.devicePixelRatio || 1) => {
if (dpr !== 1) {
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
}
canvas.width = width * dpr;
canvas.height = height * dpr;
return dpr;
};
/**
* Returns true if device's DPR > 1 (aka HighDPI)
*/
export const isHighDPI = () => (window.devicePixelRatio || 1) > 1;
const isHighDPI = () => (window.devicePixelRatio || 1) > 1;
export {
adaptDPI,
isHighDPI
};
{
"name": "@thi.ng/adapt-dpi",
"version": "2.2.27",
"version": "2.2.28",
"description": "HDPI canvas adapter / styling utility",

@@ -27,3 +27,5 @@ "type": "module",

"scripts": {
"build": "yarn clean && tsc --declaration",
"build": "yarn build:esbuild && yarn build:decl",
"build:decl": "tsc --declaration --emitDeclarationOnly",
"build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
"clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",

@@ -38,2 +40,3 @@ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",

"@microsoft/api-extractor": "^7.38.3",
"esbuild": "^0.19.8",
"rimraf": "^5.0.5",

@@ -68,3 +71,3 @@ "tools": "^0.0.1",

},
"gitHead": "25f2ac8ff795a432a930119661b364d4d93b59a0\n"
"gitHead": "5e7bafedfc3d53bc131469a28de31dd8e5b4a3ff\n"
}
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