You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/computed-function/main.html

14 lines
292 B

<script>
export let domain = [ 0, 10 ];
export let range = [ 0, 100 ];
export let x = 5;
function scale() {
return num => {
const t = domain[0] + ( num - domain[0] ) / ( domain[1] - domain[0] );
return range[0] + t * ( range[1] - range[0] );
}
}
</script>
<p>{scale()(x)}</p>