feat: implement Figlet, Pastel, and Unit tools with a unified layout
- Add Figlet text converter with font selection and history - Add Pastel color palette generator and manipulation suite - Add comprehensive Units converter with category-based logic - Introduce AppShell with Sidebar and Header for navigation - Modernize theme system with CSS variables and new animations - Update project configuration and dependencies
This commit is contained in:
117
lib/units/tempo.ts
Normal file
117
lib/units/tempo.ts
Normal file
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* Custom tempo/BPM measure for convert-units
|
||||
*
|
||||
* Converts between BPM and note durations in milliseconds
|
||||
* Uses a reciprocal relationship where BPM (beats per minute) is the base unit
|
||||
*
|
||||
* Formula: milliseconds per beat = 60000 / BPM
|
||||
*
|
||||
* The to_anchor value represents the conversion factor:
|
||||
* - For BPM → time units: multiply by to_anchor to get milliseconds
|
||||
* - For time units → BPM: divide by to_anchor to get BPM
|
||||
*/
|
||||
|
||||
export const tempoMeasure = {
|
||||
tempo: {
|
||||
systems: {
|
||||
metric: {
|
||||
// BPM as the base unit (1 BPM = 60000 ms per beat)
|
||||
'BPM': {
|
||||
name: { singular: 'Beat per Minute', plural: 'Beats per Minute' },
|
||||
to_anchor: 1
|
||||
},
|
||||
|
||||
// Whole note (4 beats) = 240000 / BPM
|
||||
'whole': {
|
||||
name: { singular: 'Whole Note (ms)', plural: 'Whole Note (ms)' },
|
||||
to_anchor: 240000
|
||||
},
|
||||
|
||||
// Half note (2 beats) = 120000 / BPM
|
||||
'half': {
|
||||
name: { singular: 'Half Note (ms)', plural: 'Half Note (ms)' },
|
||||
to_anchor: 120000
|
||||
},
|
||||
|
||||
// Quarter note (1 beat) = 60000 / BPM
|
||||
'quarter': {
|
||||
name: { singular: 'Quarter Note (ms)', plural: 'Quarter Note (ms)' },
|
||||
to_anchor: 60000
|
||||
},
|
||||
|
||||
// Eighth note (0.5 beats) = 30000 / BPM
|
||||
'eighth': {
|
||||
name: { singular: 'Eighth Note (ms)', plural: 'Eighth Note (ms)' },
|
||||
to_anchor: 30000
|
||||
},
|
||||
|
||||
// Sixteenth note (0.25 beats) = 15000 / BPM
|
||||
'sixteenth': {
|
||||
name: { singular: 'Sixteenth Note (ms)', plural: 'Sixteenth Note (ms)' },
|
||||
to_anchor: 15000
|
||||
},
|
||||
|
||||
// Thirty-second note (0.125 beats) = 7500 / BPM
|
||||
'thirty-second': {
|
||||
name: { singular: 'Thirty-Second Note (ms)', plural: 'Thirty-Second Note (ms)' },
|
||||
to_anchor: 7500
|
||||
},
|
||||
|
||||
// Dotted notes (1.5x the duration)
|
||||
'dotted-half': {
|
||||
name: { singular: 'Dotted Half Note (ms)', plural: 'Dotted Half Note (ms)' },
|
||||
to_anchor: 180000 // 3 beats
|
||||
},
|
||||
|
||||
'dotted-quarter': {
|
||||
name: { singular: 'Dotted Quarter Note (ms)', plural: 'Dotted Quarter Note (ms)' },
|
||||
to_anchor: 90000 // 1.5 beats
|
||||
},
|
||||
|
||||
'dotted-eighth': {
|
||||
name: { singular: 'Dotted Eighth Note (ms)', plural: 'Dotted Eighth Note (ms)' },
|
||||
to_anchor: 45000 // 0.75 beats
|
||||
},
|
||||
|
||||
'dotted-sixteenth': {
|
||||
name: { singular: 'Dotted Sixteenth Note (ms)', plural: 'Dotted Sixteenth Note (ms)' },
|
||||
to_anchor: 22500 // 0.375 beats
|
||||
},
|
||||
|
||||
// Triplet notes (2/3 of the duration)
|
||||
'quarter-triplet': {
|
||||
name: { singular: 'Quarter Triplet (ms)', plural: 'Quarter Triplet (ms)' },
|
||||
to_anchor: 40000 // 2/3 beat
|
||||
},
|
||||
|
||||
'eighth-triplet': {
|
||||
name: { singular: 'Eighth Triplet (ms)', plural: 'Eighth Triplet (ms)' },
|
||||
to_anchor: 20000 // 1/3 beat
|
||||
},
|
||||
|
||||
'sixteenth-triplet': {
|
||||
name: { singular: 'Sixteenth Triplet (ms)', plural: 'Sixteenth Triplet (ms)' },
|
||||
to_anchor: 10000 // 1/6 beat
|
||||
},
|
||||
|
||||
// Milliseconds as direct time unit
|
||||
'ms': {
|
||||
name: { singular: 'Millisecond', plural: 'Milliseconds' },
|
||||
to_anchor: 60000 // Same as quarter note
|
||||
},
|
||||
|
||||
// Seconds
|
||||
's': {
|
||||
name: { singular: 'Second', plural: 'Seconds' },
|
||||
to_anchor: 60 // 60 seconds per beat at 1 BPM
|
||||
},
|
||||
|
||||
// Hertz (beats per second)
|
||||
'Hz': {
|
||||
name: { singular: 'Hertz', plural: 'Hertz' },
|
||||
to_anchor: 1 / 60 // 1 BPM = 1/60 Hz
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user