Skip to content

Commit

Permalink
Update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleactii committed Mar 28, 2023
1 parent c6c4025 commit eb788c8
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 4 deletions.
139 changes: 136 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,142 @@
</div>
</nav>

<div class="content" data-ice="content"><div data-ice="index" class="github-markdown"><h1 id="eutils">EUtils</h1><p>A small plugin full of useful things.</p>
<p>#INCLUDE SCRIPT eutils.min.js</p>
<p><strong>&#x1F6A7;&#x1F6A7; Docs coming soon &#x1F6A7;&#x1F6A7;</strong></p>
<div class="content" data-ice="content"><div data-ice="index" class="github-markdown"><h1 id="eutils">EUtils</h1><p>EUtils is a lightweight and versatile JavaScript utility class designed to provide commonly used functions for web development. It is a collection of various helper functions that can be used in a variety of projects.</p>
<h1 id="usage">Usage</h1><p>To use EUtils in your project, simply import it as follows:</p>
<pre><code class="lang-js"><code class="source-code prettyprint">import { EUtils } from &apos;./eutils.min.mjs&apos;;</code>
</code></pre>
<p>You can then call any of the functions available in the EUtils class.</p>
<h1 id="api">API</h1><p>decimalRand(pNum1, pNum2, pPlaces)</p>
<ul>
<li>Generates a random decimal number between <strong><code>pNum1</code></strong> and <strong><code>pNum2</code></strong> with <strong><code>pPlaces</code></strong> decimal places.</li>
</ul>
<p>rand(pNum1, pNum2)</p>
<ul>
<li>Generates a random integer between <strong><code>pNum1</code></strong> and <strong><code>pNum2</code></strong>.</li>
</ul>
<p>getPercentage(pValue, pTotalValue)</p>
<ul>
<li>Calculates the percentage of <strong><code>pValue</code></strong> in relation to <strong><code>pTotalValue</code></strong>.</li>
</ul>
<p>clamp(pNumber, pMin, pMax)</p>
<ul>
<li>Clamps <strong><code>pNumber</code></strong> between <strong><code>pMin</code></strong> and <strong><code>pMax</code></strong>.</li>
</ul>
<p>lerp(pStart, pEnd, pAmount)</p>
<ul>
<li>Linearly interpolates between <strong><code>pStart</code></strong> and <strong><code>pEnd</code></strong> by <strong><code>pAmount</code></strong>.</li>
</ul>
<p>flooredLerp(pStart, pEnd, pAmount)</p>
<ul>
<li>Linearly interpolates between <strong><code>pStart</code></strong> and <strong><code>pEnd</code></strong> by <strong><code>pAmount</code></strong>, then floors the result.</li>
</ul>
<p>round(pNumber, pPlace)</p>
<ul>
<li>Rounds pNumber to <strong><code>pPlace</code></strong> decimal places.</li>
</ul>
<p>normalize(pVal, pMin, pMax)</p>
<ul>
<li>Normalizes pVal between <strong><code>pMin</code></strong> and <strong><code>pMax</code></strong>.</li>
</ul>
<p>within(pVal, pMin, pMax)</p>
<ul>
<li>Checks if <strong><code>pVal</code></strong> is within the range of <strong><code>pMin</code></strong> and <strong><code>pMax</code></strong>.</li>
</ul>
<p>formatIntegerWithCommas(pNum)</p>
<ul>
<li>Formats <strong><code>pNum</code></strong> as a string with commas between every three digits.</li>
</ul>
<p>degreesToRadians(pDegrees)</p>
<ul>
<li>Converts degrees to radians.</li>
</ul>
<p>radiansToDegrees(pRadians)</p>
<ul>
<li>Converts radians to degrees.</li>
</ul>
<p>pick(pArray)</p>
<ul>
<li>Returns a random element from <strong><code>pArray</code></strong>.</li>
</ul>
<p>removeProperties(pObject, pExclude)</p>
<ul>
<li>Removes all properties from <strong><code>pObject</code></strong>, excluding those in <strong><code>pExclude</code></strong>.</li>
</ul>
<p>prob(pChance)</p>
<ul>
<li>Returns true with a probability of <strong><code>pChance</code></strong>, and false with a probability of <strong><code>100 - pChance</code></strong>.</li>
</ul>
<p>getInverseDir(pDir)</p>
<ul>
<li>Returns the opposite direction of <strong><code>pDir</code></strong>.</li>
</ul>
<p>getAngleFromDir(pDir)</p>
<ul>
<li>Returns the angle in radians corresponding to <strong><code>pDir</code></strong>.</li>
</ul>
<p>generateID(pIDLength)</p>
<ul>
<li>Generates a random unique ID string of length <strong><code>pIDLength</code></strong>.</li>
</ul>
<p>decimalToHex(pDecimal, pChars)</p>
<ul>
<li>Converts a decimal number to a hexadecimal color string with pChars characters. <strong><code>pChars</code></strong> can either be <strong><code>3</code></strong> or <strong><code>6</code></strong>.</li>
</ul>
<p>addIntensity(pColor, pPercent)</p>
<ul>
<li>Increases the intensity of pColor by <strong><code>pPercent</code></strong> <strong><code>percent</code></strong>.</li>
</ul>
<p>rgbToHex(pR, pG, pB)</p>
<ul>
<li>Converts an RGB color to a hexadecimal color string.</li>
</ul>
<p>hexToRgb(pHex)</p>
<ul>
<li>Converts a hexadecimal color string to an RGB color.</li>
</ul>
<p>rgbToDecimal(pR, pG, pB)</p>
<ul>
<li>Converts an RGB color to a decimal number.</li>
</ul>
<p>hexToDecimal(pHex)</p>
<ul>
<li>Converts a hexadecimal color string to a decimal number.</li>
</ul>
<p>grabColor(pSwitch, pG, pB)</p>
<ul>
<li>Returns a color object with a hexadecimal color string, tagless hexadecimal color string, RGB string, RGB color array, RGB normalized array, RGB object, and decimal color number. If <strong><code>pSwitch</code></strong> is a number, <strong><code>pG</code></strong> and <strong><code>pB</code></strong> must also be numbers and represent the green and blue components of the color respectively. If <strong><code>pSwitch</code></strong> is a string, it can either be a hexadecimal color string or a decimal color.</li>
</ul>
<p>getRandomColor()</p>
<ul>
<li>Gets a random color in the hex format.</li>
</ul>
<p>getRandomColorBetween(pColor1, pColor2, pAmount = 0.5)</p>
<ul>
<li>Gets a random color between <strong><code>pColor1</code></strong> and <strong><code>pColor2</code></strong> in the decimal format. <strong><code>pAmount</code></strong> can be used to change how close the returned color is to either <strong><code>pColor1</code></strong> or <strong><code>pColor2</code></strong>.</li>
</ul>
<p>transitionColor(pInstance, pStartColor=&apos;#000&apos;, pEndColor=&apos;#fff&apos;, pDuration=1000, pIterativeCallback, pEndCallback)</p>
<ul>
<li>Transition <strong><code>pStartColor</code></strong> to <strong><code>pEndColor</code></strong> in <strong><code>pDuration</code></strong> time with callbacks to track the animation. Where <strong><code>pIterativeCallback</code></strong> is called each frame and <strong><code>pEndCallback</code></strong> is called at the end of the animation. This API returns the <strong><code>ID</code></strong> of the transition. So that if you want to cancel it, you can use <strong><code>cancelTransitionColor(ID)</code></strong>.</li>
</ul>
<p>cancelTransitionColor(pID)</p>
<ul>
<li>Cancels an ongoing transition with the <strong><code>ID</code></strong> of <strong><code>pID</code></strong>.</li>
</ul>
<p>getPointRotated(pRect, pTheta, pPoint)v</p>
<ul>
<li>Calculates the position of a point after rotating it around a center point by a given angle.</li>
<li>@param {object} pRect - The rectangle object to rotate the point around. pRect.anchor.x and pRecent.anchor.y is used to control the &quot;center&quot; of the rectangle.</li>
<li>@param {number} pTheta - The angle (in radians) to rotate the point by.</li>
<li>@param {object} pPoint - The point object to rotate around the center of the rectangle.</li>
<li>@param {number} pPoint.x - The x-coordinate of the point to rotate.</li>
<li>@param {number} pPoint.y - The y-coordinate of the point to rotate.</li>
<li>@returns {object} An object with the rotated point&apos;s new x and y coordinates.</li>
</ul>
<p>getPointsOfRotatedRect(pRect, pTheta)</p>
<ul>
<li>@param {object} pRect - The rectangle object to rotate the point around. <strong><code>pRect.anchor.x</code></strong> and <strong><code>pRecent.anchor.y</code></strong> is used to control the &quot;center&quot; of the rectangle.</li>
<li>@param {number} pTheta - The angle (in radians) to rotate the point by.</li>
</ul>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion docs/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2229,7 +2229,7 @@
},
{
"kind": "index",
"content": "# EUtils\r\nA small plugin full of useful things.\r\n\r\n#INCLUDE SCRIPT eutils.min.js\r\n\r\n**🚧🚧 Docs coming soon 🚧🚧**\r\n",
"content": "# EUtils\r\n\r\nEUtils is a lightweight and versatile JavaScript utility class designed to provide commonly used functions for web development. It is a collection of various helper functions that can be used in a variety of projects.\r\n\r\n# Usage\r\nTo use EUtils in your project, simply import it as follows:\r\n\r\n```js\r\nimport { EUtils } from './eutils.min.mjs';\r\n```\r\n\r\nYou can then call any of the functions available in the EUtils class.\r\n\r\n# API\r\ndecimalRand(pNum1, pNum2, pPlaces)\r\n- Generates a random decimal number between **`pNum1`** and **`pNum2`** with **`pPlaces`** decimal places.\r\n\r\nrand(pNum1, pNum2)\r\n- Generates a random integer between **`pNum1`** and **`pNum2`**.\r\n\r\ngetPercentage(pValue, pTotalValue)\r\n- Calculates the percentage of **`pValue`** in relation to **`pTotalValue`**.\r\n\r\nclamp(pNumber, pMin, pMax)\r\n- Clamps **`pNumber`** between **`pMin`** and **`pMax`**.\r\n\r\nlerp(pStart, pEnd, pAmount)\r\n- Linearly interpolates between **`pStart`** and **`pEnd`** by **`pAmount`**.\r\n\r\nflooredLerp(pStart, pEnd, pAmount)\r\n- Linearly interpolates between **`pStart`** and **`pEnd`** by **`pAmount`**, then floors the result.\r\n\r\nround(pNumber, pPlace)\r\n- Rounds pNumber to **`pPlace`** decimal places.\r\n\r\nnormalize(pVal, pMin, pMax)\r\n- Normalizes pVal between **`pMin`** and **`pMax`**.\r\n\r\nwithin(pVal, pMin, pMax)\r\n- Checks if **`pVal`** is within the range of **`pMin`** and **`pMax`**.\r\n\r\nformatIntegerWithCommas(pNum)\r\n- Formats **`pNum`** as a string with commas between every three digits.\r\n\r\ndegreesToRadians(pDegrees)\r\n- Converts degrees to radians.\r\n\r\nradiansToDegrees(pRadians)\r\n- Converts radians to degrees.\r\n\r\npick(pArray)\r\n- Returns a random element from **`pArray`**.\r\n\r\nremoveProperties(pObject, pExclude)\r\n- Removes all properties from **`pObject`**, excluding those in **`pExclude`**.\r\n\r\nprob(pChance)\r\n- Returns true with a probability of **`pChance`**, and false with a probability of **`100 - pChance`**.\r\n\r\ngetInverseDir(pDir)\r\n- Returns the opposite direction of **`pDir`**.\r\n\r\ngetAngleFromDir(pDir)\r\n- Returns the angle in radians corresponding to **`pDir`**.\r\n\r\ngenerateID(pIDLength)\r\n- Generates a random unique ID string of length **`pIDLength`**.\r\n\r\ndecimalToHex(pDecimal, pChars)\r\n- Converts a decimal number to a hexadecimal color string with pChars characters. **`pChars`** can either be **`3`** or **`6`**.\r\n\r\naddIntensity(pColor, pPercent)\r\n- Increases the intensity of pColor by **`pPercent`** **`percent`**.\r\n\r\nrgbToHex(pR, pG, pB)\r\n- Converts an RGB color to a hexadecimal color string.\r\n\r\nhexToRgb(pHex)\r\n- Converts a hexadecimal color string to an RGB color.\r\n\r\nrgbToDecimal(pR, pG, pB)\r\n- Converts an RGB color to a decimal number.\r\n\r\nhexToDecimal(pHex)\r\n- Converts a hexadecimal color string to a decimal number.\r\n\r\ngrabColor(pSwitch, pG, pB)\r\n- Returns a color object with a hexadecimal color string, tagless hexadecimal color string, RGB string, RGB color array, RGB normalized array, RGB object, and decimal color number. If **`pSwitch`** is a number, **`pG`** and **`pB`** must also be numbers and represent the green and blue components of the color respectively. If **`pSwitch`** is a string, it can either be a hexadecimal color string or a decimal color.\r\n\r\ngetRandomColor()\r\n- Gets a random color in the hex format.\r\n\r\ngetRandomColorBetween(pColor1, pColor2, pAmount = 0.5)\r\n- Gets a random color between **`pColor1`** and **`pColor2`** in the decimal format. **`pAmount`** can be used to change how close the returned color is to either **`pColor1`** or **`pColor2`**.\r\n\r\ntransitionColor(pInstance, pStartColor='#000', pEndColor='#fff', pDuration=1000, pIterativeCallback, pEndCallback)\r\n- Transition **`pStartColor`** to **`pEndColor`** in **`pDuration`** time with callbacks to track the animation. Where **`pIterativeCallback`** is called each frame and **`pEndCallback`** is called at the end of the animation. This API returns the **`ID`** of the transition. So that if you want to cancel it, you can use **`cancelTransitionColor(ID)`**.\r\n\r\ncancelTransitionColor(pID)\r\n- Cancels an ongoing transition with the **`ID`** of **`pID`**.\r\n\r\ngetPointRotated(pRect, pTheta, pPoint)v\r\n- Calculates the position of a point after rotating it around a center point by a given angle.\r\n- @param {object} pRect - The rectangle object to rotate the point around. pRect.anchor.x and pRecent.anchor.y is used to control the \"center\" of the rectangle.\r\n- @param {number} pTheta - The angle (in radians) to rotate the point by.\r\n- @param {object} pPoint - The point object to rotate around the center of the rectangle.\r\n- @param {number} pPoint.x - The x-coordinate of the point to rotate.\r\n- @param {number} pPoint.y - The y-coordinate of the point to rotate.\r\n- @returns {object} An object with the rotated point's new x and y coordinates.\r\n\r\ngetPointsOfRotatedRect(pRect, pTheta)\r\n- @param {object} pRect - The rectangle object to rotate the point around. **`pRect.anchor.x`** and **`pRecent.anchor.y`** is used to control the \"center\" of the rectangle.\r\n- @param {number} pTheta - The angle (in radians) to rotate the point by.",
"longname": "Z:\\Business\\Evitca Studio\\Github\\EUtils\\README.md",
"name": "./README.md",
"static": true,
Expand Down

0 comments on commit eb788c8

Please sign in to comment.