Skip to content

Commit

Permalink
so fckng confused right now....breaking shitt for the night
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlwizard committed Dec 14, 2024
1 parent 4e49258 commit fc0d6eb
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
35 changes: 14 additions & 21 deletions lib/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { mc } from "./utils.ts";

import { contrast } from "./accessibility.ts";
import type { Collection, ColorToken, Factor, Colorspaces } from "./types.d.ts";
import { hue } from "./constants.ts";

const { keys, entries, values } = Object;

Expand Down Expand Up @@ -157,7 +158,19 @@ function colorObj(a: string, b: unknown) {

}

function customFindKey(u: object, v: number) {



// customCConcat ???
// capture the amount of elements in hue
// for each element; slice the array from index 0 (the color family string index)
//
function customFindKey(u: typeof hue, v: number) {





// If the color is achromatic return the string gray
return keys(u)
.filter((a) => {
Expand All @@ -173,25 +186,6 @@ function customFindKey(u: object, v: number) {
.toString();
}

function customConcat(h = {}) {
return and(
eq(typeof h, "object"),
(() => {
const res = [];
const k = keys(h);



for (const g of k) {
//@ts-ignore
res.push(...h[g]);
}

return res.flat(1);
})(),
);
}

function adjustHue(val: number) {

let out = 0
Expand Down Expand Up @@ -487,7 +481,6 @@ export {
filteredColl,
customFindKey,
colorObj,
customConcat,
inRange,
rand,
isInt,
Expand Down
3 changes: 1 addition & 2 deletions lib/palettes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
QualitativeScheme,
ScaleValues,
SequentialScheme,
Swatch,
Tailwind,
} from "./types.d.ts";
import { and, eq, isArray, keys, or, values } from "./internal.ts";
Expand Down Expand Up @@ -290,7 +289,7 @@ function hasScheme(s: string = '', obj: Collection = {}) {
* @returns {Collection|import('../types.js').ColorToken} A collection of colors in the specified colorspace. The default is hex if `colorspace` is `undefined.`
* @example
*
* import { sequential } from 'huetiful-js
* import { sequential } from 'huetiful-js'
console.log(sequential("OrRd"))
Expand Down
18 changes: 9 additions & 9 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ import {
lte,
max,
min,
neq,
not,
or,
rand,
take,
} from "./internal.ts";
import { hue } from "./constants.ts";
import type {
Expand Down Expand Up @@ -79,7 +77,7 @@ console.log(alpha('#a1bd2f0d'))
// 0.050980392156862744
// Setting the alpha
let myColor = alpha('b2c3f1', 0.5)
console.log(myColor)
Expand Down Expand Up @@ -678,16 +676,18 @@ console.log(family("#310000"))
// 'red'
*/
function family(color?: ColorToken): BiasedHues & ColorFamily {
if (neq(achromatic(color), true)) {
if (!(achromatic(color))) {
const [hueAngle, hueFamilies] = [
mc("lch.h")(color),
keys(hue),
hue.map(arr => arr[0])
];

console.log(hueAngle, hueFamilies)
// @ts-ignore:
return hueFamilies.find((o) => {
// @ts-ignore:
const hueRanges = customConcat(hue[o]);

console.log(hueRanges)
return inRange(hueAngle, min(hueRanges), max(hueRanges));
});
}
Expand Down Expand Up @@ -725,13 +725,13 @@ console.log(map(sample, temp));
function temp(color: ColorToken = "cyan"): "cool" | "warm" {
return (
(
keys(hue).some((hueFamily) =>
keys(hue).some((fam) =>
inRange(
floorCeil(mc("lch.h")(color)),
// @ts-ignore:
hue[hueFamily].cool[0],
hue[fam].cool[0],
// @ts-ignore:
hue[hueFamily].cool[1],
hue[fam].cool[1],
)
) &&
"cool"
Expand Down
9 changes: 6 additions & 3 deletions test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import { token } from './lib/utils.ts'

import { diverging, sortBy, filterBy, stats, colors } from "./lib/index.ts";
import { mc, token } from "./lib/utils.ts";
import { achromatic, family, mc, token } from "./lib/utils.ts";

// console.log(stats(colors('all', '600'), {
// factor: ['chroma', 'hue'], colorspace: 'lch'zzzzzzz
Expand All @@ -22,5 +22,8 @@ import { mc, token } from "./lib/utils.ts";
// todo

//console.log(mc('rgb.b')(['rgb', 0.4, 0.3, 0.1]))
console.log(mc('lch.h')({ r: 0.2, g: 0.4, b: 0.5, mode: 'rgb' }))
console.log(token({ r: 0.2, g: 0.4, b: 0.5, mode: 'rgb' }, { kind: 'obj', targetMode: 'lch' }))
// console.log(mc('lch.h')({ r: 0.2, g: 0.4, b: 0.5, mode: 'rgb' }))
// console.log(token({ r: 0.2, g: 0.4, b: 0.5, mode: 'rgb' }, { kind: 'obj', targetMode: 'lch' }))


console.log(family('#97dfd7ff'))
5 changes: 5 additions & 0 deletions tests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ const specs: Spec[] = [{
}, {
description: 'gets the alpha channel value from a color string',
callback: alpha, params: [str]
},
{
description: 'sets the ',
params: [str],
callback: undefined
}
];

Expand Down

0 comments on commit fc0d6eb

Please sign in to comment.