-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 14-implement-change-shadows
- Loading branch information
Showing
15 changed files
with
522 additions
and
44 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import EditPix from "../../src/editpix.js"; | ||
|
||
const editpix = new EditPix(); | ||
|
||
//color | ||
const hexColor = "#78828c"; | ||
|
||
//convert color from hex to rgb | ||
const rgbColor = editpix.convertToRgb(hexColor); | ||
|
||
//get the higher contrast color | ||
const higherColorContrastRgb = editpix.getHigherContrast(rgbColor); | ||
|
||
//convert higher contrast color from rgb to hex | ||
const higherColorContrastHex = editpix.convertToHex(higherColorContrastRgb); | ||
|
||
|
||
//display results | ||
document.body.style.backgroundColor = hexColor; | ||
const contrastText = document.createElement("h1"); | ||
contrastText.textContent = "Hello World!" | ||
contrastText.style.color = higherColorContrastHex; | ||
document.body.appendChild(contrastText) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Function to change the exposure of an image. | ||
* @param {number[]} pixelArray: Image pixel array in the format [R, G, B, alpha,..., R, G, B, alpha]. | ||
* @param {number} factor: Factor to adjust the exposure (-100 to 100). | ||
* @returns {number[]} Pixel array of the image with adjusted exposure. | ||
*/ | ||
function changeExposure(pixelArray, factor) { | ||
for (let i = 0; i < pixelArray.length; i += 4) { | ||
const r = pixelArray[i]; | ||
const g = pixelArray[i + 1]; | ||
const b = pixelArray[i + 2]; | ||
|
||
// Apply exposure adjustment to each channel | ||
const newR = Math.max(0, Math.min(255, r + factor * 2.55)); // Factor scaled to range 0-255 | ||
const newG = Math.max(0, Math.min(255, g + factor * 2.55)); | ||
const newB = Math.max(0, Math.min(255, b + factor * 2.55)); | ||
|
||
pixelArray[i] = newR; | ||
pixelArray[i + 1] = newG; | ||
pixelArray[i + 2] = newB; | ||
} | ||
return pixelArray; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Function to change the tint of an image. | ||
* @param {number[]} pixelArray: Image pixel array in the format [R, G, B, alpha,..., R, G, B, alpha]. | ||
* @param {number} tint: Tint to apply (-100 to 100). | ||
* @returns {number[]} Pixel array of the image with adjusted tint. | ||
*/ | ||
function changeTint(pixelArray, tint) { | ||
for (let i = 0; i < pixelArray.length; i += 4) { | ||
const r = pixelArray[i]; | ||
const g = pixelArray[i + 1]; | ||
const b = pixelArray[i + 2]; | ||
|
||
// Apply tint adjustment to each channel | ||
const newR = Math.max(0, Math.min(255, r + (255 - r) * (tint / 100))); | ||
const newG = Math.max(0, Math.min(255, g + (255 - g) * (tint / 100))); | ||
const newB = Math.max(0, Math.min(255, b + (255 - b) * (tint / 100))); | ||
|
||
pixelArray[i] = newR; | ||
pixelArray[i + 1] = newG; | ||
pixelArray[i + 2] = newB; | ||
} | ||
return pixelArray; | ||
} |
Oops, something went wrong.