Skip to content

Main content

Convert Luminance Source Code

Browse the implementation files for Convert Luminance.
@tool.io/tools/convert/luminance source ↗
tool.ts typescript
import { convertLuminance as convertPortableLuminance } from '@tool.io/tools/convert/luminance';
import { measureFactorOptions } from '../tool';
import { measureFactors, NIST_LIGHT } from './factors';

export const convertLuminance = (
	value: number,
	from: string,
	to: string
) => convertPortableLuminance(value, from, to) ?? '';

export const Tool: TypeTool = {
	name: 'Convert Luminance',
	slug: 'convert/luminance',
	tool: convertLuminance,
	intro:
		'Convert directional surface brightness between candela per square meter, nit, foot-lambert, lambert, stilb, and related units.',
	i: [
		{
			example: '100',
			label: 'Value',
			placeholder: '100',
			type: 'number'
		},
		{
			example: 'nit',
			label: 'From',
			options: measureFactorOptions(measureFactors, 'nit'),
			placeholder: 'Select the source luminance unit',
			type: 'select',
			value: 'nit'
		},
		{
			example: 'fL',
			label: 'To',
			options: measureFactorOptions(measureFactors, 'fL'),
			placeholder: 'Select the destination luminance unit',
			type: 'select',
			value: 'fL'
		}
	],
	o: [
		{
			example: '29.185',
			label: 'Luminance',
			placeholder: 'Converted luminance',
			render: 'textarea',
			type: 'number'
		}
	],
	swap: {
		inputs: [1, 2],
		name: 'Swap luminance units',
		state: false
	},
	alternative: [
		{
			title: 'Convert illuminance',
			url: '/convert/illuminance'
		},
		{
			title: 'Convert luminous flux',
			url: '/convert/luminous-flux'
		},
		{
			title: 'Convert luminous intensity',
			url: '/convert/luminous-intensity'
		}
	],
	cite: [
		{
			title: 'Light conversion factors — NIST',
			url: NIST_LIGHT
		}
	]
};

export default Tool;

Description

Browse the implementation files for Convert Luminance.

References

  1. Tool.io on GitHub
  2. Tool.io TypeScript tools library

Similar or alternative tools