fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
29 lines (26 loc) • 665 B
JavaScript
import { halfPI } from '../../constants.mjs';
/**
* Calculate the cos of an angle, avoiding returning floats for known results
* This function is here just to avoid getting 0.999999999999999 when dealing
* with numbers that are really 1 or 0.
* @param {TRadian} angle the angle
* @return {Number} the sin value for angle.
*/
const sin = angle => {
if (angle === 0) {
return 0;
}
const angleSlice = angle / halfPI;
const value = Math.sign(angle);
switch (angleSlice) {
case 1:
return value;
case 2:
return 0;
case 3:
return -value;
}
return Math.sin(angle);
};
export { sin };
//# sourceMappingURL=sin.mjs.map