From ff9e509ad309c0c6b60087d5bb78972e0f164e38 Mon Sep 17 00:00:00 2001 From: sk66641 Date: Wed, 17 Apr 2024 00:52:33 +0530 Subject: [PATCH] update --- Readme.md | 44 +++++++++++++++++++++++++++++++++++++------- script.js | 14 +++++++------- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/Readme.md b/Readme.md index 36c9613..30c9d84 100644 --- a/Readme.md +++ b/Readme.md @@ -1,9 +1,39 @@ -This simulator takes three input:
+# Random Disco Light Simulator -#inputs:
-1:) What type of gradient you want to choose (conic or linear)?
-2:) By how much time interval (in milliseconds) you want to change the colors?
-3:) How many random colors you want to be shown? +## This simulator takes three inputs: -#output:
-On the basis of these three inputs, it simulates conic or linear view for given number of random colors and time interval. \ No newline at end of file +### Inputs: + +1. How many random colors you want to be shown? +2. By how much time interval (in milliseconds) you want to change the colors randomly?
+3. What type of gradient you want to choose (conic or linear)?
+ +### Output: + +On the basis of these three inputs, it simulates conic or linear view for given number of random colors and time interval. + +### Try these inputs: + + + + + + + + + + + + + + + + + + + + + +
1:)1000210007
2:)15001500
3:)coniclinearlinearconic
+ +### Have a fun! 😄 diff --git a/script.js b/script.js index d5bea42..f9818ad 100644 --- a/script.js +++ b/script.js @@ -13,14 +13,14 @@ let random_color = `${getRandomColor()}`; /* do { - var type = prompt("1:) To choose gradient between conic & linear, Type: \n -> 'c' or 'C' for conic \n -> 'l' or 'L' for linear"); + var view = prompt("1:) To choose gradient between conic & linear, view: \n -> 'c' or 'C' for conic \n -> 'l' or 'L' for linear"); - if (type != 'c' && type != 'l' && type != 'C' && type != 'L') { + if (view != 'c' && view != 'l' && view != 'C' && view != 'L') { alert("Please enter 'c' or 'C' for conic or 'l' or 'L' for linear"); } -} while (type != 'c' && type != 'l' && type != 'C' && type != 'L'); +} while (view != 'c' && view != 'l' && view != 'C' && view != 'L'); do { @@ -42,9 +42,9 @@ do { } while (isNaN(n) || n < 1 || Number.isInteger(n) == false); */ -let type = prompt("1:) To choose gradient between conic & linear, Enter: \n -> 'c' or 'C' for conic \n -> 'l' or 'L' for linear"); +let n = Number(prompt("1:) Enter the number of random colors:")); let set_time = Number(prompt("2:) Set the time interval (in 'milliseconds') with which the color changes randomly:\n(Negative interval or no input will be treated as 0 interval)")); -let n = Number(prompt("3:) Enter number of random colors:\n(Enter a positive integer greater than or equal to 1)")); +let view = prompt("3:) To choose gradient between conic & linear, Enter: \n -> 'c' or 'C' for conic \n -> 'l' or 'L' for linear"); // alert("𝘙𝘢𝘯𝘥𝘰𝘮 𝘋𝘪𝘴𝘤𝘰 𝘓𝘪𝘨𝘩𝘵 𝘚𝘪𝘮𝘶𝘭𝘢𝘵𝘰𝘳 (𝘸𝘪𝘵𝘩 💖 𝘣𝘺 '𝘬𝘶𝘮𝘢𝘳 𝘴𝘢𝘯𝘶')"); function number(n) { @@ -77,7 +77,7 @@ if (n == 1) { else if (n > 1) { - if (type == "c" || type == "C") { + if (view == "c" || view == "C" || view == "conic" || view == "Conic") { document.body.style.background = `conic-gradient(${random_color}, ${number(n - 1)} ${random_color})`; setInterval(() => { @@ -86,7 +86,7 @@ else if (n > 1) { }, `${set_time}`); } - else if (type == "l" || type == "L") { + else if (view == "l" || view == "L" || view == "linear" || view == "Linear") { document.body.style.background = `linear-gradient(${number(n - 1)} ${random_color})`; setInterval(() => {