virtual-gamepad-lib
Version:
Emulate and display virtual and real gamepads on the web
25 lines (24 loc) • 1.56 kB
TypeScript
/**
* Scales vectors to ≤ 1 unit length where vectors that started with a length greater than max
* are clamped to length 1, and shorter vectors are scaled between 0 - 1 based on their original
* fraction of their length relative to max.
* @param x x component of the vector
* @param y y component of the vector
* @param max the length of the vector to clamp to
* @returns the scaled vector as an object with x and y components.
*/
export declare function NormalizeClampVector(x: number, y: number, max: number): {
x: number;
y: number;
};
/** Sets the transform-origin css property of the passed element to the center of its BBOX (svg) or transform rect (html) as a pixel coordinate.
* This is intened mainly for elements that will not be moved except with the transform css property or svg attribute (relative to its parent).
* If the passed element is moved by another method (margin, top, flex, etc...) you must call this again to update the transform-origin.
* On newer browsers this function can often be replaced with ```transform-box: fill; transform-origin: 50% 50%``` properties on svg elements
* @param element The element to set the transform-origin of.
*/
export declare function CenterTransformOrigin(element: HTMLElement | SVGGraphicsElement): void;
/** Adds a visual shaded box around the bbox or bounding rect of the passed element for debugging
* @param element The element to show the visual bounding box of
*/
export declare function CenterTransformOriginDebug(element: HTMLElement | SVGGraphicsElement): void;