-
Notifications
You must be signed in to change notification settings - Fork 11
/
CruveEditorFxBg.tsx
63 lines (55 loc) · 1.57 KB
/
CruveEditorFxBg.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { Colors } from '../constants/Colors';
import { FxSection } from '@0b5vr/automaton';
import { Resolution } from '../utils/Resolution';
import { TimeValueRange, dt2dx, t2x } from '../utils/TimeValueRange';
import { WithBypass } from '../../types/WithBypass';
import { WithID } from '../../types/WithID';
import React from 'react';
import styled from 'styled-components';
// == styles =======================================================================================
const Fill = styled.rect`
fill: ${ Colors.fx };
opacity: 0.1;
`;
const Line = styled.line`
stroke: ${ Colors.fx };
stroke-width: 0.0625rem;
stroke-dasharray: 0.25rem;
`;
const Root = styled.g`
pointer-events: none;
`;
// == element ======================================================================================
const CurveEditorFxBg = ( props: {
fx: FxSection & WithBypass & WithID;
range: TimeValueRange;
size: Resolution;
} ): JSX.Element | null => {
const { fx, range, size } = props;
const x = t2x( fx.time, range, size.width );
if ( fx.bypass ) { return null; }
return (
<Root key={ fx.$id }
transform={ `translate(${ x }, 0)` }
>
<Fill
width={ dt2dx( fx.length, range, size.width ) }
height={ size.height }
/>
<Line
x1="0"
y1="0.25rem"
x2="0"
y2={ size.height }
/>
<Line
transform={ `translate(${ dt2dx( fx.length, range, size.width ) }, 0)` }
x1="0"
y1="0.25rem"
x2="0"
y2={ size.height }
/>
</Root>
);
};
export { CurveEditorFxBg };