INNER CODE UNIT · JavaScript

getCanvasRect

NeoAxis/NeoAxisEngine · Project/Sources/NeoAxis.Player.Web/wwwroot/main.js:272

		const getCanvasRect = () =>
		{
			if (cachedRect === null)
				cachedRect = canvas.getBoundingClientRect();
			return cachedRect;
		}

		const measureDevicePixelSize = () =>
		{
			const devicePixelRatio = window.devicePixelRatio || 1.0;
			const rect = getCanvasRect();

			const width = Math.round(rect.right * devicePixelRatio) - Math.round(rect.left * devicePixelRatio);
			const height = Math.round(rect.bottom * devicePixelRatio) - Math.round(rect.top * devicePixelRatio);

			return { width: Math.max(1, width), height: Math.max(1, height) };
		}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…