@thi.ng/adapt-dpi
TypeScript icon, indicating that this package has built-in type declarations

2.2.47 • Public • Published

@thi.ng/adapt-dpi

npm version npm downloads Mastodon Follow

[!NOTE] This is one of 192 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.

🚀 Please help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️

[!IMPORTANT] This package has been deprecated and merged into @thi.ng/canvas.

About

HDPI canvas adapter / styling utility.

Attempts to determine display pixel density via window.devicePixelRatio (default 1.0) and resizes canvas accordingly. I.e. If DPR != 1.0, attaches explicit width and height CSS properties to force canvas to given CSS pixel size, and resizes canvas pixel buffer itself based on DPR (e.g. 2x size).

Status

DEPRECATED - superseded by other package(s)

Search or submit any issues for this package

Installation

yarn add @thi.ng/adapt-dpi

ESM import:

import * as ad from "@thi.ng/adapt-dpi";

Browser ESM import:

<script type="module" src="https://esm.run/@thi.ng/adapt-dpi"></script>

JSDelivr documentation

Package sizes (brotli'd, pre-treeshake): ESM: 135 bytes

Dependencies

None

API

Generated API docs

import { adaptDPI, isHighDPI } from "@thi.ng/adapt-dpi";

const canvas = document.createElement("canvas");

adaptDPI(canvas, 640, 480);

if (isHighDPI()) {
    // ...
}

Authors

If this project contributes to an academic publication, please cite it as:

@misc{thing-adapt-dpi,
  title = "@thi.ng/adapt-dpi",
  author = "Karsten Schmidt",
  note = "https://thi.ng/adapt-dpi",
  year = 2015
}

License

© 2015 - 2024 Karsten Schmidt // Apache License 2.0

Package Sidebar

Install

npm i @thi.ng/adapt-dpi

Weekly Downloads

66

Version

2.2.47

License

Apache-2.0

Unpacked Size

20.4 kB

Total Files

6

Last publish

Collaborators

  • thi.ng