mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-02-18 00:16:41 +01:00
simplify interp and fix math
This commit is contained in:
parent
a4c406c911
commit
648f615560
@ -219,9 +219,6 @@ export function MotionSegment({
|
|||||||
style={{
|
style={{
|
||||||
width: interpolateMotionAudioData(
|
width: interpolateMotionAudioData(
|
||||||
getMotionSegmentValue(segmentTime),
|
getMotionSegmentValue(segmentTime),
|
||||||
0,
|
|
||||||
100,
|
|
||||||
1,
|
|
||||||
maxSegmentWidth,
|
maxSegmentWidth,
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
@ -235,9 +232,6 @@ export function MotionSegment({
|
|||||||
style={{
|
style={{
|
||||||
width: interpolateMotionAudioData(
|
width: interpolateMotionAudioData(
|
||||||
getAudioSegmentValue(segmentTime),
|
getAudioSegmentValue(segmentTime),
|
||||||
-100,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
maxSegmentWidth,
|
maxSegmentWidth,
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
@ -253,10 +247,7 @@ export function MotionSegment({
|
|||||||
onClick={segmentClick}
|
onClick={segmentClick}
|
||||||
style={{
|
style={{
|
||||||
width: interpolateMotionAudioData(
|
width: interpolateMotionAudioData(
|
||||||
getMotionSegmentValue(segmentTime - segmentDuration / 2),
|
getMotionSegmentValue(segmentTime + segmentDuration / 2),
|
||||||
0,
|
|
||||||
100,
|
|
||||||
1,
|
|
||||||
maxSegmentWidth,
|
maxSegmentWidth,
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
@ -269,10 +260,7 @@ export function MotionSegment({
|
|||||||
onClick={segmentClick}
|
onClick={segmentClick}
|
||||||
style={{
|
style={{
|
||||||
width: interpolateMotionAudioData(
|
width: interpolateMotionAudioData(
|
||||||
getAudioSegmentValue(segmentTime - segmentDuration / 2),
|
getAudioSegmentValue(segmentTime + segmentDuration / 2),
|
||||||
-100,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
maxSegmentWidth,
|
maxSegmentWidth,
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
|
@ -26,16 +26,8 @@ export const useMotionSegmentUtils = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
const interpolateMotionAudioData = useCallback(
|
const interpolateMotionAudioData = useCallback(
|
||||||
(
|
(value: number, newMax: number): number => {
|
||||||
value: number,
|
return Math.ceil((Math.abs(value) / 100.0) * newMax) || 1;
|
||||||
oldMin: number,
|
|
||||||
oldMax: number,
|
|
||||||
newMin: number,
|
|
||||||
newMax: number,
|
|
||||||
): number => {
|
|
||||||
return (
|
|
||||||
((value - oldMin) / (oldMax - oldMin)) * (newMax - newMin) + newMin
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user