-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified siteMetaData. Added headerNavLinks
- Loading branch information
Showing
40 changed files
with
1,615 additions
and
1,762 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build and Deploy | ||
on: | ||
push: | ||
branches: | ||
- api | ||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Build | ||
run: | | ||
npm ci | ||
npm run build | ||
- name: Deploy | ||
uses: JamesIves/[email protected] | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | ||
BRANCH: gh-pages | ||
FOLDER: out | ||
CLEAN: true |
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,12 @@ | ||
--- | ||
name: Dean Tarisai | ||
avatar: /static/images/slowly-avatar.png | ||
occupation: Web Developer | ||
company: Freelancer | ||
email: [email protected] | ||
github: https://github.com/prjctimg | ||
|
||
|
||
--- | ||
|
||
Self taught programmer from Zimbabwe. Currently exploring the worlds of color,generative art and game development. Always learning. |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
title: Working with achromatic colors. | ||
date: '2023-09-28' | ||
draft: false | ||
summary: Utility for working with grays or achromatic colors and how to differentiate them from chromatic colors programmatically. | ||
layout: PostSimple | ||
canonicalUrl: https://prjctimg.github.io/huetiful/api/achromatic | ||
--- | ||
|
||
These are a subtype of colors that have no _hue_. Also known as grays, these colors can be found by interpolating black and white. | ||
|
||
We can use the _isAchromatic_ utility to check if a color is achromatic or not. | ||
|
||
**Parameters:** | ||
`(color:Color):boolean` | ||
color The color to test if it is achromatic or not. | ||
|
||
**Returns:** | ||
Returns true if the color is achromatic else false | ||
|
||
**Description:** | ||
Checks if a color is achromatic(without hue or simply grayscale). | ||
|
||
```javascript | ||
import { isAchromatic } from "huetiful-js"; | ||
import { formatHex8, interpolate, samples } from "culori" | ||
|
||
|
||
isAchromatic('pink') | ||
// false | ||
|
||
let sample = [ | ||
"#00ffdc", | ||
"#00ff78", | ||
"#00c000", | ||
"#007e00", | ||
"#164100", | ||
"#ffff00", | ||
"#310000", | ||
"#3e0000", | ||
"#4e0000", | ||
"#600000", | ||
"#720000", | ||
]; | ||
|
||
console.log(map(sample, isAchromatic)); | ||
|
||
// [ | ||
false, false, false, | ||
false, false, false, | ||
false, false, false, | ||
false, false | ||
] | ||
|
||
isAchromatic('gray') | ||
// Returns true | ||
|
||
|
||
console.log(map(sample, isAchromatic)); | ||
|
||
|
||
// we create an interpolation using black and white | ||
let f = interpolate(["black", "white"]); | ||
|
||
//We then create 12 evenly spaced samples and pass them to f as the `t` param required by an interpolating function. | ||
// Lastly we convert the color to hex for brevity for this example (otherwise color objects work fine too.) | ||
let grays = map(samples(12), (c) => formatHex8(f(c))); | ||
console.log(map(grays, isAchromatic)); | ||
|
||
// | ||
[ false, true, true, | ||
true, true, true, | ||
true, true, true, | ||
true, true, false | ||
] | ||
|
||
``` | ||
|
||
In the above code, we used _isAchromatic_ against different samples of achromatic as well as chromatic colors. The _samples_ array contained chromatic colors whilst `grays` holds the achromatic colors. Notice that at the last and first index when we tested for achromatic colors we had `false` values instead of _true_. This is because pure white/black are not achromatic. | ||
|
||
> For a color to be classified as being achromatic, it needs a falsy value on the **saturation** / **chroma** channel such as 0, **NaN** or **undefined**. This is because the `hue` depends on the **saturation** channel to be true or not be gray. This means that altering the **hue** or **lightness** channel whilst **saturation** is falsy will only return a gray color and black or white (at the extreme ends of the **lightness** channel) . |
Oops, something went wrong.