MCPcopy
hub / github.com/gmattie/Data-Pixels / updateImageTransform

Function updateImageTransform

resources/source/js/application/content.js:445–473  ·  view source on GitHub ↗

* @description Updates the image coordinates and scale transformation. * @param {?number} [x = null] - The amount of pixels to translate the image along the horizontal axis. * @param {?number} [y = null] - The amount of pixels to translate the image along the vertical axis. * @param {?boolean} [s

(x = null, y = null, scale = null, reflectH = null, reflectV = null)

Source from the content-addressed store, hash-verified

443 *
444 */
445function updateImageTransform(x = null, y = null, scale = null, reflectH = null, reflectV = null) {
446
447 M.Transform.X = (x === null) ? M.Transform.X : x;
448 M.Transform.Y = (y === null) ? M.Transform.Y : y;
449
450 M.Transform.Scale = (scale === null) ? M.Transform.Scale : (() => {
451
452 if (typeof scale === C.Type.BOOLEAN) {
453
454 const step = (scale) ? C.Measurement.SCALE_STEP : -(C.Measurement.SCALE_STEP);
455
456 return Math.max(0.01, M.Transform.Scale + step);
457 }
458
459 return scale;
460 })();
461
462 M.Transform.ReflectH = (reflectH === null) ? M.Transform.ReflectH : (reflectH) ? !M.Transform.ReflectH : false;
463 M.Transform.ReflectV = (reflectV === null) ? M.Transform.ReflectV : (reflectV) ? !M.Transform.ReflectV : false;
464
465 M.Image.style.transform = `
466
467 ${C.CSS.TRANSLATE}(${M.Transform.X}${C.CSS.PX}, ${M.Transform.Y}${C.CSS.PX})
468 ${C.CSS.SCALE_Y}(${(M.Transform.ReflectH) ? "-" : "+"}${M.Transform.Scale})
469 ${C.CSS.SCALE_X}(${(M.Transform.ReflectV) ? "-" : "+"}${M.Transform.Scale})
470 `;
471
472 updateImageInfo();
473}
474
475/**
476 * @description Resets the image to the default properties.

Callers 3

setFrameViewMouseEventsFunction · 0.85
frameViewMouseHandlerFunction · 0.85
resetImageTransformFunction · 0.85

Calls 1

updateImageInfoFunction · 0.85

Tested by

no test coverage detected