How to use the fancy-canvas/coordinate-space.bindToDevicePixelRatio function in fancy-canvas

To help you get started, we’ve selected a few fancy-canvas 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 tradingview / lightweight-charts / src / gui / canvas-utils.ts View on Github external
export function createBoundCanvas(parentElement: HTMLElement, size: Size): CanvasCoordinateSpaceBinding {
	const doc = ensureNotNull(parentElement.ownerDocument);
	const canvas = createCanvas(doc);
	parentElement.appendChild(canvas);

	const binding = bindToDevicePixelRatio(canvas);
	binding.resizeCanvas({
		width: size.w,
		height: size.h,
	});
	return binding;
}

fancy-canvas

Functionality on top of HTML canvas element, including support for HiDPI and pixel-perfect rendering

MIT
Latest version published 2 years ago

Package Health Score

51 / 100
Full package analysis