From 9e7a61bb2eb70ef598513e083827e5fce6349ae1 Mon Sep 17 00:00:00 2001 From: Nalin Date: Fri, 22 Nov 2024 14:37:35 +0530 Subject: [PATCH 1/2] added color gradient in p5.Color.js file --- package-lock.json | 9 +++++---- package.json | 3 ++- src/color/p5.Color.js | 25 +++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 25859a143b..b9e6e108d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3921,9 +3921,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001549", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001549.tgz", - "integrity": "sha512-qRp48dPYSCYaP+KurZLhDYdVE+yEyht/3NlmcJgVQ2VMGt6JL36ndQ/7rgspdZsJuxDPFIo/OzBT2+GmIJ53BA==", + "version": "1.0.30001683", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001683.tgz", + "integrity": "sha512-iqmNnThZ0n70mNwvxpEC2nBJ037ZHZUoBI5Gorh1Mw6IlEAZujEoU1tXA628iZfzm7R9FvFzxbfdgml82a3k8Q==", "dev": true, "funding": [ { @@ -3938,7 +3938,8 @@ "type": "github", "url": "https://github.com/sponsors/ai" } - ] + ], + "license": "CC-BY-4.0" }, "node_modules/chai": { "version": "3.5.0", diff --git a/package.json b/package.json index 9d10fceece..d99172bacb 100644 --- a/package.json +++ b/package.json @@ -143,5 +143,6 @@ "hooks": { "pre-commit": "lint-staged" } - } + }, + "packageManager": "pnpm@9.12.1+sha512.e5a7e52a4183a02d5931057f7a0dbff9d5e9ce3161e33fa68ae392125b79282a8a8a470a51dfc8a0ed86221442eb2fb57019b0990ed24fab519bf0e1bc5ccfc4" } diff --git a/src/color/p5.Color.js b/src/color/p5.Color.js index 5dee81c61d..7167f45bb6 100644 --- a/src/color/p5.Color.js +++ b/src/color/p5.Color.js @@ -835,6 +835,31 @@ p5.Color = class Color { return this.hsla[1] * this.maxes[constants.HSL][1]; } } + + //Added the gradients for color + _generateGradient() { + const hue = this._getHue(); // Fetch hue + const lightness = this._getLightness(); // Fetch lightness + + // Adjust properties for variation + const startLightness = Math.max(0, lightness - 20); // Darker start + const endLightness = Math.min(100, lightness + 20); // Lighter end + + // Generate color stops + const startColor = `hsl(${hue}, 80%, ${startLightness}%)`; + const endColor = `hsl(${hue}, 80%, ${endLightness}%)`; + + // Create linear gradient + return `linear-gradient(90deg, ${startColor}, ${endColor})`; + } + + // Usage: Apply the gradient to an element + applyGradient(element) { + const gradient = this._generateGradient(); + element.style.background = gradient; + } + + //end of gradient logic /** * For a number of different inputs, returns a color formatted as [r, g, b, a] * arrays, with each component normalized between 0 and 1. From cf13c22b1332229201b7ba74ad617858d99e7db0 Mon Sep 17 00:00:00 2001 From: Nalin Date: Fri, 22 Nov 2024 14:50:57 +0530 Subject: [PATCH 2/2] added my own into contributor list --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0f0827f282..749052118c 100644 --- a/README.md +++ b/README.md @@ -1074,6 +1074,8 @@ We recognize all types of contributions. This project follows the [all-contribut blackboxlogic
blackboxlogic

📖 ℤ

📖 dhanush
dhanush

📖 + Nalin Dalal
Nalin Dalal

🐛 💻 +