From 8fcf58c049be96ff3d2b2aeaa4ab4f0728e719ce Mon Sep 17 00:00:00 2001 From: ayushman1210 Date: Thu, 9 Oct 2025 01:14:44 +0530 Subject: [PATCH] add feature of E(Euler number) --- src/core/constants.js | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/core/constants.js b/src/core/constants.js index ece1333037..37e0b87017 100644 --- a/src/core/constants.js +++ b/src/core/constants.js @@ -627,9 +627,56 @@ export const DEGREES = 'degrees'; * * */ + +/** + * @property {Number} E (Euler's Number) + * @final + * @default 2.718281828459045 + * @description Euler’s number, the base of natural logarithms. + * It is approximately equal to 2.71828 and is used in many + * mathematical and exponential calculations. + * + * @example + *
+ * + * function setup() { + * createCanvas(100, 100); + * + * background(200); + * + * // Calculate exponential growth using E + * let growthRate = 0.5; + * let result = E ** growthRate; + * + * // Display E and the calculation + * fill(0); + * textAlign(CENTER, CENTER); + * textSize(12); + * text('E = ' + E.toFixed(5), 50, 30); + * text('e^0.5 = ' + result.toFixed(5), 50, 50); + * + * // Visualize exponential curve + * stroke(0, 100, 255); + * strokeWeight(2); + * noFill(); + * beginShape(); + * for (let x = 0; x < width; x++) { + * let t = map(x, 0, width, 0, 2); + * let y = map(E ** t, 1, E ** 2, height - 10, 60); + * vertex(x, y); + * } + * endShape(); + * + * describe('A gray canvas showing the value of E (2.71828) and e^0.5, with a blue exponential growth curve below the text.'); + * } + * + *
+ */ + export const RADIANS = 'radians'; export const DEG_TO_RAD = _PI / 180.0; export const RAD_TO_DEG = 180.0 / _PI; +export const E = Math.E; // SHAPE /**