beer-color
v1.0.0
Published
Convert between SRM, EBC, Lovibond, hex and RGB
Downloads
11
Readme
beer-color
Simple library to convert between beer/malt color units and to hex.
- Convert between SRM, EBC and Lovibond
- Hex conversion is only a rough approximation and not an accurate prediction of actual beer color as this is influenced by a wide range of factors such as lighting, glass size, yeast action, additions, etc.
Usage
Install the module with:
npm install beer-color
import { ebcToHex, lovibondToHex, srmToHex } from 'beer-color';
const hex = srmToHex(3.6);
// '#efec2e'
const hex = ebcToHex(23.6);
// '#c07238'
const hex = lovibondToHex(0.5);
// '#fafad2'
import { convertColorUnits } from 'beer-color';
const ebc = convertColorUnits(12, 'srm', 'ebc');
// 23.64
const srm = convertColorUnits(12, 'ebc', 'srm');
// 6.096
const lovibond = convertColorUnits(12, 'ebc', 'lovibond');
// 5.06
Documentation
srmToHex(value)
value
number
SRM value to convert
returns approximate hex color equivalent
ebcToHex(value)
value
number
EBC value to convert
returns approximate hex color equivalent
lovibondToHex(value)
value
number
lovibond value to convert
returns approximate hex color equivalent
convertColorUnits(value, sourceUnit, targetUnit)
value
number
value to convertsourceUnit
'srm' | 'ebc' | 'lovibond'
unit of value parametertargetUnit
'srm' | 'ebc' | 'lovibond'
unit to convert to
returns converted value for the specified unit
Testing
To run tests:
npm install
npm run test