MCPcopy Index your code
hub / github.com/microsoft/SandDance / scalePixels

Function scalePixels

docs/app/js/sanddance-app.js:59425–59443  ·  view source on GitHub ↗
(pixel, ratio, width, height, yInvert)

Source from the content-addressed store, hash-verified

59423 return useDevicePixels ? windowRatio : 1;
59424}
59425function scalePixels(pixel, ratio, width, height, yInvert) {
59426 var x = scaleX(pixel[0], ratio, width);
59427 var y = scaleY(pixel[1], ratio, height, yInvert);
59428 var t = scaleX(pixel[0] + 1, ratio, width);
59429 var xHigh = t === width - 1 ? t : t - 1;
59430 t = scaleY(pixel[1] + 1, ratio, height, yInvert);
59431 var yHigh;
59432 if (yInvert) {
59433 t = t === 0 ? t : t + 1;
59434 yHigh = y;
59435 y = t;
59436 } else yHigh = t === height - 1 ? t : t - 1;
59437 return {
59438 x: x,
59439 y: y,
59440 width: Math.max(xHigh - x + 1, 1),
59441 height: Math.max(yHigh - y + 1, 1)
59442 };
59443}
59444function scaleX(x, ratio, width) {
59445 var r = Math.min(Math.round(x * ratio), width - 1);
59446 return r;

Callers 1

cssToDevicePixelsFunction · 0.70

Calls 3

scaleXFunction · 0.70
scaleYFunction · 0.70
maxMethod · 0.45

Tested by

no test coverage detected