mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Prefer arrow functions (#2344)
This commit is contained in:
parent
e05acd6fd9
commit
a20f3240fd
19 changed files with 304 additions and 336 deletions
|
@ -6,33 +6,36 @@ import * as GADirection from "./gadirections";
|
|||
* TODO: docs
|
||||
*/
|
||||
|
||||
export function rotation(pivot: Point, angle: number): Transform {
|
||||
return GA.add(GA.mul(pivot, Math.sin(angle / 2)), Math.cos(angle / 2));
|
||||
}
|
||||
export const rotation = (pivot: Point, angle: number): Transform =>
|
||||
GA.add(GA.mul(pivot, Math.sin(angle / 2)), Math.cos(angle / 2));
|
||||
|
||||
export function translation(direction: Direction): Transform {
|
||||
return [1, 0, 0, 0, -(0.5 * direction[5]), 0.5 * direction[4], 0, 0];
|
||||
}
|
||||
export const translation = (direction: Direction): Transform => [
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
-(0.5 * direction[5]),
|
||||
0.5 * direction[4],
|
||||
0,
|
||||
0,
|
||||
];
|
||||
|
||||
export function translationOrthogonal(
|
||||
export const translationOrthogonal = (
|
||||
direction: Direction,
|
||||
distance: number,
|
||||
): Transform {
|
||||
): Transform => {
|
||||
const scale = 0.5 * distance;
|
||||
return [1, 0, 0, 0, scale * direction[4], scale * direction[5], 0, 0];
|
||||
}
|
||||
};
|
||||
|
||||
export function translationAlong(line: Line, distance: number): Transform {
|
||||
return GA.add(GA.mul(GADirection.orthogonalToLine(line), 0.5 * distance), 1);
|
||||
}
|
||||
export const translationAlong = (line: Line, distance: number): Transform =>
|
||||
GA.add(GA.mul(GADirection.orthogonalToLine(line), 0.5 * distance), 1);
|
||||
|
||||
export function compose(motor1: Transform, motor2: Transform): Transform {
|
||||
return GA.mul(motor2, motor1);
|
||||
}
|
||||
export const compose = (motor1: Transform, motor2: Transform): Transform =>
|
||||
GA.mul(motor2, motor1);
|
||||
|
||||
export function apply(
|
||||
export const apply = (
|
||||
motor: Transform,
|
||||
nvector: Point | Direction | Line,
|
||||
): Point | Direction | Line {
|
||||
return GA.normalized(GA.mul(GA.mul(motor, nvector), GA.reverse(motor)));
|
||||
}
|
||||
): Point | Direction | Line =>
|
||||
GA.normalized(GA.mul(GA.mul(motor, nvector), GA.reverse(motor)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue