mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-12 17:44:01 +01:00
feat(rotation): implement rotation utilities and enhance angle input handling
This commit is contained in:
1 parent
bef12f1d23
commit
7a6cd61286
4 files changed
+170
-51
No files matched your search
@@ -0,0 +1,17 @@
|
||||
export const ROTATION_MIN = -360;
|
||||
export const ROTATION_MAX = 360;
|
||||
export const ROTATION_STEP = 0.1;
|
||||
|
||||
export function clampRotation(value: number): number {
|
||||
return Math.max(ROTATION_MIN, Math.min(ROTATION_MAX, value));
|
||||
}
|
||||
|
||||
export function roundToStep(value: number): number {
|
||||
return Math.round(value * 10) / 10;
|
||||
}
|
||||
|
||||
export function parseAngleInput(raw: string, fallback = 0): number {
|
||||
const parsed = parseFloat(raw);
|
||||
if (!Number.isFinite(parsed)) return fallback;
|
||||
return clampRotation(roundToStep(parsed));
|
||||
}
|
||||
Reference in new issue
Block a user