|
Last change
on this file was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Prototype 1.1
|
-
Property mode
set to
100644
|
|
File size:
700 bytes
|
| Line | |
|---|
| 1 | import constant from "./constant.js";
|
|---|
| 2 |
|
|---|
| 3 | function linear(a, d) {
|
|---|
| 4 | return function(t) {
|
|---|
| 5 | return a + t * d;
|
|---|
| 6 | };
|
|---|
| 7 | }
|
|---|
| 8 |
|
|---|
| 9 | function exponential(a, b, y) {
|
|---|
| 10 | return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
|
|---|
| 11 | return Math.pow(a + t * b, y);
|
|---|
| 12 | };
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | export function hue(a, b) {
|
|---|
| 16 | var d = b - a;
|
|---|
| 17 | return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant(isNaN(a) ? b : a);
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | export function gamma(y) {
|
|---|
| 21 | return (y = +y) === 1 ? nogamma : function(a, b) {
|
|---|
| 22 | return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a);
|
|---|
| 23 | };
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | export default function nogamma(a, b) {
|
|---|
| 27 | var d = b - a;
|
|---|
| 28 | return d ? linear(a, d) : constant(isNaN(a) ? b : a);
|
|---|
| 29 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.