color-util-helpers 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# Color Util Helpers
|
|
2
|
+
|
|
3
|
+
This lib contains a variety of very useful color utils
|
|
4
|
+
|
|
5
|
+
- Color conversion (HEX<->RGB)
|
|
6
|
+
- Generate a Color Pallette (from image - eg: Pintrest before image loads)
|
|
7
|
+
- Color Extractor Directive (from inline image - eg: Pintrest before image loads)
|
|
8
|
+
- Text Color - provides the color to use (you provide light and dark) based on color provided
|
|
9
|
+
- Color Lighten Darken - Takes a color and you can darken or lighten
|
|
10
|
+
- Generate Random Color - This function generates a random hue value between 0 and 360 degrees, and random saturation and lightness values between 50% and 100%.
|
|
11
|
+
- Color Grabber - Directive when applied to a div will get the average color of the provided url of an image and then change the background color.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
`npm install color-util-helpers`
|
|
16
|
+
|
|
17
|
+
## Demo
|
|
18
|
+
|
|
19
|
+
Import the `ColorUtilHelpersModule`
|
|
20
|
+
|
|
21
|
+
add the selector `<app-color-utilities-demo></app-color-utilities-demo>`
|
|
22
|
+
|
|
23
|
+
## Color Conversion Service
|
|
24
|
+
|
|
25
|
+
Converts RGB to HEX or HEX to RGB
|
|
26
|
+
|
|
27
|
+
### Installation
|
|
28
|
+
|
|
29
|
+
npm install color-util-helpers
|
|
30
|
+
|
|
31
|
+
### Usage
|
|
32
|
+
|
|
33
|
+
rgbToHex(rgb: number[]): string
|
|
34
|
+
|
|
35
|
+
hexToRgb(hex: string): string
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## Color Pallette Service and Directive
|
|
39
|
+
|
|
40
|
+
### Usage
|
|
41
|
+
|
|
42
|
+
Because this is a Directive - import the `ColorExtractorDirective`
|
|
43
|
+
|
|
44
|
+
define image path
|
|
45
|
+
|
|
46
|
+
this.colorSelectionService.getColorsFromImage('../assets/sample2.jpg')
|
|
47
|
+
|
|
48
|
+
### Usage
|
|
49
|
+
|
|
50
|
+
this.colorSelectionService.palette.subscribe(data => this.palette = data)
|
|
51
|
+
|
|
52
|
+
### Template Usage
|
|
53
|
+
|
|
54
|
+
<div *ngFor="let color of palette">
|
|
55
|
+
<div style="display: flex;">
|
|
56
|
+
<div
|
|
57
|
+
class="box"
|
|
58
|
+
[style.background-color]="color.color"
|
|
59
|
+
>
|
|
60
|
+
Color
|
|
61
|
+
</div>
|
|
62
|
+
<div
|
|
63
|
+
class="box"
|
|
64
|
+
[style.background-color]="color.complementaryColor"
|
|
65
|
+
>
|
|
66
|
+
Complementary
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
CSS Style
|
|
72
|
+
|
|
73
|
+
CSS
|
|
74
|
+
.box {
|
|
75
|
+
width: 100px;
|
|
76
|
+
height: 100px;
|
|
77
|
+
border: solid thin black;
|
|
78
|
+
color: black;
|
|
79
|
+
margin: 4px;
|
|
80
|
+
padding: 16px;
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-wrap: wrap;
|
|
83
|
+
align-content: center;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
## Text Color Service
|
|
88
|
+
|
|
89
|
+
Provide a color that is used for a background and then provide the lightColor and darkColor
|
|
90
|
+
The function will return the appropriate color based on the background color provided
|
|
91
|
+
|
|
92
|
+
### Usage
|
|
93
|
+
|
|
94
|
+
This function takes `bgColor` and by providing the `lightColor` and `darkColor` compares them to the background and returns the color that will best work for the visibility of the background color.
|
|
95
|
+
|
|
96
|
+
These colors may be represented as RGB or HEX
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
textColorForBgColor(bgColor: string, lightColor: string, darkColor: string)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This function takes two colors and compares them and returns the darker color.
|
|
103
|
+
The color may be represented as RGB or HEX
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
isColorDarker(color1: string, color2: string)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Color Lighten Darken Service
|
|
110
|
+
|
|
111
|
+
This function takes a color and percentage of lightness/darkness and returns the new color. The amount is a value between 0-1. This function changes the HSL of the color keeping the saturation values.
|
|
112
|
+
|
|
113
|
+
Example: .5 is 50%.
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
lighten(color: string, amount: number)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
darken(color: string, amount: number)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Generate Random Color Service
|
|
124
|
+
|
|
125
|
+
This function takes a color '#3498db' and lightens the color by 20% and also darkens the color by 20%.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
const color = '#3498db'; // Your color
|
|
129
|
+
const lighterColor = lighten(color, 0.2); // 20% lighter
|
|
130
|
+
const darkerColor = darken(color, 0.2); // 20% darker
|
|
131
|
+
|
|
132
|
+
console.log(lighterColor, darkerColor);
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
# Color Grabber
|
|
136
|
+
|
|
137
|
+
This Angular Directive when applied to a div will get the average color of the provided url of an image and then change the background color to that color. Any test inside the div will be colored white or black based on the average color of the image that best suites it.
|
|
138
|
+
|
|
139
|
+
## Usage
|
|
140
|
+
|
|
141
|
+
Because this is a Directive - import the `ColorUtilitiesModule`
|
|
142
|
+
In the following example, the mat-card container has the `colorGrab` directive applied.
|
|
143
|
+
|
|
144
|
+
The `[imageUrl]="image"` is the image to grab the color from.
|
|
145
|
+
|
|
146
|
+
The `[light]="'#FFFFFF'"` is the light color to use if the average color is dark.
|
|
147
|
+
The `[dark]="'#000000'"` is the dark color to use if the average color is light.
|
|
148
|
+
|
|
149
|
+
The mat-card contaner background color will change to this color
|
|
150
|
+
|
|
151
|
+
The Text inside this container will also change ether to black or white depending what suites best based on that colors image.
|
|
152
|
+
|
|
153
|
+
To use in the directive, use the following
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
image = "https://picsum.photos/id/1/5616/3744"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
<mat-card style="margin: 8px;"
|
|
161
|
+
colorGrab [imageUrl]="image" [light]="'rgb(220, 220, 220)'" [dark]="'rgb(47, 79, 79)'"
|
|
162
|
+
class="box"
|
|
163
|
+
>
|
|
164
|
+
<h3>{{ item.author }}</h3>
|
|
165
|
+
<img [src]="image" width="160" height="120" style="object-fit: cover;">
|
|
166
|
+
</mat-card>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Paramiter
|
|
170
|
+
|
|
171
|
+
> imageUrl - provide the full URL of the image (png, jpg)
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
colorGrab [imageUrl]="item.download_url"
|
|
175
|
+
```
|
|
176
|
+
|
|
Binary file
|
|
@@ -0,0 +1,769 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Input, Directive, Injectable, inject, Component, EventEmitter, HostListener, Output, NgModule } from '@angular/core';
|
|
3
|
+
import * as i2 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
6
|
+
import * as i1 from '@angular/material/divider';
|
|
7
|
+
import { MatDividerModule } from '@angular/material/divider';
|
|
8
|
+
import { BehaviorSubject } from 'rxjs';
|
|
9
|
+
|
|
10
|
+
class ColorGrabberDirective {
|
|
11
|
+
constructor(el) {
|
|
12
|
+
this.el = el;
|
|
13
|
+
}
|
|
14
|
+
ngOnInit() {
|
|
15
|
+
const canvas = document.createElement('canvas');
|
|
16
|
+
canvas.width = 1;
|
|
17
|
+
canvas.height = 1;
|
|
18
|
+
this.ctx = canvas.getContext('2d');
|
|
19
|
+
const img = new Image();
|
|
20
|
+
img.src = this.imageUrl || '';
|
|
21
|
+
img.setAttribute('crossOrigin', '');
|
|
22
|
+
img.onload = () => {
|
|
23
|
+
this.ctx?.drawImage(img, 0, 0, 1, 1);
|
|
24
|
+
const imageData = this.ctx?.getImageData(0, 0, 1, 1);
|
|
25
|
+
if (imageData && imageData.data) {
|
|
26
|
+
const i = imageData.data;
|
|
27
|
+
const rgbColor = `rgba(${i[0]},${i[1]},${i[2]},${i[3]})`;
|
|
28
|
+
const hexColor = "#" + ((1 << 24) + (i[0] << 16) + (i[1] << 8) + i[2]).toString(16).slice(1);
|
|
29
|
+
const textColor = this.textColorBasedOnBgColor(hexColor, this.light, this.dark);
|
|
30
|
+
const hsv = this.RGB2HSV({ r: i[0], g: i[1], b: i[2] });
|
|
31
|
+
hsv.hue = this.HueShift(hsv.hue, 135.0);
|
|
32
|
+
const secondaryColor = this.HSV2RGB(hsv);
|
|
33
|
+
const highlightColor = this.lightenDarkenColor(secondaryColor.hex, 50);
|
|
34
|
+
this.el.nativeElement.style.backgroundColor = rgbColor;
|
|
35
|
+
this.el.nativeElement.style.color = textColor;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.error("Failed to get image data.");
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
textColorBasedOnBgColor(bgColor, lightColor = '#FFFFFF', darkColor = '#000000') {
|
|
43
|
+
const color = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
44
|
+
const r = parseInt(color.substring(0, 2), 16); // hexToR
|
|
45
|
+
const g = parseInt(color.substring(2, 4), 16); // hexToG
|
|
46
|
+
const b = parseInt(color.substring(4, 6), 16); // hexToB
|
|
47
|
+
const uicolors = [r / 255, g / 255, b / 255];
|
|
48
|
+
const c = uicolors.map((col) => {
|
|
49
|
+
if (col <= 0.03928)
|
|
50
|
+
return col / 12.92;
|
|
51
|
+
return Math.pow((col + 0.055) / 1.055, 2.4);
|
|
52
|
+
});
|
|
53
|
+
const L = (0.2126 * c[0]) + (0.7152 * c[1]) + (0.0722 * c[2]);
|
|
54
|
+
return (L > 0.179) ? darkColor : lightColor;
|
|
55
|
+
}
|
|
56
|
+
RGB2HSV(rgb) {
|
|
57
|
+
const hsv = { saturation: 0, hue: 0, value: 0 };
|
|
58
|
+
const max = this.max3(rgb.r, rgb.g, rgb.b);
|
|
59
|
+
const dif = max - this.min3(rgb.r, rgb.g, rgb.b);
|
|
60
|
+
hsv.saturation = (max == 0.0) ? 0 : (100 * dif / max);
|
|
61
|
+
if (hsv.saturation == 0) {
|
|
62
|
+
hsv.hue = 0;
|
|
63
|
+
}
|
|
64
|
+
else if (rgb.r == max) {
|
|
65
|
+
hsv.hue = 60.0 * (rgb.g - rgb.b) / dif;
|
|
66
|
+
}
|
|
67
|
+
else if (rgb.g == max) {
|
|
68
|
+
hsv.hue = 120.0 + 60.0 * (rgb.b - rgb.r) / dif;
|
|
69
|
+
}
|
|
70
|
+
else if (rgb.b == max) {
|
|
71
|
+
hsv.hue = 240.0 + 60.0 * (rgb.r - rgb.g) / dif;
|
|
72
|
+
}
|
|
73
|
+
if (hsv.hue < 0.0)
|
|
74
|
+
hsv.hue += 360.0;
|
|
75
|
+
hsv.value = Math.round(max * 100 / 255);
|
|
76
|
+
hsv.hue = Math.round(hsv.hue);
|
|
77
|
+
hsv.saturation = Math.round(hsv.saturation);
|
|
78
|
+
return hsv;
|
|
79
|
+
}
|
|
80
|
+
HSV2RGB(hsv) {
|
|
81
|
+
const rgb = { r: 0, g: 0, b: 0 };
|
|
82
|
+
if (hsv.saturation == 0) {
|
|
83
|
+
rgb.r = rgb.g = rgb.b = Math.round(hsv.value * 2.55);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
hsv.hue /= 60;
|
|
87
|
+
hsv.saturation /= 100;
|
|
88
|
+
hsv.value /= 100;
|
|
89
|
+
const i = Math.floor(hsv.hue);
|
|
90
|
+
const f = hsv.hue - i;
|
|
91
|
+
const p = hsv.value * (1 - hsv.saturation);
|
|
92
|
+
const q = hsv.value * (1 - hsv.saturation * f);
|
|
93
|
+
const t = hsv.value * (1 - hsv.saturation * (1 - f));
|
|
94
|
+
switch (i) {
|
|
95
|
+
case 0:
|
|
96
|
+
rgb.r = hsv.value;
|
|
97
|
+
rgb.g = t;
|
|
98
|
+
rgb.b = p;
|
|
99
|
+
break;
|
|
100
|
+
case 1:
|
|
101
|
+
rgb.r = q;
|
|
102
|
+
rgb.g = hsv.value;
|
|
103
|
+
rgb.b = p;
|
|
104
|
+
break;
|
|
105
|
+
case 2:
|
|
106
|
+
rgb.r = p;
|
|
107
|
+
rgb.g = hsv.value;
|
|
108
|
+
rgb.b = t;
|
|
109
|
+
break;
|
|
110
|
+
case 3:
|
|
111
|
+
rgb.r = p;
|
|
112
|
+
rgb.g = q;
|
|
113
|
+
rgb.b = hsv.value;
|
|
114
|
+
break;
|
|
115
|
+
case 4:
|
|
116
|
+
rgb.r = t;
|
|
117
|
+
rgb.g = p;
|
|
118
|
+
rgb.b = hsv.value;
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
rgb.r = hsv.value;
|
|
122
|
+
rgb.g = p;
|
|
123
|
+
rgb.b = q;
|
|
124
|
+
}
|
|
125
|
+
rgb.r = Math.round(rgb.r * 255);
|
|
126
|
+
rgb.g = Math.round(rgb.g * 255);
|
|
127
|
+
rgb.b = Math.round(rgb.b * 255);
|
|
128
|
+
}
|
|
129
|
+
const rgbColor = `rgba(${rgb.r},${rgb.g},${rgb.b},${1})`;
|
|
130
|
+
const hexColor = "#" + ((1 << 24) + (rgb.r << 16) + (rgb.g << 8) + rgb.b).toString(16).slice(1);
|
|
131
|
+
return { rgb: rgbColor, hex: hexColor };
|
|
132
|
+
}
|
|
133
|
+
HueShift(h, s) {
|
|
134
|
+
h += s;
|
|
135
|
+
while (h >= 360.0)
|
|
136
|
+
h -= 360.0;
|
|
137
|
+
while (h < 0.0)
|
|
138
|
+
h += 360.0;
|
|
139
|
+
return h;
|
|
140
|
+
}
|
|
141
|
+
min3(a, b, c) {
|
|
142
|
+
return (a < b) ? ((a < c) ? a : c) : ((b < c) ? b : c);
|
|
143
|
+
}
|
|
144
|
+
max3(a, b, c) {
|
|
145
|
+
return (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c);
|
|
146
|
+
}
|
|
147
|
+
lightenDarkenColor(colorCode, amount) {
|
|
148
|
+
var usePound = false;
|
|
149
|
+
if (colorCode[0] == "#") {
|
|
150
|
+
colorCode = colorCode.slice(1);
|
|
151
|
+
usePound = true;
|
|
152
|
+
}
|
|
153
|
+
var num = parseInt(colorCode, 16);
|
|
154
|
+
var r = (num >> 16) + amount;
|
|
155
|
+
if (r > 255) {
|
|
156
|
+
r = 255;
|
|
157
|
+
}
|
|
158
|
+
else if (r < 0) {
|
|
159
|
+
r = 0;
|
|
160
|
+
}
|
|
161
|
+
var b = ((num >> 8) & 0x00FF) + amount;
|
|
162
|
+
if (b > 255) {
|
|
163
|
+
b = 255;
|
|
164
|
+
}
|
|
165
|
+
else if (b < 0) {
|
|
166
|
+
b = 0;
|
|
167
|
+
}
|
|
168
|
+
var g = (num & 0x0000FF) + amount;
|
|
169
|
+
if (g > 255) {
|
|
170
|
+
g = 255;
|
|
171
|
+
}
|
|
172
|
+
else if (g < 0) {
|
|
173
|
+
g = 0;
|
|
174
|
+
}
|
|
175
|
+
return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
|
|
176
|
+
}
|
|
177
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorGrabberDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
178
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: ColorGrabberDirective, selector: "[colorGrabber]", inputs: { imageUrl: "imageUrl", light: "light", dark: "dark" }, ngImport: i0 }); }
|
|
179
|
+
}
|
|
180
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorGrabberDirective, decorators: [{
|
|
181
|
+
type: Directive,
|
|
182
|
+
args: [{
|
|
183
|
+
selector: '[colorGrabber]',
|
|
184
|
+
standalone: false
|
|
185
|
+
}]
|
|
186
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { imageUrl: [{
|
|
187
|
+
type: Input
|
|
188
|
+
}], light: [{
|
|
189
|
+
type: Input
|
|
190
|
+
}], dark: [{
|
|
191
|
+
type: Input
|
|
192
|
+
}] } });
|
|
193
|
+
|
|
194
|
+
class ColorConversionService {
|
|
195
|
+
constructor() {
|
|
196
|
+
this.componentToHex = (c) => {
|
|
197
|
+
const hex = c.toString(16);
|
|
198
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
rgbToHex(rgb) {
|
|
202
|
+
if (rgb === null || rgb.length !== 3 || rgb.some(value => value < 0 || value > 255))
|
|
203
|
+
return '';
|
|
204
|
+
const [r, g, b] = rgb;
|
|
205
|
+
const hexR = this.componentToHex(r);
|
|
206
|
+
const hexG = this.componentToHex(g);
|
|
207
|
+
const hexB = this.componentToHex(b);
|
|
208
|
+
return "#" + hexR + hexG + hexB;
|
|
209
|
+
}
|
|
210
|
+
hexToRgb(hex) {
|
|
211
|
+
if (hex === null || hex === undefined)
|
|
212
|
+
return [];
|
|
213
|
+
hex = (hex.length === 3) ? hex + hex : hex;
|
|
214
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
215
|
+
return result ? [
|
|
216
|
+
parseInt(result[1], 16),
|
|
217
|
+
parseInt(result[2], 16),
|
|
218
|
+
parseInt(result[3], 16)
|
|
219
|
+
] : [];
|
|
220
|
+
}
|
|
221
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorConversionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
222
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorConversionService, providedIn: 'root' }); }
|
|
223
|
+
}
|
|
224
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorConversionService, decorators: [{
|
|
225
|
+
type: Injectable,
|
|
226
|
+
args: [{
|
|
227
|
+
providedIn: 'root'
|
|
228
|
+
}]
|
|
229
|
+
}] });
|
|
230
|
+
|
|
231
|
+
class ColorPalletteService {
|
|
232
|
+
constructor(colorConversionService) {
|
|
233
|
+
this.colorConversionService = colorConversionService;
|
|
234
|
+
// define image path
|
|
235
|
+
// this.colorSelectionService.getColorsFromImage('../assets/sample2.jpg')
|
|
236
|
+
// get colors
|
|
237
|
+
// this.colorSelectionService.palette.subscribe(data => this.palette = data)
|
|
238
|
+
// sample html
|
|
239
|
+
// <div *ngFor="let color of palette">
|
|
240
|
+
// <div style="display: flex;">
|
|
241
|
+
// <div
|
|
242
|
+
// class="box"
|
|
243
|
+
// [style.background-color]="color.color"
|
|
244
|
+
// >
|
|
245
|
+
// Color
|
|
246
|
+
// </div>
|
|
247
|
+
// <div
|
|
248
|
+
// class="box"
|
|
249
|
+
// [style.background-color]="color.complementaryColor"
|
|
250
|
+
// >
|
|
251
|
+
// Complementary
|
|
252
|
+
// </div>
|
|
253
|
+
// </div>
|
|
254
|
+
// </div>
|
|
255
|
+
// CSS
|
|
256
|
+
// .box {
|
|
257
|
+
// width: 100px;
|
|
258
|
+
// height: 100px;
|
|
259
|
+
// border: solid thin black;
|
|
260
|
+
// color: black;
|
|
261
|
+
// margin: 4px;
|
|
262
|
+
// padding: 16px;
|
|
263
|
+
// display: flex;
|
|
264
|
+
// flex-wrap: wrap;
|
|
265
|
+
// align-content: center;
|
|
266
|
+
// justify-content: center;
|
|
267
|
+
// }
|
|
268
|
+
this.palette = new BehaviorSubject([]);
|
|
269
|
+
this.palette$ = this.palette.asObservable();
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Retrieves a color palette from an image at the specified path.
|
|
273
|
+
*
|
|
274
|
+
* @param imagePath - The path to the image to extract the color palette from.
|
|
275
|
+
* @param colors - The number of colors to include in the palette (default is 3).
|
|
276
|
+
* @returns An observable that emits the generated color palette.
|
|
277
|
+
*/
|
|
278
|
+
getColorsFromImage(imagePath, colors = 3) {
|
|
279
|
+
const image = new Image();
|
|
280
|
+
image.src = imagePath;
|
|
281
|
+
image.onload = () => {
|
|
282
|
+
const data = this.generateColorPalette(image, colors) || [];
|
|
283
|
+
this.palette.next(data);
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Generates a color palette from an image.
|
|
288
|
+
*
|
|
289
|
+
* @param image - The HTML image element to extract the color palette from.
|
|
290
|
+
* @param colorCount - The number of colors to include in the palette (default is 6).
|
|
291
|
+
* @returns An array of color objects, each with a hex color and a complementary hex color.
|
|
292
|
+
*/
|
|
293
|
+
generateColorPalette(image, colorCount = 6) {
|
|
294
|
+
const canvas = document.createElement("canvas");
|
|
295
|
+
const context = canvas.getContext("2d");
|
|
296
|
+
if (!context)
|
|
297
|
+
return;
|
|
298
|
+
canvas.width = image.width;
|
|
299
|
+
canvas.height = image.height;
|
|
300
|
+
context.drawImage(image, 0, 0);
|
|
301
|
+
// Get the image data
|
|
302
|
+
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
303
|
+
const pixels = imageData.data;
|
|
304
|
+
const pixelCount = imageData.width * imageData.height;
|
|
305
|
+
// Build an array of RGB colors
|
|
306
|
+
const colors = [];
|
|
307
|
+
for (let i = 0; i < pixelCount; i++) {
|
|
308
|
+
const offset = i * 4;
|
|
309
|
+
const r = pixels[offset];
|
|
310
|
+
const g = pixels[offset + 1];
|
|
311
|
+
const b = pixels[offset + 2];
|
|
312
|
+
colors.push([r, g, b]);
|
|
313
|
+
}
|
|
314
|
+
// Apply color quantization using k-means clustering
|
|
315
|
+
const quantizedColors = this.kMeansColorQuantization(colors, colorCount);
|
|
316
|
+
// Order colors by luminance
|
|
317
|
+
quantizedColors.sort((color1, color2) => {
|
|
318
|
+
const luminance1 = this.getLuminance(color1);
|
|
319
|
+
const luminance2 = this.getLuminance(color2);
|
|
320
|
+
return luminance2 - luminance1;
|
|
321
|
+
});
|
|
322
|
+
const palette = quantizedColors.map((color) => {
|
|
323
|
+
const complementaryColor = color.map((component) => 255 - component);
|
|
324
|
+
const hexColor = this.colorConversionService.rgbToHex(color);
|
|
325
|
+
const hexComplementaryColor = this.colorConversionService.rgbToHex(complementaryColor);
|
|
326
|
+
return { color: hexColor, complementaryColor: hexComplementaryColor };
|
|
327
|
+
});
|
|
328
|
+
return palette;
|
|
329
|
+
}
|
|
330
|
+
getLuminance(color) {
|
|
331
|
+
const [r, g, b] = color;
|
|
332
|
+
return 0.299 * r + 0.587 * g + 0.114 * b;
|
|
333
|
+
}
|
|
334
|
+
calculateColorDistance(color1, color2) {
|
|
335
|
+
const [r1, g1, b1] = color1;
|
|
336
|
+
const [r2, g2, b2] = color2;
|
|
337
|
+
const dr = r2 - r1;
|
|
338
|
+
const dg = g2 - g1;
|
|
339
|
+
const db = b2 - b1;
|
|
340
|
+
return Math.sqrt(dr * dr + dg * dg + db * db);
|
|
341
|
+
}
|
|
342
|
+
calculateMeanColor(colors) {
|
|
343
|
+
let sumR = 0;
|
|
344
|
+
let sumG = 0;
|
|
345
|
+
let sumB = 0;
|
|
346
|
+
for (let i = 0; i < colors.length; i++) {
|
|
347
|
+
const [r, g, b] = colors[i];
|
|
348
|
+
sumR += r;
|
|
349
|
+
sumG += g;
|
|
350
|
+
sumB += b;
|
|
351
|
+
}
|
|
352
|
+
const meanR = Math.round(sumR / colors.length);
|
|
353
|
+
const meanG = Math.round(sumG / colors.length);
|
|
354
|
+
const meanB = Math.round(sumB / colors.length);
|
|
355
|
+
return [meanR, meanG, meanB];
|
|
356
|
+
}
|
|
357
|
+
kMeansColorQuantization(colors, k) {
|
|
358
|
+
let clusterCenters = [];
|
|
359
|
+
for (let i = 0; i < k; i++) {
|
|
360
|
+
const randomColor = colors[Math.floor(Math.random() * colors.length)];
|
|
361
|
+
clusterCenters.push(randomColor);
|
|
362
|
+
}
|
|
363
|
+
let clusters = [];
|
|
364
|
+
for (let i = 0; i < colors.length; i++) {
|
|
365
|
+
const color = colors[i];
|
|
366
|
+
let minDistance = Infinity;
|
|
367
|
+
let nearestCenter = null;
|
|
368
|
+
for (let j = 0; j < clusterCenters.length; j++) {
|
|
369
|
+
const center = clusterCenters[j];
|
|
370
|
+
const distance = this.calculateColorDistance(color, center);
|
|
371
|
+
if (distance < minDistance) {
|
|
372
|
+
minDistance = distance;
|
|
373
|
+
nearestCenter = center;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
clusters.push({ color, center: nearestCenter });
|
|
377
|
+
}
|
|
378
|
+
let updatedCenters = [];
|
|
379
|
+
for (let i = 0; i < clusterCenters.length; i++) {
|
|
380
|
+
const center = clusterCenters[i];
|
|
381
|
+
const clusterColors = clusters.filter(c => c.center === center).map(c => c.color);
|
|
382
|
+
if (clusterColors.length > 0) {
|
|
383
|
+
const updatedCenter = this.calculateMeanColor(clusterColors);
|
|
384
|
+
updatedCenters.push(updatedCenter);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return updatedCenters;
|
|
388
|
+
}
|
|
389
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorPalletteService, deps: [{ token: ColorConversionService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
390
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorPalletteService, providedIn: 'root' }); }
|
|
391
|
+
}
|
|
392
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorPalletteService, decorators: [{
|
|
393
|
+
type: Injectable,
|
|
394
|
+
args: [{
|
|
395
|
+
providedIn: 'root'
|
|
396
|
+
}]
|
|
397
|
+
}], ctorParameters: () => [{ type: ColorConversionService }] });
|
|
398
|
+
|
|
399
|
+
class TextColorService {
|
|
400
|
+
constructor(colorConversionService) {
|
|
401
|
+
this.colorConversionService = colorConversionService;
|
|
402
|
+
}
|
|
403
|
+
textColorForBgColor(bgColor, lightColor, darkColor) {
|
|
404
|
+
const UIColors = this.fixColor(bgColor);
|
|
405
|
+
const r = UIColors[0];
|
|
406
|
+
const g = UIColors[1];
|
|
407
|
+
const b = UIColors[2];
|
|
408
|
+
return ((r * 0.299 + g * 0.587 + b * 0.114) > 149) ? darkColor : lightColor;
|
|
409
|
+
}
|
|
410
|
+
darkerColor(color1, color2) {
|
|
411
|
+
return this.isColorDarker(color1, color2) ? color1 : color2;
|
|
412
|
+
}
|
|
413
|
+
isColorDarker(color1, color2) {
|
|
414
|
+
const newColor1 = this.fixColor(color1);
|
|
415
|
+
const newColor2 = this.fixColor(color2);
|
|
416
|
+
const luminance1 = this.calculateLuminance(newColor1[0], newColor1[1], newColor1[2]);
|
|
417
|
+
const luminance2 = this.calculateLuminance(newColor2[0], newColor2[1], newColor2[2]);
|
|
418
|
+
return luminance1 < luminance2;
|
|
419
|
+
}
|
|
420
|
+
lighterColor(color1, color2) {
|
|
421
|
+
return (this.isColorLighter(color1, color2)) ? color1 : color2;
|
|
422
|
+
}
|
|
423
|
+
isColorLighter(color1, color2) {
|
|
424
|
+
const newColor1 = this.fixColor(color1);
|
|
425
|
+
const newColor2 = this.fixColor(color2);
|
|
426
|
+
const luminance1 = this.calculateLuminance(newColor1[0], newColor1[1], newColor1[2]);
|
|
427
|
+
const luminance2 = this.calculateLuminance(newColor2[0], newColor2[1], newColor2[2]);
|
|
428
|
+
return (luminance1 > luminance2);
|
|
429
|
+
}
|
|
430
|
+
calculateLuminance(r, g, b) {
|
|
431
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
432
|
+
}
|
|
433
|
+
fixColor(color) {
|
|
434
|
+
// Remove leading hash if present
|
|
435
|
+
const sanitizedColor = color.startsWith('#') ? color.slice(1) : color;
|
|
436
|
+
// Validate if the color is a valid hex (3 or 6 characters)
|
|
437
|
+
if (!this.isValidHex(sanitizedColor)) {
|
|
438
|
+
return this.parseRgb(sanitizedColor); // If not hex, attempt to parse as RGB
|
|
439
|
+
}
|
|
440
|
+
// Convert hex to RGB
|
|
441
|
+
const rgb = this.hexToRgb(sanitizedColor);
|
|
442
|
+
return rgb;
|
|
443
|
+
}
|
|
444
|
+
// Helper function to validate if a string is a valid 3 or 6 digit hex code
|
|
445
|
+
isValidHex(color) {
|
|
446
|
+
const hexRegex = /^[A-Fa-f0-9]{3}$|^[A-Fa-f0-9]{6}$/i;
|
|
447
|
+
return hexRegex.test(color);
|
|
448
|
+
}
|
|
449
|
+
// Helper function to convert a 3 or 6 digit hex color to RGB
|
|
450
|
+
hexToRgb(hex) {
|
|
451
|
+
if (hex.length === 3) {
|
|
452
|
+
hex = hex.split('').map(c => c + c).join(''); // Expand shorthand hex to full
|
|
453
|
+
}
|
|
454
|
+
return [
|
|
455
|
+
parseInt(hex.slice(0, 2), 16),
|
|
456
|
+
parseInt(hex.slice(2, 4), 16),
|
|
457
|
+
parseInt(hex.slice(4, 6), 16),
|
|
458
|
+
];
|
|
459
|
+
}
|
|
460
|
+
// Helper function to parse an RGB string (e.g., rgb(255, 0, 0)) into an array
|
|
461
|
+
parseRgb(rgb) {
|
|
462
|
+
const match = rgb.match(/\d+/g);
|
|
463
|
+
return match ? match.map(num => parseInt(num)) : [];
|
|
464
|
+
}
|
|
465
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TextColorService, deps: [{ token: ColorConversionService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
466
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TextColorService, providedIn: 'root' }); }
|
|
467
|
+
}
|
|
468
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TextColorService, decorators: [{
|
|
469
|
+
type: Injectable,
|
|
470
|
+
args: [{
|
|
471
|
+
providedIn: 'root'
|
|
472
|
+
}]
|
|
473
|
+
}], ctorParameters: () => [{ type: ColorConversionService }] });
|
|
474
|
+
|
|
475
|
+
class ColorLightenDarkenService {
|
|
476
|
+
// const color = '#3498db'; // Your color
|
|
477
|
+
// const lighterColor = lighten(color, 0.2); // 20% lighter
|
|
478
|
+
// const darkerColor = darken(color, 0.2); // 20% darker
|
|
479
|
+
// console.log(lighterColor, darkerColor);
|
|
480
|
+
constructor() {
|
|
481
|
+
this.colors = inject(TextColorService);
|
|
482
|
+
}
|
|
483
|
+
lighten(color, amount) {
|
|
484
|
+
const rgb = this.colors.fixColor(color);
|
|
485
|
+
// const rgb = color.match(/\w\w/g)?.map((x) => parseInt(x, 16)) || [];
|
|
486
|
+
// Convert RGB to HSL
|
|
487
|
+
let [r, g, b] = rgb.map((c) => c / 255);
|
|
488
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
489
|
+
let h = 0, s = 0, l = (max + min) / 2;
|
|
490
|
+
if (max !== min) {
|
|
491
|
+
const d = max - min;
|
|
492
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
493
|
+
switch (max) {
|
|
494
|
+
case r:
|
|
495
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
496
|
+
break;
|
|
497
|
+
case g:
|
|
498
|
+
h = (b - r) / d + 2;
|
|
499
|
+
break;
|
|
500
|
+
case b:
|
|
501
|
+
h = (r - g) / d + 4;
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
h /= 6;
|
|
505
|
+
}
|
|
506
|
+
// Modify the lightness and clamp it to [0, 1]
|
|
507
|
+
l = Math.min(1, l + amount);
|
|
508
|
+
// Convert HSL back to RGB
|
|
509
|
+
if (s === 0) {
|
|
510
|
+
r = g = b = l; // achromatic
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
const hue2rgb = (p, q, t) => {
|
|
514
|
+
if (t < 0)
|
|
515
|
+
t += 1;
|
|
516
|
+
if (t > 1)
|
|
517
|
+
t -= 1;
|
|
518
|
+
if (t < 1 / 6)
|
|
519
|
+
return p + (q - p) * 6 * t;
|
|
520
|
+
if (t < 1 / 2)
|
|
521
|
+
return q;
|
|
522
|
+
if (t < 2 / 3)
|
|
523
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
524
|
+
return p;
|
|
525
|
+
};
|
|
526
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
527
|
+
const p = 2 * l - q;
|
|
528
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
529
|
+
g = hue2rgb(p, q, h);
|
|
530
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
531
|
+
}
|
|
532
|
+
// Convert RGB back to hexadecimal color
|
|
533
|
+
const toHex = (x) => Math.round(x * 255)
|
|
534
|
+
.toString(16)
|
|
535
|
+
.padStart(2, '0');
|
|
536
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
537
|
+
}
|
|
538
|
+
darken(color, amount) {
|
|
539
|
+
return this.lighten(color, -amount);
|
|
540
|
+
}
|
|
541
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorLightenDarkenService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
542
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorLightenDarkenService, providedIn: 'root' }); }
|
|
543
|
+
}
|
|
544
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorLightenDarkenService, decorators: [{
|
|
545
|
+
type: Injectable,
|
|
546
|
+
args: [{
|
|
547
|
+
providedIn: 'root'
|
|
548
|
+
}]
|
|
549
|
+
}], ctorParameters: () => [] });
|
|
550
|
+
|
|
551
|
+
class ColorSchemeService {
|
|
552
|
+
constructor() { }
|
|
553
|
+
/**
|
|
554
|
+
* Generates a random hexadecimal color code.
|
|
555
|
+
*
|
|
556
|
+
* This function generates a random hue value between 0 and 360 degrees, and random saturation and lightness values between 50% and 100%. It then converts the HSL values to RGB values using the `hslToRgb` function, and finally converts the RGB values to a hexadecimal color code using the `rgbToHex` function.
|
|
557
|
+
*
|
|
558
|
+
* @returns A hexadecimal color code in the format "#RRGGBB".
|
|
559
|
+
*/
|
|
560
|
+
generateRandomColor() {
|
|
561
|
+
// Generate a random hue between 0 and 360 (representing degrees on the color wheel)
|
|
562
|
+
const hue = Math.floor(Math.random() * 360);
|
|
563
|
+
// Generate random saturation and lightness values between 50% and 100%
|
|
564
|
+
const saturation = Math.floor(Math.random() * 51) + 50;
|
|
565
|
+
const lightness = Math.floor(Math.random() * 51) + 50;
|
|
566
|
+
// Convert HSL values to RGB values
|
|
567
|
+
const rgbColor = this.hslToRgb(hue, saturation, lightness);
|
|
568
|
+
// Convert RGB values to hexadecimal color code
|
|
569
|
+
const hexColor = this.rgbToHex(rgbColor.r, rgbColor.g, rgbColor.b);
|
|
570
|
+
return hexColor;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Converts HSL (Hue, Saturation, Lightness) color values to RGB (Red, Green, Blue) color values.
|
|
574
|
+
*
|
|
575
|
+
* @param h - The hue value, ranging from 0 to 360 degrees.
|
|
576
|
+
* @param s - The saturation value, ranging from 0 to 100 percent.
|
|
577
|
+
* @param l - The lightness value, ranging from 0 to 100 percent.
|
|
578
|
+
* @returns An object with the RGB color values, where each value is between 0 and 255.
|
|
579
|
+
*/
|
|
580
|
+
hslToRgb(h, s, l) {
|
|
581
|
+
h /= 360;
|
|
582
|
+
s /= 100;
|
|
583
|
+
l /= 100;
|
|
584
|
+
let r, g, b;
|
|
585
|
+
if (s === 0) {
|
|
586
|
+
r = g = b = l; // Achromatic color (gray)
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
const hueToRgb = (p, q, t) => {
|
|
590
|
+
if (t < 0)
|
|
591
|
+
t += 1;
|
|
592
|
+
if (t > 1)
|
|
593
|
+
t -= 1;
|
|
594
|
+
if (t < 1 / 6)
|
|
595
|
+
return p + (q - p) * 6 * t;
|
|
596
|
+
if (t < 1 / 2)
|
|
597
|
+
return q;
|
|
598
|
+
if (t < 2 / 3)
|
|
599
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
600
|
+
return p;
|
|
601
|
+
};
|
|
602
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
603
|
+
const p = 2 * l - q;
|
|
604
|
+
r = Math.round(hueToRgb(p, q, h + 1 / 3) * 255);
|
|
605
|
+
g = Math.round(hueToRgb(p, q, h) * 255);
|
|
606
|
+
b = Math.round(hueToRgb(p, q, h - 1 / 3) * 255);
|
|
607
|
+
}
|
|
608
|
+
return { r, g, b };
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Converts RGB color values to a hexadecimal color string.
|
|
612
|
+
*
|
|
613
|
+
* @param r - The red color value, between 0 and 255.
|
|
614
|
+
* @param g - The green color value, between 0 and 255.
|
|
615
|
+
* @param b - The blue color value, between 0 and 255.
|
|
616
|
+
* @returns A hexadecimal color string in the format "#RRGGBB".
|
|
617
|
+
*/
|
|
618
|
+
rgbToHex(r, g, b) {
|
|
619
|
+
const componentToHex = (c) => {
|
|
620
|
+
const hex = c.toString(16);
|
|
621
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
622
|
+
};
|
|
623
|
+
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Adjusts a hexadecimal color value by a given percentage.
|
|
627
|
+
*
|
|
628
|
+
* @param hexColor - The hexadecimal color value to adjust.
|
|
629
|
+
* @param percentage - The percentage to adjust the color by, ranging from -100 to 100.
|
|
630
|
+
* @returns The adjusted hexadecimal color value.
|
|
631
|
+
*/
|
|
632
|
+
adjustHexColor(hexColor, percentage) {
|
|
633
|
+
// Remove the "#" symbol if present
|
|
634
|
+
hexColor = hexColor.replace("#", "");
|
|
635
|
+
// Convert the hex color to RGB values
|
|
636
|
+
const red = parseInt(hexColor.substring(0, 2), 16);
|
|
637
|
+
const green = parseInt(hexColor.substring(2, 4), 16);
|
|
638
|
+
const blue = parseInt(hexColor.substring(4, 6), 16);
|
|
639
|
+
// Calculate the adjustment amount based on the percentage
|
|
640
|
+
const adjustAmount = Math.round(255 * (percentage / 100));
|
|
641
|
+
// Adjust the RGB values
|
|
642
|
+
const adjustedRed = this.clamp(red + adjustAmount);
|
|
643
|
+
const adjustedGreen = this.clamp(green + adjustAmount);
|
|
644
|
+
const adjustedBlue = this.clamp(blue + adjustAmount);
|
|
645
|
+
// Convert the adjusted RGB values back to hex
|
|
646
|
+
const adjustedHexColor = `#${(adjustedRed).toString(16).padStart(2, '0')}${(adjustedGreen).toString(16).padStart(2, '0')}${(adjustedBlue).toString(16).padStart(2, '0')}`;
|
|
647
|
+
return adjustedHexColor;
|
|
648
|
+
}
|
|
649
|
+
clamp(value) {
|
|
650
|
+
return Math.max(0, Math.min(value, 255));
|
|
651
|
+
}
|
|
652
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorSchemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
653
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorSchemeService, providedIn: 'root' }); }
|
|
654
|
+
}
|
|
655
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorSchemeService, decorators: [{
|
|
656
|
+
type: Injectable,
|
|
657
|
+
args: [{
|
|
658
|
+
providedIn: 'root'
|
|
659
|
+
}]
|
|
660
|
+
}], ctorParameters: () => [] });
|
|
661
|
+
|
|
662
|
+
class ColorUtilitiesDemoComponent {
|
|
663
|
+
constructor() {
|
|
664
|
+
this.colorConversionService = inject(ColorConversionService);
|
|
665
|
+
this.colorLightenDarkenService = inject(ColorLightenDarkenService);
|
|
666
|
+
this.colorPalletteService = inject(ColorPalletteService);
|
|
667
|
+
this.textColorService = inject(TextColorService);
|
|
668
|
+
this.colorSchemeService = inject(ColorSchemeService);
|
|
669
|
+
this.HEX = this.colorConversionService.rgbToHex([12, 56, 128]);
|
|
670
|
+
this.RGB = `rgb(${this.colorConversionService.hexToRgb('#AA11BB')})`;
|
|
671
|
+
this.lighten = this.colorLightenDarkenService.lighten('#AA11BB', .25);
|
|
672
|
+
this.darken = this.colorLightenDarkenService.darken('#AA11BB', .25);
|
|
673
|
+
this.colorIsDarker = this.textColorService.isColorDarker(this.lighten, this.darken);
|
|
674
|
+
this.darkBk = this.textColorService.textColorForBgColor(this.HEX, this.lighten, this.darken);
|
|
675
|
+
this.lightBk = this.textColorService.textColorForBgColor('whitesmoke', this.lighten, this.darken);
|
|
676
|
+
this.colors$ = this.colorPalletteService.palette$;
|
|
677
|
+
this.colorPick = this.colorSchemeService.generateRandomColor();
|
|
678
|
+
this.colorPickDarker = this.colorSchemeService.adjustHexColor(this.colorPick, -25);
|
|
679
|
+
this.colorPickLighter = this.colorSchemeService.adjustHexColor(this.colorPick, 25);
|
|
680
|
+
}
|
|
681
|
+
ngOnInit() {
|
|
682
|
+
// define image path
|
|
683
|
+
this.img = 'assets/picture.webp';
|
|
684
|
+
this.colorPalletteService.getColorsFromImage(this.img, 8);
|
|
685
|
+
}
|
|
686
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorUtilitiesDemoComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
687
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ColorUtilitiesDemoComponent, selector: "app-color-utilities-demo", ngImport: i0, template: "<div style=\"margin: 2rem;\">\n\n <h1>Color Conversion Service</h1>\n <div style=\"display: flex; flex-direction: column; gap: 1rem;\">\n <div style=\"display: flex\">\n <div style=\"padding-top: .5rem; margin-right: .5rem;\">rgbToHex: {{ HEX }}</div>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"HEX\"></div>\n </div>\n\n <div style=\"display: flex\">\n <div style=\"padding-top: .5rem; margin-right: .5rem;\"> hexToRgb: {{ RGB }} </div>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"RGB\"></div>\n </div>\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Color Light/Darken Service</h1>\n\n <div style=\"display: flex; flex-direction: column; gap: 1rem;\">\n\n <div style=\"display: flex; gap: 1rem\">\n Original Color: #AA11BB<br>\n <div style=\"width: 32px; height: 32px; background-color: #AA11BB;\"></div>\n Lighten (25%): {{ lighten }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"lighten\"></div>\n Darken (25%): {{ darken }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"darken\"></div>\n </div>\n\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Text Color Utility Services</h1>\n\n <div style=\"display: flex; gap: 1rem; flex-direction: column;\">\n <div style=\"display: flex; gap: 1rem\">\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"darken\"></div>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"lighten\"></div>\n is Darker : {{ colorIsDarker }}\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorIsDarker\"></div>\n </div>\n\n <div style=\"display: flex; gap: 1rem; flex-direction: column;\">\n\n <div>\n Use: {{ lightBk }} for '{{ HEX }}' background-color<br>\n <div style=\"padding: 1rem;\" [style.backgroundColor]=\"HEX\" [style.color]=\"darkBk\">\n Sample Text Color\n </div>\n </div>\n\n <div>\n Use: {{ lightBk }} for 'whitesmoke' background-color<br>\n <div style=\"padding: 1rem; background-color: whitesmoke;\" [style.color]=\"lightBk\">\n Sample Text Color\n </div>\n </div>\n </div>\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Color Schema Services</h1>\n\n <div style=\"display: flex; gap: 1rem\">\n Pick Color: {{ colorPick }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorPick\"></div>\n Lighter Version: {{ colorPickLighter }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorPickLighter\"></div>\n DarkerVersion: {{ colorPickDarker }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorPickDarker\"></div>\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Color Pallette Service</h1>\n Creates Pallette from Image\n <div style=\"display: flex; gap: 2rem;\">\n <div>\n <img [src]=\"img\" height=\"180\">\n </div>\n\n <div style=\"display: flex; gap: .5rem; width: 120px; border: 1px solid black; flex-wrap: wrap; padding: .5rem;\">\n <div>Color Pick</div>\n @for (color of (colors$ | async); track color) {\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"color.color\"></div>\n }\n </div>\n\n <div style=\"display: flex; gap: .5rem; width: 120px; border: 1px solid black; flex-wrap: wrap; padding: .5rem;\">\n <div>Complementary</div>\n @for (color of (colors$ | async); track color) {\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"color.complementaryColor\"></div>\n }\n </div>\n </div>\n\n</div>\n\n", styles: [".box{width:100px;height:100px;border:solid thin black;color:#000;margin:4px;padding:16px;display:flex;flex-wrap:wrap;align-content:center;justify-content:center}\n"], dependencies: [{ kind: "component", type: i1.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }] }); }
|
|
688
|
+
}
|
|
689
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorUtilitiesDemoComponent, decorators: [{
|
|
690
|
+
type: Component,
|
|
691
|
+
args: [{ selector: 'app-color-utilities-demo', standalone: false, template: "<div style=\"margin: 2rem;\">\n\n <h1>Color Conversion Service</h1>\n <div style=\"display: flex; flex-direction: column; gap: 1rem;\">\n <div style=\"display: flex\">\n <div style=\"padding-top: .5rem; margin-right: .5rem;\">rgbToHex: {{ HEX }}</div>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"HEX\"></div>\n </div>\n\n <div style=\"display: flex\">\n <div style=\"padding-top: .5rem; margin-right: .5rem;\"> hexToRgb: {{ RGB }} </div>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"RGB\"></div>\n </div>\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Color Light/Darken Service</h1>\n\n <div style=\"display: flex; flex-direction: column; gap: 1rem;\">\n\n <div style=\"display: flex; gap: 1rem\">\n Original Color: #AA11BB<br>\n <div style=\"width: 32px; height: 32px; background-color: #AA11BB;\"></div>\n Lighten (25%): {{ lighten }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"lighten\"></div>\n Darken (25%): {{ darken }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"darken\"></div>\n </div>\n\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Text Color Utility Services</h1>\n\n <div style=\"display: flex; gap: 1rem; flex-direction: column;\">\n <div style=\"display: flex; gap: 1rem\">\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"darken\"></div>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"lighten\"></div>\n is Darker : {{ colorIsDarker }}\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorIsDarker\"></div>\n </div>\n\n <div style=\"display: flex; gap: 1rem; flex-direction: column;\">\n\n <div>\n Use: {{ lightBk }} for '{{ HEX }}' background-color<br>\n <div style=\"padding: 1rem;\" [style.backgroundColor]=\"HEX\" [style.color]=\"darkBk\">\n Sample Text Color\n </div>\n </div>\n\n <div>\n Use: {{ lightBk }} for 'whitesmoke' background-color<br>\n <div style=\"padding: 1rem; background-color: whitesmoke;\" [style.color]=\"lightBk\">\n Sample Text Color\n </div>\n </div>\n </div>\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Color Schema Services</h1>\n\n <div style=\"display: flex; gap: 1rem\">\n Pick Color: {{ colorPick }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorPick\"></div>\n Lighter Version: {{ colorPickLighter }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorPickLighter\"></div>\n DarkerVersion: {{ colorPickDarker }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorPickDarker\"></div>\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Color Pallette Service</h1>\n Creates Pallette from Image\n <div style=\"display: flex; gap: 2rem;\">\n <div>\n <img [src]=\"img\" height=\"180\">\n </div>\n\n <div style=\"display: flex; gap: .5rem; width: 120px; border: 1px solid black; flex-wrap: wrap; padding: .5rem;\">\n <div>Color Pick</div>\n @for (color of (colors$ | async); track color) {\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"color.color\"></div>\n }\n </div>\n\n <div style=\"display: flex; gap: .5rem; width: 120px; border: 1px solid black; flex-wrap: wrap; padding: .5rem;\">\n <div>Complementary</div>\n @for (color of (colors$ | async); track color) {\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"color.complementaryColor\"></div>\n }\n </div>\n </div>\n\n</div>\n\n", styles: [".box{width:100px;height:100px;border:solid thin black;color:#000;margin:4px;padding:16px;display:flex;flex-wrap:wrap;align-content:center;justify-content:center}\n"] }]
|
|
692
|
+
}], ctorParameters: () => [] });
|
|
693
|
+
|
|
694
|
+
class ColorExtractorDirective {
|
|
695
|
+
constructor(elementRef, renderer) {
|
|
696
|
+
this.elementRef = elementRef;
|
|
697
|
+
this.renderer = renderer;
|
|
698
|
+
this.colorValue = new EventEmitter();
|
|
699
|
+
}
|
|
700
|
+
get currentElement() {
|
|
701
|
+
return window.getComputedStyle(this.elementRef.nativeElement);
|
|
702
|
+
}
|
|
703
|
+
onMouseEnter() {
|
|
704
|
+
// console.log('ENTER', this.currentElement)
|
|
705
|
+
this.colorValue.emit(this.currentElement.getPropertyValue('background-color'));
|
|
706
|
+
}
|
|
707
|
+
onMouseLeave() {
|
|
708
|
+
// console.log('LEAVE', this.currentElement.getPropertyValue('background-color'))
|
|
709
|
+
this.colorValue.emit('white');
|
|
710
|
+
}
|
|
711
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorExtractorDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
712
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: ColorExtractorDirective, selector: "[getColor]", outputs: { colorValue: "colorValue" }, host: { listeners: { "mouseenter": "onMouseEnter()", "mouseleave": "onMouseLeave()" } }, ngImport: i0 }); }
|
|
713
|
+
}
|
|
714
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorExtractorDirective, decorators: [{
|
|
715
|
+
type: Directive,
|
|
716
|
+
args: [{
|
|
717
|
+
selector: '[getColor]',
|
|
718
|
+
standalone: false
|
|
719
|
+
}]
|
|
720
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { colorValue: [{
|
|
721
|
+
type: Output
|
|
722
|
+
}], onMouseEnter: [{
|
|
723
|
+
type: HostListener,
|
|
724
|
+
args: ['mouseenter']
|
|
725
|
+
}], onMouseLeave: [{
|
|
726
|
+
type: HostListener,
|
|
727
|
+
args: ['mouseleave']
|
|
728
|
+
}] } });
|
|
729
|
+
|
|
730
|
+
class ColorUtilHelpersModule {
|
|
731
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorUtilHelpersModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
732
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: ColorUtilHelpersModule, declarations: [ColorUtilitiesDemoComponent,
|
|
733
|
+
ColorGrabberDirective,
|
|
734
|
+
ColorExtractorDirective], imports: [CommonModule,
|
|
735
|
+
MatButtonModule,
|
|
736
|
+
MatDividerModule], exports: [ColorUtilitiesDemoComponent] }); }
|
|
737
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorUtilHelpersModule, imports: [CommonModule,
|
|
738
|
+
MatButtonModule,
|
|
739
|
+
MatDividerModule] }); }
|
|
740
|
+
}
|
|
741
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColorUtilHelpersModule, decorators: [{
|
|
742
|
+
type: NgModule,
|
|
743
|
+
args: [{
|
|
744
|
+
imports: [
|
|
745
|
+
CommonModule,
|
|
746
|
+
MatButtonModule,
|
|
747
|
+
MatDividerModule
|
|
748
|
+
],
|
|
749
|
+
declarations: [
|
|
750
|
+
ColorUtilitiesDemoComponent,
|
|
751
|
+
ColorGrabberDirective,
|
|
752
|
+
ColorExtractorDirective
|
|
753
|
+
],
|
|
754
|
+
exports: [
|
|
755
|
+
ColorUtilitiesDemoComponent
|
|
756
|
+
]
|
|
757
|
+
}]
|
|
758
|
+
}] });
|
|
759
|
+
|
|
760
|
+
/*
|
|
761
|
+
* Public API Surface of color-util-helpers
|
|
762
|
+
*/
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Generated bundle index. Do not edit.
|
|
766
|
+
*/
|
|
767
|
+
|
|
768
|
+
export { ColorConversionService, ColorExtractorDirective, ColorGrabberDirective, ColorLightenDarkenService, ColorPalletteService, ColorSchemeService, ColorUtilHelpersModule, ColorUtilitiesDemoComponent, TextColorService };
|
|
769
|
+
//# sourceMappingURL=color-util-helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-util-helpers.mjs","sources":["../../../projects/color-util-helpers/src/lib/color-grab.directive.ts","../../../projects/color-util-helpers/src/lib/color-conversion.service.ts","../../../projects/color-util-helpers/src/lib/color-pallette.service.ts","../../../projects/color-util-helpers/src/lib/text-color.service.ts","../../../projects/color-util-helpers/src/lib/color-lighten-darken.service.ts","../../../projects/color-util-helpers/src/lib/color-scheme.service.ts","../../../projects/color-util-helpers/src/lib/color-utilities-demo/color-utilities-demo.component.ts","../../../projects/color-util-helpers/src/lib/color-utilities-demo/color-utilities-demo.component.html","../../../projects/color-util-helpers/src/lib/color-extractor.directive.ts","../../../projects/color-util-helpers/src/lib/color-utils.module.ts","../../../projects/color-util-helpers/src/public-api.ts","../../../projects/color-util-helpers/src/color-util-helpers.ts"],"sourcesContent":["import { Directive, ElementRef, Input, OnInit } from '@angular/core';\n\n@Directive({\n selector: '[colorGrabber]',\n standalone: false\n})\nexport class ColorGrabberDirective implements OnInit {\n\n ctx?: CanvasRenderingContext2D\n\n @Input() imageUrl?: string\n @Input() light?: string\n @Input() dark?: string\n\n constructor(private el: ElementRef) { }\n\n ngOnInit() {\n\n const canvas = document.createElement('canvas');\n canvas.width = 1;\n canvas.height = 1;\n\n this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D;\n\n const img = new Image();\n img.src = this.imageUrl || '';\n img.setAttribute('crossOrigin', '');\n\n img.onload = () => {\n this.ctx?.drawImage(img, 0, 0, 1, 1);\n const imageData = this.ctx?.getImageData(0, 0, 1, 1);\n\n if (imageData && imageData.data) {\n const i = imageData.data;\n\n const rgbColor = `rgba(${i[0]},${i[1]},${i[2]},${i[3]})`;\n const hexColor = \"#\" + ((1 << 24) + (i[0] << 16) + (i[1] << 8) + i[2]).toString(16).slice(1);\n\n const textColor = this.textColorBasedOnBgColor(hexColor, this.light, this.dark);\n\n const hsv = this.RGB2HSV({ r: i[0], g: i[1], b: i[2] });\n hsv.hue = this.HueShift(hsv.hue, 135.0);\n\n const secondaryColor = this.HSV2RGB(hsv);\n const highlightColor = this.lightenDarkenColor(secondaryColor.hex, 50);\n\n this.el.nativeElement.style.backgroundColor = rgbColor;\n this.el.nativeElement.style.color = textColor;\n } else {\n console.error(\"Failed to get image data.\");\n }\n };\n }\n\n textColorBasedOnBgColor(\n bgColor: string,\n lightColor: string = '#FFFFFF',\n darkColor: string = '#000000'\n ) {\n\n const color = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor\n\n const r = parseInt(color.substring(0, 2), 16) // hexToR\n const g = parseInt(color.substring(2, 4), 16) // hexToG\n const b = parseInt(color.substring(4, 6), 16) // hexToB\n\n const uicolors = [r / 255, g / 255, b / 255]\n\n const c = uicolors.map((col) => {\n\n if (col <= 0.03928) return col / 12.92\n return Math.pow((col + 0.055) / 1.055, 2.4)\n\n })\n\n const L = (0.2126 * c[0]) + (0.7152 * c[1]) + (0.0722 * c[2])\n\n return (L > 0.179) ? darkColor : lightColor\n\n }\n\n RGB2HSV(rgb: { r: any, g: any, b: any}) {\n\n const hsv = { saturation:0, hue:0, value: 0 }\n\n const max = this.max3(rgb.r,rgb.g,rgb.b)\n const dif = max - this.min3(rgb.r,rgb.g,rgb.b)\n hsv.saturation = (max==0.0)?0:(100*dif/max)\n\n if (hsv.saturation == 0) {\n hsv.hue=0\n } else if (rgb.r == max) {\n hsv.hue=60.0*(rgb.g-rgb.b)/dif\n } else if (rgb.g == max) {\n hsv.hue=120.0+60.0*(rgb.b-rgb.r)/dif\n } else if (rgb.b == max) {\n hsv.hue=240.0+60.0*(rgb.r-rgb.g)/dif\n }\n\n if (hsv.hue<0.0) hsv.hue+=360.0\n\n hsv.value = Math.round(max*100/255)\n hsv.hue = Math.round(hsv.hue)\n hsv.saturation = Math.round(hsv.saturation)\n\n return hsv\n }\n\n HSV2RGB(hsv: any) {\n\n const rgb = { r: 0, g: 0, b: 0}\n\n if (hsv.saturation==0) {\n rgb.r = rgb.g = rgb.b = Math.round(hsv.value*2.55)\n } else {\n\n hsv.hue/=60\n hsv.saturation/=100\n hsv.value/=100\n const i = Math.floor(hsv.hue)\n const f = hsv.hue-i\n\n const p = hsv.value*(1-hsv.saturation)\n const q = hsv.value*(1-hsv.saturation*f)\n const t = hsv.value*(1-hsv.saturation*(1-f))\n\n switch(i) {\n\n case 0: rgb.r=hsv.value; rgb.g=t; rgb.b=p; break\n case 1: rgb.r=q; rgb.g=hsv.value; rgb.b=p; break\n case 2: rgb.r=p; rgb.g=hsv.value; rgb.b=t; break\n case 3: rgb.r=p; rgb.g=q; rgb.b=hsv.value; break\n case 4: rgb.r=t; rgb.g=p; rgb.b=hsv.value; break\n\n default: rgb.r=hsv.value; rgb.g=p; rgb.b=q\n\n }\n\n rgb.r = Math.round(rgb.r*255)\n rgb.g = Math.round(rgb.g*255)\n rgb.b = Math.round(rgb.b*255)\n\n }\n\n const rgbColor = `rgba(${rgb.r},${rgb.g},${rgb.b},${1})`\n const hexColor = \"#\" + ((1 << 24) + (rgb.r << 16) + (rgb.g << 8) + rgb.b).toString(16).slice(1)\n\n return { rgb: rgbColor, hex: hexColor }\n }\n\n HueShift(h: any, s: any) {\n h += s\n while (h>=360.0) h-=360.0\n while (h<0.0) h+=360.0\n return h\n }\n\n min3(a: any, b: any, c: any) {\n return (a<b)?((a<c)?a:c):((b<c)?b:c)\n }\n\n max3(a: any, b: any, c: any) {\n return (a>b)?((a>c)?a:c):((b>c)?b:c)\n }\n\n lightenDarkenColor(colorCode: any, amount: number) {\n\n var usePound = false;\n\n if (colorCode[0] == \"#\") {\n colorCode = colorCode.slice(1);\n usePound = true;\n }\n\n var num = parseInt(colorCode, 16);\n\n var r = (num >> 16) + amount;\n\n if (r > 255) {\n r = 255;\n } else if (r < 0) {\n r = 0;\n }\n\n var b = ((num >> 8) & 0x00FF) + amount;\n\n if (b > 255) {\n b = 255;\n } else if (b < 0) {\n b = 0;\n }\n\n var g = (num & 0x0000FF) + amount;\n\n if (g > 255) {\n g = 255;\n } else if (g < 0) {\n g = 0;\n }\n\n return (usePound ? \"#\" : \"\") + (g | (b << 8) | (r << 16)).toString(16)\n\n }\n\n}\n","import { Injectable } from '@angular/core';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class ColorConversionService {\r\n\r\n rgbToHex(rgb: number[] | null): string {\r\n if (rgb === null || rgb.length !== 3 || rgb.some(value => value < 0 || value > 255)) return '';\r\n\r\n const [r, g, b] = rgb;\r\n const hexR = this.componentToHex(r);\r\n const hexG = this.componentToHex(g);\r\n const hexB = this.componentToHex(b);\r\n return \"#\" + hexR + hexG + hexB;\r\n }\r\n\r\n private componentToHex = (c: number) => {\r\n const hex = c.toString(16);\r\n return hex.length === 1 ? \"0\" + hex : hex;\r\n }\r\n\r\n hexToRgb(hex: string | null | undefined): number[] {\r\n if (hex === null || hex === undefined) return [];\r\n\r\n hex = (hex.length === 3) ? hex + hex : hex;\r\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\r\n\r\n return result ? [\r\n parseInt(result[1], 16),\r\n parseInt(result[2], 16),\r\n parseInt(result[3], 16)\r\n ] : [];\r\n }\r\n}\r\n","import { Injectable } from '@angular/core'\r\nimport { BehaviorSubject } from 'rxjs'\r\nimport { ColorConversionService } from './color-conversion.service'\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class ColorPalletteService {\r\n\r\n // define image path\r\n // this.colorSelectionService.getColorsFromImage('../assets/sample2.jpg')\r\n\r\n // get colors\r\n // this.colorSelectionService.palette.subscribe(data => this.palette = data)\r\n\r\n // sample html\r\n // <div *ngFor=\"let color of palette\">\r\n // <div style=\"display: flex;\">\r\n // <div\r\n // class=\"box\"\r\n // [style.background-color]=\"color.color\"\r\n // >\r\n // Color\r\n // </div>\r\n // <div\r\n // class=\"box\"\r\n // [style.background-color]=\"color.complementaryColor\"\r\n // >\r\n // Complementary\r\n // </div>\r\n // </div>\r\n // </div>\r\n\r\n // CSS\r\n // .box {\r\n // width: 100px;\r\n // height: 100px;\r\n // border: solid thin black;\r\n // color: black;\r\n // margin: 4px;\r\n // padding: 16px;\r\n // display: flex;\r\n // flex-wrap: wrap;\r\n // align-content: center;\r\n // justify-content: center;\r\n // }\r\n\r\n private palette = new BehaviorSubject<{ color: string, complementaryColor: string }[]>([])\n palette$ = this.palette.asObservable()\n\n constructor(\n private colorConversionService: ColorConversionService\n ) { }\n\n /**\n * Retrieves a color palette from an image at the specified path.\n *\n * @param imagePath - The path to the image to extract the color palette from.\n * @param colors - The number of colors to include in the palette (default is 3).\n * @returns An observable that emits the generated color palette.\n */\n getColorsFromImage(imagePath: string, colors = 3) {\n const image = new Image();\n image.src = imagePath;\n\n image.onload = () => {\n const data = this.generateColorPalette(image, colors) || [];\n this.palette.next(data);\n };\n }\n\n /**\n * Generates a color palette from an image.\n *\n * @param image - The HTML image element to extract the color palette from.\n * @param colorCount - The number of colors to include in the palette (default is 6).\n * @returns An array of color objects, each with a hex color and a complementary hex color.\n */\n generateColorPalette(image: HTMLImageElement, colorCount = 6) {\n const canvas = document.createElement(\"canvas\");\n const context = canvas.getContext(\"2d\");\n\n if (!context) return;\n\n canvas.width = image.width;\n canvas.height = image.height;\n context.drawImage(image, 0, 0);\n\n // Get the image data\n const imageData = context.getImageData(0, 0, canvas.width, canvas.height);\n const pixels = imageData.data;\n const pixelCount = imageData.width * imageData.height;\n\n // Build an array of RGB colors\n const colors: number[][] = [];\n for (let i = 0; i < pixelCount; i++) {\n const offset = i * 4;\n const r = pixels[offset];\n const g = pixels[offset + 1];\n const b = pixels[offset + 2];\n colors.push([r, g, b]);\n }\n\n // Apply color quantization using k-means clustering\n const quantizedColors = this.kMeansColorQuantization(colors, colorCount);\n\n // Order colors by luminance\n quantizedColors.sort((color1, color2) => {\n const luminance1 = this.getLuminance(color1);\n const luminance2 = this.getLuminance(color2);\n return luminance2 - luminance1;\n });\n\n const palette = quantizedColors.map((color) => {\n const complementaryColor = color.map((component: number) => 255 - component);\n const hexColor = this.colorConversionService.rgbToHex(color);\n const hexComplementaryColor =\n this.colorConversionService.rgbToHex(complementaryColor);\n return { color: hexColor, complementaryColor: hexComplementaryColor };\n });\n\n return palette;\n }\n\n private getLuminance(color: number[]) {\n const [r, g, b] = color\n return 0.299 * r + 0.587 * g + 0.114 * b\n }\n\n private calculateColorDistance(color1: number[], color2: number[]) {\n const [r1, g1, b1] = color1\n const [r2, g2, b2] = color2\n const dr = r2 - r1\n const dg = g2 - g1\n const db = b2 - b1\n return Math.sqrt(dr * dr + dg * dg + db * db)\n }\n\n private calculateMeanColor(colors: number[][]) {\n let sumR = 0\n let sumG = 0\n let sumB = 0\n for (let i = 0; i < colors.length; i++) {\n const [r, g, b] = colors[i]\n sumR += r\n sumG += g\n sumB += b\n }\n const meanR = Math.round(sumR / colors.length)\n const meanG = Math.round(sumG / colors.length)\n const meanB = Math.round(sumB / colors.length)\n return [meanR, meanG, meanB]\n }\n\n private kMeansColorQuantization(colors: number[][], k: number) {\n let clusterCenters: number[][] = []\n for (let i = 0; i < k; i++) {\n const randomColor = colors[Math.floor(Math.random() * colors.length)]\n clusterCenters.push(randomColor)\n }\n\n let clusters: { color: number[], center: number[] | null }[] = []\n for (let i = 0; i < colors.length; i++) {\n const color = colors[i]\n let minDistance = Infinity\n let nearestCenter: number[] | null = null\n for (let j = 0; j < clusterCenters.length; j++) {\n const center = clusterCenters[j]\n const distance = this.calculateColorDistance(color, center)\n if (distance < minDistance) {\n minDistance = distance\n nearestCenter = center\n }\n }\n clusters.push({ color, center: nearestCenter })\n }\n\n let updatedCenters: number[][] = []\n for (let i = 0; i < clusterCenters.length; i++) {\n const center = clusterCenters[i]\n const clusterColors = clusters.filter(c => c.center === center).map(c => c.color)\n if (clusterColors.length > 0) {\n const updatedCenter = this.calculateMeanColor(clusterColors)\n updatedCenters.push(updatedCenter)\n }\n }\n\n return updatedCenters\n }\n\r\n}\r\n","import { Injectable } from '@angular/core'\r\nimport { ColorConversionService } from './color-conversion.service'\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class TextColorService {\r\n\r\n constructor(\r\n private colorConversionService: ColorConversionService\r\n ) {}\r\n\r\n textColorForBgColor(bgColor: string, lightColor: string, darkColor: string) {\r\n\r\n const UIColors = this.fixColor(bgColor)\r\n\r\n const r = UIColors[0]\r\n const g = UIColors[1]\r\n const b = UIColors[2]\r\n\r\n return ((r*0.299 + g*0.587 + b*0.114) > 149) ? darkColor : lightColor;\r\n\r\n }\r\n\r\n darkerColor(color1: string, color2: string) {\r\n return this.isColorDarker(color1, color2) ? color1 : color2;\r\n }\r\n\r\n isColorDarker(color1: string, color2: string) {\r\n\r\n const newColor1 = this.fixColor(color1);\r\n const newColor2 = this.fixColor(color2);\r\n\r\n const luminance1 = this.calculateLuminance(newColor1[0], newColor1[1], newColor1[2]);\r\n const luminance2 = this.calculateLuminance(newColor2[0], newColor2[1], newColor2[2]);\r\n\r\n return luminance1 < luminance2;\r\n }\r\n\r\n\r\n lighterColor(color1: string, color2: string): string {\r\n return (this.isColorLighter(color1,color2)) ? color1 : color2;\r\n }\r\n\r\n isColorLighter(color1: string, color2: string) {\r\n\r\n const newColor1 = this.fixColor(color1);\r\n const newColor2 = this.fixColor(color2);\r\n\r\n const luminance1 = this.calculateLuminance(newColor1[0], newColor1[1], newColor1[2]);\r\n const luminance2 = this.calculateLuminance(newColor2[0], newColor2[1], newColor2[2]);\r\n\r\n return (luminance1 > luminance2)\r\n\r\n }\r\n\r\n calculateLuminance(r: number, g: number, b: number): number {\r\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\r\n }\r\n\r\n fixColor(color: string) {\r\n // Remove leading hash if present\r\n const sanitizedColor = color.startsWith('#') ? color.slice(1) : color;\r\n\r\n // Validate if the color is a valid hex (3 or 6 characters)\r\n if (!this.isValidHex(sanitizedColor)) {\r\n return this.parseRgb(sanitizedColor); // If not hex, attempt to parse as RGB\r\n }\r\n\r\n // Convert hex to RGB\r\n const rgb = this.hexToRgb(sanitizedColor);\r\n return rgb;\r\n }\r\n\r\n // Helper function to validate if a string is a valid 3 or 6 digit hex code\r\n isValidHex(color: string): boolean {\r\n const hexRegex = /^[A-Fa-f0-9]{3}$|^[A-Fa-f0-9]{6}$/i;\r\n return hexRegex.test(color);\r\n }\r\n\r\n // Helper function to convert a 3 or 6 digit hex color to RGB\r\n hexToRgb(hex: string): number[] {\r\n if (hex.length === 3) {\r\n hex = hex.split('').map(c => c + c).join(''); // Expand shorthand hex to full\r\n }\r\n\r\n return [\r\n parseInt(hex.slice(0, 2), 16),\r\n parseInt(hex.slice(2, 4), 16),\r\n parseInt(hex.slice(4, 6), 16),\r\n ];\r\n }\r\n\r\n // Helper function to parse an RGB string (e.g., rgb(255, 0, 0)) into an array\r\n parseRgb(rgb: string): number[] {\r\n const match = rgb.match(/\\d+/g);\r\n return match ? match.map(num => parseInt(num)) : [];\r\n }\r\n\r\n\r\n}\r\n","import { Injectable, inject } from '@angular/core';\nimport { TextColorService } from './text-color.service';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ColorLightenDarkenService {\n\n colors = inject(TextColorService)\n\n // const color = '#3498db'; // Your color\n // const lighterColor = lighten(color, 0.2); // 20% lighter\n // const darkerColor = darken(color, 0.2); // 20% darker\n\n // console.log(lighterColor, darkerColor);\n\nconstructor() { }\n\n lighten(color: string, amount: number) {\n\n const rgb = this.colors.fixColor(color)\n // const rgb = color.match(/\\w\\w/g)?.map((x) => parseInt(x, 16)) || [];\n\n // Convert RGB to HSL\n let [r, g, b] = rgb.map((c) => c / 255);\n const max = Math.max(r, g, b),\n min = Math.min(r, g, b);\n let h = 0,\n s = 0,\n l = (max + min) / 2;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n // Modify the lightness and clamp it to [0, 1]\n l = Math.min(1, l + amount);\n\n // Convert HSL back to RGB\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n const hue2rgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n // Convert RGB back to hexadecimal color\n const toHex = (x: number) =>\n Math.round(x * 255)\n .toString(16)\n .padStart(2, '0');\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n }\n\n darken(color: string, amount: number) {\n return this.lighten(color, -amount);\n }\n\n}\n","import { Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ColorSchemeService {\n\n constructor() { }\n\n /**\n * Generates a random hexadecimal color code.\n *\n * This function generates a random hue value between 0 and 360 degrees, and random saturation and lightness values between 50% and 100%. It then converts the HSL values to RGB values using the `hslToRgb` function, and finally converts the RGB values to a hexadecimal color code using the `rgbToHex` function.\n *\n * @returns A hexadecimal color code in the format \"#RRGGBB\".\n */\n generateRandomColor() {\n // Generate a random hue between 0 and 360 (representing degrees on the color wheel)\n const hue = Math.floor(Math.random() * 360);\n\n // Generate random saturation and lightness values between 50% and 100%\n const saturation = Math.floor(Math.random() * 51) + 50;\n const lightness = Math.floor(Math.random() * 51) + 50;\n\n // Convert HSL values to RGB values\n const rgbColor = this.hslToRgb(hue, saturation, lightness);\n\n // Convert RGB values to hexadecimal color code\n const hexColor = this.rgbToHex(rgbColor.r, rgbColor.g, rgbColor.b);\n\n return hexColor;\n }\n\n /**\n * Converts HSL (Hue, Saturation, Lightness) color values to RGB (Red, Green, Blue) color values.\n *\n * @param h - The hue value, ranging from 0 to 360 degrees.\n * @param s - The saturation value, ranging from 0 to 100 percent.\n * @param l - The lightness value, ranging from 0 to 100 percent.\n * @returns An object with the RGB color values, where each value is between 0 and 255.\n */\n hslToRgb(h: number, s: number, l: number) {\n h /= 360;\n s /= 100;\n l /= 100;\n\n let r, g, b;\n\n if (s === 0) {\n r = g = b = l; // Achromatic color (gray)\n } else {\n const hueToRgb = (p: number, q: number, t: number) => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n\n r = Math.round(hueToRgb(p, q, h + 1 / 3) * 255);\n g = Math.round(hueToRgb(p, q, h) * 255);\n b = Math.round(hueToRgb(p, q, h - 1 / 3) * 255);\n }\n\n return { r, g, b };\n }\n\n /**\n * Converts RGB color values to a hexadecimal color string.\n *\n * @param r - The red color value, between 0 and 255.\n * @param g - The green color value, between 0 and 255.\n * @param b - The blue color value, between 0 and 255.\n * @returns A hexadecimal color string in the format \"#RRGGBB\".\n */\n rgbToHex(r: number, g: number, b: number) {\n const componentToHex = (c: number) => {\n const hex = c.toString(16);\n return hex.length === 1 ? \"0\" + hex : hex;\n };\n\n return \"#\" + componentToHex(r) + componentToHex(g) + componentToHex(b);\n }\n\n /**\n * Adjusts a hexadecimal color value by a given percentage.\n *\n * @param hexColor - The hexadecimal color value to adjust.\n * @param percentage - The percentage to adjust the color by, ranging from -100 to 100.\n * @returns The adjusted hexadecimal color value.\n */\n adjustHexColor(hexColor: string, percentage: number) {\n // Remove the \"#\" symbol if present\n hexColor = hexColor.replace(\"#\", \"\");\n\n // Convert the hex color to RGB values\n const red = parseInt(hexColor.substring(0, 2), 16);\n const green = parseInt(hexColor.substring(2, 4), 16);\n const blue = parseInt(hexColor.substring(4, 6), 16);\n\n // Calculate the adjustment amount based on the percentage\n const adjustAmount = Math.round(255 * (percentage / 100));\n\n // Adjust the RGB values\n const adjustedRed = this.clamp(red + adjustAmount);\n const adjustedGreen = this.clamp(green + adjustAmount);\n const adjustedBlue = this.clamp(blue + adjustAmount);\n\n // Convert the adjusted RGB values back to hex\n const adjustedHexColor = `#${(adjustedRed).toString(16).padStart(2, '0')}${(adjustedGreen).toString(16).padStart(2, '0')}${(adjustedBlue).toString(16).padStart(2, '0')}`;\n\n return adjustedHexColor;\n }\n\n clamp(value: number) {\n return Math.max(0, Math.min(value, 255));\n }\n\n}\n","import { Component, OnInit, inject } from '@angular/core';\n\nimport { ColorConversionService } from '../color-conversion.service';\nimport { ColorPalletteService } from '../color-pallette.service';\nimport { TextColorService } from '../text-color.service';\nimport { ColorLightenDarkenService } from '../color-lighten-darken.service';\nimport { ColorSchemeService } from '../color-scheme.service';\n\n@Component({\n selector: 'app-color-utilities-demo',\n templateUrl: './color-utilities-demo.component.html',\n styleUrls: ['./color-utilities-demo.component.css'],\n standalone: false\n})\nexport class ColorUtilitiesDemoComponent implements OnInit {\n\n colorConversionService = inject(ColorConversionService)\n colorLightenDarkenService = inject(ColorLightenDarkenService)\n colorPalletteService = inject(ColorPalletteService)\n textColorService = inject(TextColorService)\n colorSchemeService = inject(ColorSchemeService)\n\n\n HEX = this.colorConversionService.rgbToHex([12, 56, 128])\n RGB = `rgb(${this.colorConversionService.hexToRgb('#AA11BB')})`\n\n\n lighten = this.colorLightenDarkenService.lighten('#AA11BB', .25)\n darken = this.colorLightenDarkenService.darken('#AA11BB', .25)\n\n colorIsDarker = this.textColorService.isColorDarker(this.lighten, this.darken)\n\n darkBk = this.textColorService.textColorForBgColor(this.HEX, this.lighten, this.darken)\n lightBk = this.textColorService.textColorForBgColor('whitesmoke', this.lighten, this.darken)\n\n palette: any\n colors$ = this.colorPalletteService.palette$\n\n colorPick = this.colorSchemeService.generateRandomColor()\n colorPickDarker = this.colorSchemeService.adjustHexColor(this.colorPick, -25)\n colorPickLighter = this.colorSchemeService.adjustHexColor(this.colorPick, 25)\n\n img: string|any\n\n constructor() { }\n\n ngOnInit() {\n\n // define image path\n this.img = 'assets/picture.webp'\n this.colorPalletteService.getColorsFromImage(this.img, 8)\n\n\n }\n\n\n}\n\n","<div style=\"margin: 2rem;\">\n\n <h1>Color Conversion Service</h1>\n <div style=\"display: flex; flex-direction: column; gap: 1rem;\">\n <div style=\"display: flex\">\n <div style=\"padding-top: .5rem; margin-right: .5rem;\">rgbToHex: {{ HEX }}</div>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"HEX\"></div>\n </div>\n\n <div style=\"display: flex\">\n <div style=\"padding-top: .5rem; margin-right: .5rem;\"> hexToRgb: {{ RGB }} </div>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"RGB\"></div>\n </div>\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Color Light/Darken Service</h1>\n\n <div style=\"display: flex; flex-direction: column; gap: 1rem;\">\n\n <div style=\"display: flex; gap: 1rem\">\n Original Color: #AA11BB<br>\n <div style=\"width: 32px; height: 32px; background-color: #AA11BB;\"></div>\n Lighten (25%): {{ lighten }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"lighten\"></div>\n Darken (25%): {{ darken }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"darken\"></div>\n </div>\n\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Text Color Utility Services</h1>\n\n <div style=\"display: flex; gap: 1rem; flex-direction: column;\">\n <div style=\"display: flex; gap: 1rem\">\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"darken\"></div>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"lighten\"></div>\n is Darker : {{ colorIsDarker }}\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorIsDarker\"></div>\n </div>\n\n <div style=\"display: flex; gap: 1rem; flex-direction: column;\">\n\n <div>\n Use: {{ lightBk }} for '{{ HEX }}' background-color<br>\n <div style=\"padding: 1rem;\" [style.backgroundColor]=\"HEX\" [style.color]=\"darkBk\">\n Sample Text Color\n </div>\n </div>\n\n <div>\n Use: {{ lightBk }} for 'whitesmoke' background-color<br>\n <div style=\"padding: 1rem; background-color: whitesmoke;\" [style.color]=\"lightBk\">\n Sample Text Color\n </div>\n </div>\n </div>\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Color Schema Services</h1>\n\n <div style=\"display: flex; gap: 1rem\">\n Pick Color: {{ colorPick }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorPick\"></div>\n Lighter Version: {{ colorPickLighter }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorPickLighter\"></div>\n DarkerVersion: {{ colorPickDarker }}<br>\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"colorPickDarker\"></div>\n </div>\n\n <div style=\"margin-top: 1rem; margin-bottom: 1rem;\">\n <mat-divider></mat-divider>\n </div>\n\n <h1>Color Pallette Service</h1>\n Creates Pallette from Image\n <div style=\"display: flex; gap: 2rem;\">\n <div>\n <img [src]=\"img\" height=\"180\">\n </div>\n\n <div style=\"display: flex; gap: .5rem; width: 120px; border: 1px solid black; flex-wrap: wrap; padding: .5rem;\">\n <div>Color Pick</div>\n @for (color of (colors$ | async); track color) {\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"color.color\"></div>\n }\n </div>\n\n <div style=\"display: flex; gap: .5rem; width: 120px; border: 1px solid black; flex-wrap: wrap; padding: .5rem;\">\n <div>Complementary</div>\n @for (color of (colors$ | async); track color) {\n <div style=\"width: 32px; height: 32px;\" [style.backgroundColor]=\"color.complementaryColor\"></div>\n }\n </div>\n </div>\n\n</div>\n\n","import { Directive, ElementRef, Renderer2, HostListener, EventEmitter, Output } from '@angular/core';\n\n@Directive({\n selector: '[getColor]',\n standalone: false\n})\nexport class ColorExtractorDirective {\n\n @Output() colorValue: EventEmitter<string> = new EventEmitter<string>();\n\n constructor(private elementRef: ElementRef, private renderer: Renderer2) {}\n\n get currentElement() {\n return window.getComputedStyle(this.elementRef.nativeElement);\n }\n\n @HostListener('mouseenter')\n onMouseEnter() {\n // console.log('ENTER', this.currentElement)\n this.colorValue.emit(this.currentElement.getPropertyValue('background-color'))\n }\n\n @HostListener('mouseleave')\n onMouseLeave() {\n // console.log('LEAVE', this.currentElement.getPropertyValue('background-color'))\n this.colorValue.emit('white')\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatDividerModule } from '@angular/material/divider';\nimport { ColorGrabberDirective } from './color-grab.directive';\n\nimport { ColorUtilitiesDemoComponent } from './color-utilities-demo/color-utilities-demo.component';\nimport { ColorExtractorDirective } from './color-extractor.directive';\n\n\n@NgModule({\n imports: [\n CommonModule,\n MatButtonModule,\n MatDividerModule\n ],\n declarations: [\n ColorUtilitiesDemoComponent,\n ColorGrabberDirective,\n ColorExtractorDirective\n ],\n exports: [\n ColorUtilitiesDemoComponent\n ]\n})\nexport class ColorUtilHelpersModule { }\n","/*\n * Public API Surface of color-util-helpers\n */\n\nexport * from './lib/color-utils.module';\n\nexport * from './lib/color-utilities-demo/color-utilities-demo.component';\n\nexport * from './lib/color-conversion.service';\nexport * from './lib/color-extractor.directive';\nexport * from './lib/color-grab.directive';\nexport * from './lib/color-pallette.service';\nexport * from './lib/text-color.service';\n\nexport * from './lib/color-scheme.service';\nexport * from './lib/color-lighten-darken.service';\n\nexport * from './lib/color-utils.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.ColorConversionService"],"mappings":";;;;;;;;;MAMa,qBAAqB,CAAA;AAQhC,IAAA,WAAA,CAAoB,EAAc,EAAA;QAAd,IAAA,CAAA,EAAE,GAAF,EAAE;IAAgB;IAEtC,QAAQ,GAAA;QAEN,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC;AAC/C,QAAA,MAAM,CAAC,KAAK,GAAG,CAAC;AAChB,QAAA,MAAM,CAAC,MAAM,GAAG,CAAC;QAEjB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAA6B;AAE9D,QAAA,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE;QACvB,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE;AAC7B,QAAA,GAAG,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,CAAC;AAEnC,QAAA,GAAG,CAAC,MAAM,GAAG,MAAK;AAChB,YAAA,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACpC,YAAA,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAEpD,YAAA,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AAY;;;MCIf,sBAAsB,CAAA;+GAAtB,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAtB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,sBAAsB,iBAR/B,2BAA2B;YAC3B,qBAAqB;AACrB,YAAA,uBAAuB,aAPvB,YAAY;YACZ,eAAe;AACf,YAAA,gBAAgB,aAQhB,2BAA2B,CAAA,EAAA,CAAA,CAAA;AAGlB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,sBAAsB,YAb/B,YAAY;YACZ,eAAe;YACf,gBAAgB,CAAA,EAAA,CAAA,CAAA;;4FAWP,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAflC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;wBACZ,eAAe;wBACf;AACD,qBAAA;AACD,oBAAA,YAAY,EAAE;wBACZ,2BAA2B;wBAC3B,qBAAqB;wBACrB;AACD,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP;AACD;AACF,iBAAA;;;ACzBD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "color-util-helpers",
|
|
3
|
+
"version": "0.0.21",
|
|
4
|
+
"homepage": "https://wavecoders.ca",
|
|
5
|
+
"author": "Mike Bonifacio <wavecoders@gmail.com> (http://wavecoders@gmail.com/)",
|
|
6
|
+
"description": "This is an Angular Module containing Components/Services using Material",
|
|
7
|
+
"funding": [
|
|
8
|
+
{
|
|
9
|
+
"type": "individual",
|
|
10
|
+
"url": "http://wavecoders.ca/donate"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@angular/common": "^15.2.0",
|
|
15
|
+
"@angular/core": "^15.2.0"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"tslib": "^2.3.0"
|
|
19
|
+
},
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"module": "fesm2022/color-util-helpers.mjs",
|
|
22
|
+
"typings": "types/color-util-helpers.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
"./package.json": {
|
|
25
|
+
"default": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./types/color-util-helpers.d.ts",
|
|
29
|
+
"default": "./fesm2022/color-util-helpers.mjs"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { OnInit, ElementRef, EventEmitter, Renderer2 } from '@angular/core';
|
|
3
|
+
import * as rxjs from 'rxjs';
|
|
4
|
+
import * as i4 from '@angular/common';
|
|
5
|
+
import * as i5 from '@angular/material/button';
|
|
6
|
+
import * as i6 from '@angular/material/divider';
|
|
7
|
+
|
|
8
|
+
declare class ColorConversionService {
|
|
9
|
+
rgbToHex(rgb: number[] | null): string;
|
|
10
|
+
private componentToHex;
|
|
11
|
+
hexToRgb(hex: string | null | undefined): number[];
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ColorConversionService, never>;
|
|
13
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ColorConversionService>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare class ColorPalletteService {
|
|
17
|
+
private colorConversionService;
|
|
18
|
+
private palette;
|
|
19
|
+
palette$: rxjs.Observable<{
|
|
20
|
+
color: string;
|
|
21
|
+
complementaryColor: string;
|
|
22
|
+
}[]>;
|
|
23
|
+
constructor(colorConversionService: ColorConversionService);
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves a color palette from an image at the specified path.
|
|
26
|
+
*
|
|
27
|
+
* @param imagePath - The path to the image to extract the color palette from.
|
|
28
|
+
* @param colors - The number of colors to include in the palette (default is 3).
|
|
29
|
+
* @returns An observable that emits the generated color palette.
|
|
30
|
+
*/
|
|
31
|
+
getColorsFromImage(imagePath: string, colors?: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Generates a color palette from an image.
|
|
34
|
+
*
|
|
35
|
+
* @param image - The HTML image element to extract the color palette from.
|
|
36
|
+
* @param colorCount - The number of colors to include in the palette (default is 6).
|
|
37
|
+
* @returns An array of color objects, each with a hex color and a complementary hex color.
|
|
38
|
+
*/
|
|
39
|
+
generateColorPalette(image: HTMLImageElement, colorCount?: number): {
|
|
40
|
+
color: string;
|
|
41
|
+
complementaryColor: string;
|
|
42
|
+
}[] | undefined;
|
|
43
|
+
private getLuminance;
|
|
44
|
+
private calculateColorDistance;
|
|
45
|
+
private calculateMeanColor;
|
|
46
|
+
private kMeansColorQuantization;
|
|
47
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ColorPalletteService, never>;
|
|
48
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ColorPalletteService>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare class TextColorService {
|
|
52
|
+
private colorConversionService;
|
|
53
|
+
constructor(colorConversionService: ColorConversionService);
|
|
54
|
+
textColorForBgColor(bgColor: string, lightColor: string, darkColor: string): string;
|
|
55
|
+
darkerColor(color1: string, color2: string): string;
|
|
56
|
+
isColorDarker(color1: string, color2: string): boolean;
|
|
57
|
+
lighterColor(color1: string, color2: string): string;
|
|
58
|
+
isColorLighter(color1: string, color2: string): boolean;
|
|
59
|
+
calculateLuminance(r: number, g: number, b: number): number;
|
|
60
|
+
fixColor(color: string): number[];
|
|
61
|
+
isValidHex(color: string): boolean;
|
|
62
|
+
hexToRgb(hex: string): number[];
|
|
63
|
+
parseRgb(rgb: string): number[];
|
|
64
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TextColorService, never>;
|
|
65
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TextColorService>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare class ColorLightenDarkenService {
|
|
69
|
+
colors: TextColorService;
|
|
70
|
+
constructor();
|
|
71
|
+
lighten(color: string, amount: number): string;
|
|
72
|
+
darken(color: string, amount: number): string;
|
|
73
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ColorLightenDarkenService, never>;
|
|
74
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ColorLightenDarkenService>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare class ColorSchemeService {
|
|
78
|
+
constructor();
|
|
79
|
+
/**
|
|
80
|
+
* Generates a random hexadecimal color code.
|
|
81
|
+
*
|
|
82
|
+
* This function generates a random hue value between 0 and 360 degrees, and random saturation and lightness values between 50% and 100%. It then converts the HSL values to RGB values using the `hslToRgb` function, and finally converts the RGB values to a hexadecimal color code using the `rgbToHex` function.
|
|
83
|
+
*
|
|
84
|
+
* @returns A hexadecimal color code in the format "#RRGGBB".
|
|
85
|
+
*/
|
|
86
|
+
generateRandomColor(): string;
|
|
87
|
+
/**
|
|
88
|
+
* Converts HSL (Hue, Saturation, Lightness) color values to RGB (Red, Green, Blue) color values.
|
|
89
|
+
*
|
|
90
|
+
* @param h - The hue value, ranging from 0 to 360 degrees.
|
|
91
|
+
* @param s - The saturation value, ranging from 0 to 100 percent.
|
|
92
|
+
* @param l - The lightness value, ranging from 0 to 100 percent.
|
|
93
|
+
* @returns An object with the RGB color values, where each value is between 0 and 255.
|
|
94
|
+
*/
|
|
95
|
+
hslToRgb(h: number, s: number, l: number): {
|
|
96
|
+
r: number;
|
|
97
|
+
g: number;
|
|
98
|
+
b: number;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Converts RGB color values to a hexadecimal color string.
|
|
102
|
+
*
|
|
103
|
+
* @param r - The red color value, between 0 and 255.
|
|
104
|
+
* @param g - The green color value, between 0 and 255.
|
|
105
|
+
* @param b - The blue color value, between 0 and 255.
|
|
106
|
+
* @returns A hexadecimal color string in the format "#RRGGBB".
|
|
107
|
+
*/
|
|
108
|
+
rgbToHex(r: number, g: number, b: number): string;
|
|
109
|
+
/**
|
|
110
|
+
* Adjusts a hexadecimal color value by a given percentage.
|
|
111
|
+
*
|
|
112
|
+
* @param hexColor - The hexadecimal color value to adjust.
|
|
113
|
+
* @param percentage - The percentage to adjust the color by, ranging from -100 to 100.
|
|
114
|
+
* @returns The adjusted hexadecimal color value.
|
|
115
|
+
*/
|
|
116
|
+
adjustHexColor(hexColor: string, percentage: number): string;
|
|
117
|
+
clamp(value: number): number;
|
|
118
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ColorSchemeService, never>;
|
|
119
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ColorSchemeService>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare class ColorUtilitiesDemoComponent implements OnInit {
|
|
123
|
+
colorConversionService: ColorConversionService;
|
|
124
|
+
colorLightenDarkenService: ColorLightenDarkenService;
|
|
125
|
+
colorPalletteService: ColorPalletteService;
|
|
126
|
+
textColorService: TextColorService;
|
|
127
|
+
colorSchemeService: ColorSchemeService;
|
|
128
|
+
HEX: string;
|
|
129
|
+
RGB: string;
|
|
130
|
+
lighten: string;
|
|
131
|
+
darken: string;
|
|
132
|
+
colorIsDarker: boolean;
|
|
133
|
+
darkBk: string;
|
|
134
|
+
lightBk: string;
|
|
135
|
+
palette: any;
|
|
136
|
+
colors$: rxjs.Observable<{
|
|
137
|
+
color: string;
|
|
138
|
+
complementaryColor: string;
|
|
139
|
+
}[]>;
|
|
140
|
+
colorPick: string;
|
|
141
|
+
colorPickDarker: string;
|
|
142
|
+
colorPickLighter: string;
|
|
143
|
+
img: string | any;
|
|
144
|
+
constructor();
|
|
145
|
+
ngOnInit(): void;
|
|
146
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ColorUtilitiesDemoComponent, never>;
|
|
147
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ColorUtilitiesDemoComponent, "app-color-utilities-demo", never, {}, {}, never, never, false, never>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
declare class ColorGrabberDirective implements OnInit {
|
|
151
|
+
private el;
|
|
152
|
+
ctx?: CanvasRenderingContext2D;
|
|
153
|
+
imageUrl?: string;
|
|
154
|
+
light?: string;
|
|
155
|
+
dark?: string;
|
|
156
|
+
constructor(el: ElementRef);
|
|
157
|
+
ngOnInit(): void;
|
|
158
|
+
textColorBasedOnBgColor(bgColor: string, lightColor?: string, darkColor?: string): string;
|
|
159
|
+
RGB2HSV(rgb: {
|
|
160
|
+
r: any;
|
|
161
|
+
g: any;
|
|
162
|
+
b: any;
|
|
163
|
+
}): {
|
|
164
|
+
saturation: number;
|
|
165
|
+
hue: number;
|
|
166
|
+
value: number;
|
|
167
|
+
};
|
|
168
|
+
HSV2RGB(hsv: any): {
|
|
169
|
+
rgb: string;
|
|
170
|
+
hex: string;
|
|
171
|
+
};
|
|
172
|
+
HueShift(h: any, s: any): any;
|
|
173
|
+
min3(a: any, b: any, c: any): any;
|
|
174
|
+
max3(a: any, b: any, c: any): any;
|
|
175
|
+
lightenDarkenColor(colorCode: any, amount: number): string;
|
|
176
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ColorGrabberDirective, never>;
|
|
177
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ColorGrabberDirective, "[colorGrabber]", never, { "imageUrl": { "alias": "imageUrl"; "required": false; }; "light": { "alias": "light"; "required": false; }; "dark": { "alias": "dark"; "required": false; }; }, {}, never, never, false, never>;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare class ColorExtractorDirective {
|
|
181
|
+
private elementRef;
|
|
182
|
+
private renderer;
|
|
183
|
+
colorValue: EventEmitter<string>;
|
|
184
|
+
constructor(elementRef: ElementRef, renderer: Renderer2);
|
|
185
|
+
get currentElement(): CSSStyleDeclaration;
|
|
186
|
+
onMouseEnter(): void;
|
|
187
|
+
onMouseLeave(): void;
|
|
188
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ColorExtractorDirective, never>;
|
|
189
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ColorExtractorDirective, "[getColor]", never, {}, { "colorValue": "colorValue"; }, never, never, false, never>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare class ColorUtilHelpersModule {
|
|
193
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ColorUtilHelpersModule, never>;
|
|
194
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<ColorUtilHelpersModule, [typeof ColorUtilitiesDemoComponent, typeof ColorGrabberDirective, typeof ColorExtractorDirective], [typeof i4.CommonModule, typeof i5.MatButtonModule, typeof i6.MatDividerModule], [typeof ColorUtilitiesDemoComponent]>;
|
|
195
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<ColorUtilHelpersModule>;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export { ColorConversionService, ColorExtractorDirective, ColorGrabberDirective, ColorLightenDarkenService, ColorPalletteService, ColorSchemeService, ColorUtilHelpersModule, ColorUtilitiesDemoComponent, TextColorService };
|