@vsreact/core 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/meter.tsx CHANGED
@@ -67,6 +67,9 @@ export interface MeterProps {
67
67
  thickness?: number;
68
68
  /** Horizontal bar instead of the vertical default. */
69
69
  horizontal?: boolean;
70
+ /** Fill from the top (vertical) / right (horizontal) — gain-reduction
71
+ meters. Default false. */
72
+ reverse?: boolean;
70
73
  /** Show the peak-hold line. Default true. */
71
74
  peak?: boolean;
72
75
  holdMs?: number;
@@ -85,6 +88,7 @@ export function Meter({
85
88
  length = 120,
86
89
  thickness = 10,
87
90
  horizontal,
91
+ reverse = false,
88
92
  peak = true,
89
93
  holdMs,
90
94
  decayPerSecond,
@@ -108,19 +112,27 @@ export function Meter({
108
112
  style={{ width: length, height: thickness, backgroundColor: trackColor }}
109
113
  >
110
114
  <View
111
- className="absolute left-0 top-0 bottom-0"
112
- style={{ width: fill, backgroundColor: color }}
115
+ className="absolute top-0 bottom-0"
116
+ style={reverse ? { right: 0, width: fill, backgroundColor: color } : { left: 0, width: fill, backgroundColor: color }}
113
117
  />
114
118
  {hotFill > 0 ? (
115
119
  <View
116
120
  className="absolute top-0 bottom-0"
117
- style={{ left: hot * length, width: hotFill, backgroundColor: hotColor }}
121
+ style={
122
+ reverse
123
+ ? { right: hot * length, width: hotFill, backgroundColor: hotColor }
124
+ : { left: hot * length, width: hotFill, backgroundColor: hotColor }
125
+ }
118
126
  />
119
127
  ) : null}
120
128
  {peak && peakAt > 2 ? (
121
129
  <View
122
130
  className="absolute top-0 bottom-0 w-[2]"
123
- style={{ left: peakAt - 2, backgroundColor: held >= hot ? hotColor : color }}
131
+ style={
132
+ reverse
133
+ ? { right: peakAt - 2, backgroundColor: held >= hot ? hotColor : color }
134
+ : { left: peakAt - 2, backgroundColor: held >= hot ? hotColor : color }
135
+ }
124
136
  />
125
137
  ) : null}
126
138
  </View>
@@ -130,19 +142,27 @@ export function Meter({
130
142
  style={{ width: thickness, height: length, backgroundColor: trackColor }}
131
143
  >
132
144
  <View
133
- className="absolute bottom-0 left-0 right-0"
134
- style={{ height: fill, backgroundColor: color }}
145
+ className="absolute left-0 right-0"
146
+ style={reverse ? { top: 0, height: fill, backgroundColor: color } : { bottom: 0, height: fill, backgroundColor: color }}
135
147
  />
136
148
  {hotFill > 0 ? (
137
149
  <View
138
150
  className="absolute left-0 right-0"
139
- style={{ bottom: hot * length, height: hotFill, backgroundColor: hotColor }}
151
+ style={
152
+ reverse
153
+ ? { top: hot * length, height: hotFill, backgroundColor: hotColor }
154
+ : { bottom: hot * length, height: hotFill, backgroundColor: hotColor }
155
+ }
140
156
  />
141
157
  ) : null}
142
158
  {peak && peakAt > 2 ? (
143
159
  <View
144
160
  className="absolute left-0 right-0 h-[2]"
145
- style={{ bottom: peakAt - 2, backgroundColor: held >= hot ? hotColor : color }}
161
+ style={
162
+ reverse
163
+ ? { top: peakAt - 2, backgroundColor: held >= hot ? hotColor : color }
164
+ : { bottom: peakAt - 2, backgroundColor: held >= hot ? hotColor : color }
165
+ }
146
166
  />
147
167
  ) : null}
148
168
  </View>
@@ -157,3 +177,84 @@ export function Meter({
157
177
  </View>
158
178
  );
159
179
  }
180
+
181
+ export interface RingMeterProps {
182
+ /** Level 0..1. */
183
+ value: number;
184
+ /** Diameter. Default 64. */
185
+ size?: number;
186
+ thickness?: number;
187
+ /** Where the arc turns hot, 0..1. Default 0.85; 1 disables. */
188
+ hotFrom?: number;
189
+ trackColor?: string;
190
+ color?: string;
191
+ hotColor?: string;
192
+ /** Center readout. Default: none. */
193
+ format?: (value: number) => string;
194
+ label?: string;
195
+ }
196
+
197
+ /** A circular level meter on the native arc keys — channel-strip level
198
+ rings, macro amounts, gain-reduction dials. */
199
+ export function RingMeter({
200
+ value,
201
+ size = 64,
202
+ thickness,
203
+ hotFrom = 0.85,
204
+ trackColor = "#FFFFFF14",
205
+ color = "#C6F135",
206
+ hotColor = "#FF4545",
207
+ format,
208
+ label,
209
+ }: RingMeterProps) {
210
+ const level = clamp01(value);
211
+ const hot = clamp01(hotFrom);
212
+ const arcThickness = thickness ?? Math.max(3, size * 0.09);
213
+ const START = -135;
214
+ const SWEEP = 270;
215
+
216
+ const ring = (
217
+ <View className="relative items-center justify-center" style={{ width: size, height: size }}>
218
+ <View
219
+ className="absolute inset-0"
220
+ style={{
221
+ arcTrackColor: trackColor,
222
+ arcColor: color,
223
+ arcStart: START,
224
+ arcEnd: START + SWEEP,
225
+ arcValueStart: START,
226
+ arcValueEnd: START + SWEEP * Math.min(level, hot),
227
+ arcThickness,
228
+ }}
229
+ />
230
+ {level > hot ? (
231
+ <View
232
+ className="absolute inset-0"
233
+ style={{
234
+ arcTrackColor: "#00000000",
235
+ arcColor: hotColor,
236
+ arcStart: START,
237
+ arcEnd: START + SWEEP,
238
+ arcValueStart: START + SWEEP * hot,
239
+ arcValueEnd: START + SWEEP * level,
240
+ arcThickness,
241
+ }}
242
+ />
243
+ ) : null}
244
+ {format !== undefined ? (
245
+ <Text className="text-[11] font-bold" style={{ color: level > hot ? hotColor : color }}>
246
+ {format(level)}
247
+ </Text>
248
+ ) : null}
249
+ </View>
250
+ );
251
+
252
+ if (label === undefined) return ring;
253
+
254
+ return (
255
+ <View className="items-center gap-2">
256
+ {ring}
257
+ <Text className="text-faint text-[10] font-bold tracking-widest">{label}</Text>
258
+ </View>
259
+ );
260
+ }