@techui/colors 1.0.1 → 1.0.3

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 CHANGED
@@ -1,46 +1,59 @@
1
1
  # @techui/colors
2
2
 
3
- **[English](README.md)** | **[中文](README.cn.md)**
3
+ **[English](#english)** | **[中文](#中文)**
4
+
5
+ ---
6
+
7
+ ## English
4
8
 
5
9
  > Color tables for JavaScript and Less, developed by ayin.
6
10
 
7
11
  **@techui/colors** (formerly **ayin-color**) is a color library tool designed to help developers avoid memorizing tedious color values like `#FF0000` or `RGB(255,0,0)`, using a more natural language-like approach to define and call colors.
8
12
 
9
- ## ✨ Features
13
+ ### ✨ Features
10
14
 
11
15
  - 🎨 **Natural Language Naming** - Use intuitive color names like `rel5` (red), `bll5` (blue)
12
16
  - 📦 **Dual Version Support** - Provides V1 and V2 versions, with V2 offering richer color variations
13
17
  - 🔧 **Multi-Platform Compatible** - Supports both JavaScript and Less/CSS versions
14
18
  - 🌈 **Scientific Color Scheme** - Based on HSL color model, generating complete color spectrum through hue, saturation, and lightness
15
- - 🎯 **Ready to Use** - Hundreds of preset color values for rapid development without lookup tables
19
+ - 🎯 **Ready to Use** - Hundreds of preset color values for rapid development
20
+ - 📄 **Built-in Preview File** - Quickly view and copy the colors you need from preview.html for a quick start. After getting started, you can quickly call up colors using natural language without looking up tables.
16
21
 
17
- ## 🚀 Quick Start
22
+ ### 🚀 Quick Start
18
23
 
19
- ### JavaScript Usage
24
+ #### JavaScript Usage
20
25
 
21
26
  Import in your project entry file (e.g., `main.js`):
22
27
 
23
28
  ```javascript
24
- import { AyinColor } from "@techui/colors"
25
- Vue.use(AyinColor)
29
+ import tuiColors from "@techui/colors"
30
+ Vue.use(tuiColors)
31
+ //At this point, you can use $c and $chroma anywhere in your project.
32
+ ```
33
+
34
+ Or use import to bring in components or pages, such as:
35
+
36
+ ```javascript
37
+ import { $c, $chroma } from “@techui/colors”
38
+ const color = $c.rel5
26
39
  ```
27
40
 
28
41
  Usage examples:
29
42
 
30
43
  ```javascript
31
- // AyinColor V1 - Using base colors
44
+ // TechUI/Colors V1 - Using base colors
32
45
  let color = $c.rel5 // Red
33
46
  let blue = $c.bll5 // Blue
34
47
  let gray = $c.gyd4 // Gray
35
48
 
36
- // AyinColor V2 - Using extended colors
49
+ // TechUI/Colors V2 - Using extended colors
37
50
  let color2 = $c.reA10 // Red (with finer gradations)
38
51
  let blue2 = $c.blA03 // Blue
39
52
  ```
40
53
 
41
- ### CSS/Less Usage
54
+ #### CSS/Less Usage
42
55
 
43
- #### Vue 2 (vue.config.js)
56
+ ##### Vue 2 (vue.config.js)
44
57
 
45
58
  First install dependencies: `less`, `less-loader`, `style-resources-loader`
46
59
 
@@ -60,7 +73,7 @@ module.exports = {
60
73
  }
61
74
  ```
62
75
 
63
- #### Vue 3 + Vite (vite.config.js)
76
+ ##### Vue 3 + Vite (vite.config.js)
64
77
 
65
78
  First install dependencies: `less`, `less-loader`
66
79
 
@@ -86,14 +99,14 @@ export default defineConfig({
86
99
  Use in style files:
87
100
 
88
101
  ```less
89
- // AyinColor V1
102
+ // TechUI/Colors V1
90
103
  .text {
91
104
  color: @rel5;
92
105
  background-color: @bll5;
93
106
  border: 1px solid @gyd4;
94
107
  }
95
108
 
96
- // AyinColor V2
109
+ // TechUI/Colors V2
97
110
  .text-v2 {
98
111
  color: @reA10;
99
112
  background-color: @blA03;
@@ -101,45 +114,45 @@ Use in style files:
101
114
  }
102
115
  ```
103
116
 
104
- ## 🎨 Color Naming Convention
117
+ ### 🎨 Color Naming Convention
105
118
 
106
- ### V1 Naming Rules
119
+ #### V1 Naming Rules
107
120
 
108
121
  Color names consist of **base color** + **saturation** + **lightness**.
109
122
 
110
123
  **25 Base Colors** (15° hue intervals):
111
124
 
112
- - `re` - red
113
- - `or` - orange
114
- - `ye` - yellow
115
- - `ch` - chartreuse
116
- - `gr` - green
117
- - `aq` - aquamarine
118
- - `cy` - cyan
119
- - `bl` - blue
120
- - `in` - indigo
121
- - `pu` - purple
122
- - `pi` - pink
123
- - `vi` - violetred
124
- - `gy` - gray
125
- - And intermediate colors: `ro`, `oy`, `yc`, `cg`, `ga`, `ac`, `cb`, `bi`, `ip`, `pp`, `pv`, `vr`
125
+ - `re` - red
126
+ - `or` - orange
127
+ - `ye` - yellow
128
+ - `ch` - chartreuse
129
+ - `gr` - green
130
+ - `aq` - aquamarine
131
+ - `cy` - cyan
132
+ - `bl` - blue
133
+ - `in` - indigo
134
+ - `pu` - purple
135
+ - `pi` - pink
136
+ - `vi` - violetred
137
+ - `gy` - gray
138
+ - And intermediate colors: `ro`, `oy`, `yc`, `cg`, `ga`, `ac`, `cb`, `bi`, `ip`, `pp`, `pv`, `vr`
126
139
 
127
140
  **4 Saturation Levels**:
128
141
 
129
- - `l` - light
130
- - `m` - middle
131
- - `r` - roast
132
- - `d` - dark
142
+ - `l` - light
143
+ - `m` - middle
144
+ - `r` - roast
145
+ - `d` - dark
133
146
 
134
147
  **9 Lightness Levels**: `1` (lightest) to `9` (darkest)
135
148
 
136
149
  **Examples**:
137
150
 
138
- - `rel5` - Red, light saturation, level 5 lightness
139
- - `bld1` - Blue, dark saturation, level 1 lightness (light blue with deep saturation)
140
- - `rel9` - Red, light saturation, level 9 lightness (deep red)
151
+ - `rel5` - Red, light saturation, level 5 lightness
152
+ - `bld1` - Blue, dark saturation, level 1 lightness (light blue with deep saturation)
153
+ - `rel9` - Red, light saturation, level 9 lightness (deep red)
141
154
 
142
- ### V2 Naming Rules
155
+ #### V2 Naming Rules
143
156
 
144
157
  V2 provides finer color gradations.
145
158
 
@@ -149,12 +162,12 @@ V2 provides finer color gradations.
149
162
 
150
163
  **Examples**:
151
164
 
152
- - `reA10` - Red, A saturation, level 10 lightness
153
- - `blE05` - Blue, E saturation, level 5 lightness
165
+ - `reA10` - Red, A saturation, level 10 lightness
166
+ - `blE05` - Blue, E saturation, level 5 lightness
154
167
 
155
- ## 🔧 Advanced Features
168
+ ### 🔧 Advanced Features
156
169
 
157
- ### JavaScript Color Processing Functions
170
+ #### JavaScript Color Processing Functions
158
171
 
159
172
  Color processing functions based on chroma.js:
160
173
 
@@ -180,7 +193,47 @@ let gradient = $c.scale(['rel5', 'bll5', 'yel5'], 10, 'lch')
180
193
  // Parameters: color array (minimum 2), number of colors needed, blending mode (lch/hsl/lab/lrgb, default lch)
181
194
  ```
182
195
 
183
- ### Less Color Processing Functions
196
+ #### Advanced Color Utilities
197
+
198
+ ```javascript
199
+ // 1. Resolve a color — supports preset names, @-prefixed names, or raw hex/rgb values
200
+ const blue = $c.resolve('bll5')
201
+ const blueFromToken = $c.resolve('@bll5')
202
+
203
+ // 2. Validate a color
204
+ const isValidPreset = $c.valid('bll5') // true
205
+ const isValidHex = $c.valid('#1677ff') // true
206
+
207
+ // 3. Expression syntax — pipe-based shorthand for color transforms
208
+ const softBlue = $c.expr('@bll5|.3') // fade to 30% opacity
209
+ const softHex = $c.expr('#1677ff|.4') // hex colors are supported too
210
+ const fadeBlue = $c.expr('@bll5|fade(.3)') // explicit fade
211
+ const lightBlue = $c.expr('@bll5|lighten(2)') // lighten
212
+ const darkBlue = $c.expr('@bll5|darken(1)') // darken
213
+ const customL = $c.expr('@bll5|hsll(.35)') // set HSL lightness
214
+
215
+ // 4. Generate a semantic color scale from a base color
216
+ const colors = $c.genColors('bll5', 7)
217
+ // Parameters: base color (or array), count, hue diff between steps, saturation reduce factor
218
+
219
+ // 5. Convert a color scale array into a semantic object with optional opacity variants
220
+ const colorObj = $c.genColorObj(colors, [0.9, 0.7, 0.5])
221
+ // Result includes keys like weak / base / strong, plus opacity variants
222
+ ```
223
+
224
+ ##### Expression Syntax Reference
225
+
226
+ | Expression | Equivalent Call | Description |
227
+ | --- | --- | --- |
228
+ | `@bll5` | `$c.resolve('bll5')` | `@` explicitly marks a TechUI Colors preset name |
229
+ | `@bll5\|.3` | `$c.fade('bll5', .3)` | Pipe + number defaults to `fade` |
230
+ | `@bll5\|fade(.3)` | `$c.fade('bll5', .3)` | Explicit fade |
231
+ | `@bll5\|lighten(2)` | `$c.lighten('bll5', 2)` | Lighten the color |
232
+ | `@bll5\|darken(1)` | `$c.darken('bll5', 1)` | Darken the color |
233
+ | `@bll5\|hsll(.35)` | `$c.hsll('bll5', .35)` | Set HSL lightness |
234
+ | `#1677ff\|.4` | `$c.fade('#1677ff', .4)` | Raw hex values are also supported |
235
+
236
+ #### Less Color Processing Functions
184
237
 
185
238
  ```less
186
239
  .element {
@@ -204,76 +257,407 @@ let gradient = $c.scale(['rel5', 'bll5', 'yel5'], 10, 'lch')
204
257
 
205
258
  For more Less color functions, refer to the [Less official documentation](http://lesscss.org/functions/#color-operations).
206
259
 
207
- ## 📖 Version Selection Guide
260
+ ### 📖 Version Selection Guide
208
261
 
209
- ### Use V1 Version
262
+ #### Use V1 Version
210
263
 
211
- - ✅ Daily project development
212
- - ✅ Rapid prototyping
213
- - ✅ Need for easy-to-remember and controllable color schemes
214
- - ✅ General web applications and admin dashboards
264
+ - ✅ Daily project development
265
+ - ✅ Rapid prototyping
266
+ - ✅ Need for easy-to-remember and controllable color schemes
267
+ - ✅ General web applications and admin dashboards
215
268
 
216
269
  V1 has a moderate number of colors, easy to master, and meets the color needs of most projects.
217
270
 
218
- ### Use V2 Version
271
+ #### Use V2 Version
219
272
 
220
- - ✅ Data visualization projects
221
- - ✅ Large screen display systems
222
- - ✅ Need for fine color gradation control
223
- - ✅ Professional design projects
273
+ - ✅ Data visualization projects
274
+ - ✅ Large screen display systems
275
+ - ✅ Need for fine color gradation control
276
+ - ✅ Professional design projects
224
277
 
225
278
  V2 provides finer color variations, suitable for scenarios with higher color requirements.
226
279
 
227
- ## 🔨 Development Tools
280
+ ### 🔨 Development Tools
228
281
 
229
- ### Color Conversion Tool
282
+ #### Color Conversion Tool
230
283
 
231
- The project provides a color conversion tool that converts regular color values to AyinColor format.
284
+ The project provides a color conversion tool that converts regular color values to TechUI/Colors format.
232
285
 
233
286
  Supported input formats:
234
287
 
235
- - Color names: `red`
236
- - Hexadecimal: `#FF0000`
237
- - RGB/RGBA: `rgb(255, 0, 0)`, `rgba(255, 0, 0, 0.5)`
288
+ - Color names: `red`
289
+ - Hexadecimal: `#FF0000`
290
+ - RGB/RGBA: `rgb(255, 0, 0)`, `rgba(255, 0, 0, 0.5)`
238
291
 
239
292
  The tool returns the best match in both V1 and V2 versions. A smaller distance parameter indicates closer proximity to the original color.
240
293
 
241
294
  The tool is located in the `aYinColor-V2 source` directory.
242
295
 
243
- ## 📂 Included Files
296
+ ### 📂 Included Files
244
297
 
245
- - `ayin-color.less` - V1 CSS version
246
- - `ayin-color-expand.less` - V2 CSS version
247
- - `ayin-color.js` - JavaScript version
248
- - `ayin-color.json` - Static color values JSON file
249
- - `index.js` - Entry file
298
+ - `ayin-color.less` - V1 CSS version
299
+ - `ayin-color-extended.less` - V2 CSS version
300
+ - `ayin-color.js` - JavaScript version
301
+ - `ayin-color.json` - Static color values JSON file
302
+ - `index.js` - Entry file
303
+ - `preview.html` - Offline color table preview, query, and matching tool
250
304
 
251
- ## 🎯 Design Philosophy
305
+ ### 🎯 Design Philosophy
252
306
 
253
- AyinColor is designed based on the HSL color model:
307
+ TechUI/Colors is designed based on the HSL color model:
254
308
 
255
- 1. **Hue**: Starting from pure red `#FF0000`, generates a base color every 15°, totaling 24 base colors + 1 gray
256
- 2. **Saturation**: V1 provides 4 levels, V2 provides 6 levels
257
- 3. **Lightness**: V1 provides 9 levels, V2 provides 19 levels
309
+ 1. **Hue**: Starting from pure red `#FF0000`, generates a base color every 15°, totaling 24 base colors + 1 gray
310
+ 2. **Saturation**: V1 provides 4 levels, V2 provides 6 levels
311
+ 3. **Lightness**: V1 provides 9 levels, V2 provides 19 levels
258
312
 
259
313
  This design makes color usage more intuitive and systematic.
260
314
 
261
- ## 📚 Related Links
315
+ ### 📚 Related Links
316
+
317
+ - 🏠 [Official Website](https://techui.net/)
318
+ - 📦 [npm Package](https://www.npmjs.com/package/@techui/colors)
319
+ - 💻 [GitHub Repository](https://github.com/aYin86cn/ayin-color)
320
+ - 🎥 [Bilibili Video Tutorial](https://space.bilibili.com/302402751)
321
+ - 🎨 [Color Table Preview](https://ayin86.com/)
322
+
323
+ ### 👨‍💻 Author
324
+
325
+ **Ayin**
326
+
327
+ - Email: [ayin86cn@gmail.com](mailto:ayin86cn@gmail.com)
328
+ - WeChat: jay1986cn
329
+
330
+ ### 🙏 Acknowledgments
331
+
332
+ - Built with [chroma.js](https://gka.github.io/chroma.js/)
333
+ - Thanks to all developers who use and support @techui/colors
334
+
335
+ -----
336
+
337
+ ## 中文
338
+
339
+ > ayin 开发的 js 和 less 版本的颜色表。
340
+
341
+ **@techui/colors** 曾用名为 **ayin-color**,是一个颜色库工具,旨在帮助开发者摆脱记忆 `#FF0000`、`RGB(255,0,0)` 等繁琐颜色值的困扰,使用更接近自然语言的方式来定义和调用颜色。
342
+
343
+ ### ✨ 特性
344
+
345
+ - 🎨 **自然语言式命名** - 使用直观的颜色名称,如 `rel5`(红色)、`bll5`(蓝色)
346
+ - 📦 **双版本支持** - 提供 V1 和 V2 两个版本,V2 拥有更丰富的颜色数量
347
+ - 🔧 **多平台兼容** - 同时支持 JavaScript 和 Less/CSS 版本
348
+ - 🌈 **科学配色** - 基于 HSL 色彩模型,通过色相、饱和度、明暗度生成完整色谱
349
+ - 🎯 **开箱即用** - 预设数百种颜色值,快速开发
350
+ - 📄 **内置预览文件** - 根据preview.html快速查看复制所需颜色,进行快速入门,入门后即可通过自然语义快速调用颜色无需查表。
351
+
352
+ ### 🚀 快速开始
353
+
354
+ #### JavaScript 使用方式
355
+
356
+ 在项目入口文件(如 `main.js`)中引入:
357
+
358
+ ```javascript
359
+ import tuiColors from "@techui/colors"
360
+ Vue.use(tuiColors)
361
+ //此时你可以在项目中任意位置使用$c,$chroma
362
+ ```
363
+
364
+ 或者在组件或者页面中使用import引入使用,如:
365
+
366
+ ```javascript
367
+ import { $c, $chroma } from "@techui/colors"
368
+ const color=$c.rel5
369
+ ```
370
+
371
+ 使用示例:
372
+
373
+ ```javascript
374
+ // TechUI/Colors V1 - 使用基础色
375
+ let color = $c.rel5 // 红色
376
+ let blue = $c.bll5 // 蓝色
377
+ let gray = $c.gyd4 // 灰色
378
+
379
+ // TechUI/Colors V2 - 使用扩展色
380
+ let color2 = $c.reA10 // 红色(更细腻的色阶)
381
+ let blue2 = $c.blA03 // 蓝色
382
+ ```
383
+
384
+ #### CSS/Less 使用方式
385
+
386
+ ##### Vue 2 (vue.config.js)
387
+
388
+ 需要先安装依赖:`less`、`less-loader`、`style-resources-loader`
389
+
390
+ ```javascript
391
+ const path = require('path')
392
+
393
+ module.exports = {
394
+ pluginOptions: {
395
+ 'style-resources-loader': {
396
+ preProcessor: 'less',
397
+ patterns: [
398
+ path.resolve(__dirname, "./node_modules/@techui/colors/base.less"),
399
+ path.resolve(__dirname, "./node_modules/@techui/colors/extended.less")
400
+ ]
401
+ }
402
+ }
403
+ }
404
+ ```
405
+
406
+ ##### Vue 3 + Vite (vite.config.js)
407
+
408
+ 需要先安装依赖:`less`、`less-loader`
409
+
410
+ ```javascript
411
+ import { defineConfig } from 'vite'
412
+ import path from 'path'
413
+
414
+ export default defineConfig({
415
+ css: {
416
+ preprocessorOptions: {
417
+ less: {
418
+ javascriptEnabled: true,
419
+ additionalData: `
420
+ @import "${path.resolve(__dirname, './node_modules/@techui/colors/base.less')}";
421
+ @import "${path.resolve(__dirname, './node_modules/@techui/colors/extended.less')}";
422
+ `
423
+ }
424
+ }
425
+ }
426
+ })
427
+ ```
428
+
429
+ 在样式文件中使用:
430
+
431
+ ```less
432
+ // TechUI/Colors V1
433
+ .text {
434
+ color: @rel5;
435
+ background-color: @bll5;
436
+ border: 1px solid @gyd4;
437
+ }
438
+
439
+ // TechUI/Colors V2
440
+ .text-v2 {
441
+ color: @reA10;
442
+ background-color: @blA03;
443
+ border: 1px solid @gyE05;
444
+ }
445
+ ```
446
+
447
+ ### 🎨 颜色命名规则
448
+
449
+ #### V1 版本命名规则
450
+
451
+ 颜色命名由 **基础色** + **饱和度** + **明暗度** 组成。
452
+
453
+ **25 种基础色**(色相间隔 15°):
454
+
455
+ - `re` - 红色 (red)
456
+ - `or` - 橙色 (orange)
457
+ - `ye` - 黄色 (yellow)
458
+ - `ch` - 草绿 (chartreuse)
459
+ - `gr` - 绿色 (green)
460
+ - `aq` - 水绿 (aquamarine)
461
+ - `cy` - 青色 (cyan)
462
+ - `bl` - 蓝色 (blue)
463
+ - `in` - 靛色 (indigo)
464
+ - `pu` - 紫色 (purple)
465
+ - `pi` - 粉色 (pink)
466
+ - `vi` - 罗兰红 (violetred)
467
+ - `gy` - 灰色 (gray)
468
+ - 以及中间色:`ro`、`oy`、`yc`、`cg`、`ga`、`ac`、`cb`、`bi`、`ip`、`pp`、`pv`、`vr`
469
+
470
+ **4 种饱和度**:
471
+
472
+ - `l` - light(淡)
473
+ - `m` - middle(中)
474
+ - `r` - rost(烤)
475
+ - `d` - dark(深)
476
+
477
+ **9 级明暗度**:`1`(最淡)到 `9`(最深)
478
+
479
+ **示例**:
480
+
481
+ - `rel5` - 红色,light 饱和度,5 级明暗
482
+ - `bld1` - 蓝色,dark 饱和度,1 级明暗(淡蓝深饱和)
483
+ - `rel9` - 红色,light 饱和度,9 级明暗(深红)
484
+
485
+ #### V2 版本命名规则
486
+
487
+ V2 版本提供更细腻的色阶变化。
488
+
489
+ **饱和度**:`A`、`B`、`C`、`D`、`E`、`F` 六种
490
+
491
+ **明暗度**:`01` 到 `19` 共 19 级
492
+
493
+ **示例**:
494
+
495
+ - `reA10` - 红色,A 饱和度,10 级明暗
496
+ - `blE05` - 蓝色,E 饱和度,5 级明暗
497
+
498
+ ### 🔧 进阶功能
499
+
500
+ #### JavaScript 颜色处理函数
501
+
502
+ 基于 chroma.js 封装的颜色处理函数:
503
+
504
+ ```javascript
505
+ // 透明度
506
+ let color = $c.fade('bll5', 0.5) // 50% 透明度
507
+
508
+ // 色相调整
509
+ let hue = $c.hslh('rel5', 30) // 色相偏移 30°
510
+
511
+ // 饱和度调整
512
+ let sat = $c.hsls('rel5', 0.8)
513
+
514
+ // 明暗调整
515
+ let light = $c.hsll('rel5', 0.6)
516
+
517
+ // 加深/减淡
518
+ let darker = $c.darken('bll5', 0.2)
519
+ let lighter = $c.lighten('bll5', 0.2)
520
+
521
+ // 颜色渐变(生成多个颜色之间的过渡色)
522
+ let gradient = $c.scale(['rel5', 'bll5', 'yel5'], 10, 'lch')
523
+ // 参数:颜色数组(最少2个)、需要的颜色数量、混合模式(lch/hsl/lab/lrgb,默认 lch)
524
+ ```
525
+
526
+ #### 进阶颜色工具函数
527
+
528
+ ```javascript
529
+ // 1. 解析颜色 — 支持预定义颜色名、@ 前缀写法,以及原始 Hex/RGB 值
530
+ const blue = $c.resolve('bll5')
531
+ const blueFromToken = $c.resolve('@bll5')
532
+
533
+ // 2. 校验颜色是否有效
534
+ const isValidPreset = $c.valid('bll5') // true
535
+ const isValidHex = $c.valid('#1677ff') // true
536
+
537
+ // 3. 表达式语法 — 管道式颜色变换简写
538
+ const softBlue = $c.expr('@bll5|.3') // 等同于 fade 30% 透明度
539
+ const softHex = $c.expr('#1677ff|.4') // 普通 Hex 颜色同样支持
540
+ const fadeBlue = $c.expr('@bll5|fade(.3)') // 显式 fade
541
+ const lightBlue = $c.expr('@bll5|lighten(2)') // 提亮
542
+ const darkBlue = $c.expr('@bll5|darken(1)') // 加深
543
+ const customL = $c.expr('@bll5|hsll(.35)') // 设置 HSL 亮度
544
+
545
+ // 4. 根据基础色生成语义色阶
546
+ const colors = $c.genColors('bll5', 7)
547
+ // 参数:基础色(或颜色数组)、数量、每步色相偏移量、饱和度衰减系数
548
+
549
+ // 5. 将色阶数组转换为语义对象,并附加透明度变体
550
+ const colorObj = $c.genColorObj(colors, [0.9, 0.7, 0.5])
551
+ // 结果包含 weak / base / strong 等语义键,以及对应的透明度变体
552
+ ```
553
+
554
+ ##### 表达式语法速查
555
+
556
+ | 写法 | 等价调用 | 说明 |
557
+ | --- | --- | --- |
558
+ | `@bll5` | `$c.resolve('bll5')` | `@` 明确表示 TechUI Colors 预定义颜色名 |
559
+ | `@bll5\|.3` | `$c.fade('bll5', .3)` | 管道后接数字,默认为透明度 |
560
+ | `@bll5\|fade(.3)` | `$c.fade('bll5', .3)` | 显式透明度处理 |
561
+ | `@bll5\|lighten(2)` | `$c.lighten('bll5', 2)` | 提亮颜色 |
562
+ | `@bll5\|darken(1)` | `$c.darken('bll5', 1)` | 加深颜色 |
563
+ | `@bll5\|hsll(.35)` | `$c.hsll('bll5', .35)` | 设置 HSL 亮度 |
564
+ | `#1677ff\|.4` | `$c.fade('#1677ff', .4)` | 普通 Hex 颜色同样支持表达式 |
565
+
566
+ #### Less 颜色处理函数
567
+
568
+ ```less
569
+ .element {
570
+ // 透明度
571
+ color: fade(@bll5, 50%);
572
+
573
+ // 明暗调整
574
+ background: lighten(@rel5, 20%);
575
+ border-color: darken(@bll5, 10%);
576
+
577
+ // 饱和度调整
578
+ box-shadow: 0 0 10px saturate(@rel5, 20%);
579
+
580
+ // 色相旋转
581
+ outline-color: spin(@rel5, 30);
582
+
583
+ // 颜色混合
584
+ background: mix(@rel5, @bll5, 50%);
585
+ }
586
+ ```
587
+
588
+ 更多 Less 颜色函数请参考 [Less 官方文档](http://lesscss.org/functions/#color-operations)。
589
+
590
+ ### 📖 版本选择建议
591
+
592
+ #### 使用 V1 版本
593
+
594
+ - ✅ 日常项目开发
595
+ - ✅ 快速原型设计
596
+ - ✅ 需要易于记忆和掌控的配色方案
597
+ - ✅ 一般 Web 应用和管理后台
598
+
599
+ V1 版本颜色数量适中,易于掌握,能够满足绝大多数项目的配色需求。
600
+
601
+ #### 使用 V2 版本
602
+
603
+ - ✅ 数据可视化项目
604
+ - ✅ 大屏展示系统
605
+ - ✅ 需要精细色阶控制
606
+ - ✅ 专业设计项目
607
+
608
+ V2 版本提供更细腻的颜色变化,适合对配色有更高要求的场景。
609
+
610
+ ### 🔨 开发工具
611
+
612
+ #### 颜色转换工具
613
+
614
+ 项目提供了颜色转换工具,可以将普通颜色值转换为 TechUI/Colors 格式。
615
+
616
+ 支持输入格式:
617
+
618
+ - 颜色名称:`red`
619
+ - 十六进制:`#FF0000`
620
+ - RGB/RGBA:`rgb(255, 0, 0)`、`rgba(255, 0, 0, 0.5)`
621
+
622
+ 工具会返回 V1 和 V2 版本中的最佳匹配结果。距离参数越小表示与原始颜色越接近。
623
+
624
+ 工具位于 `aYinColor-V2 source` 目录中。
625
+
626
+ ### 📂 包含文件
627
+
628
+ - `ayin-color.less` - V1 CSS 版本
629
+ - `ayin-color-extended.less` - V2 CSS 版本
630
+ - `ayin-color.js` - JavaScript 版本
631
+ - `ayin-color.json` - 静态颜色值 JSON 文件
632
+ - `index.js` - 入口文件
633
+ - `preview.html` - 离线版颜色表预览查询匹配工具
634
+
635
+ ### 🎯 设计原理
636
+
637
+ TechUI/Colors 基于 HSL 色彩模型设计:
638
+
639
+ 1. **色相 (Hue)**:从纯红色 `#FF0000` 开始,每隔 15° 生成一个基础色,共 24 个基础色 + 1 个灰色
640
+ 2. **饱和度 (Saturation)**:V1 提供 4 级,V2 提供 6 级
641
+ 3. **明度 (Lightness)**:V1 提供 9 级,V2 提供 19 级
642
+
643
+ 这种设计使得颜色调用更加直观和系统化。
644
+
645
+ ### 📚 相关链接
262
646
 
263
- - 🏠 [Official Website](https://techui.net/)
264
- - 📦 [npm Package](https://www.npmjs.com/package/@techui/colors)
265
- - 💻 [GitHub Repository](https://github.com/aYin86cn/ayin-color)
266
- - 🎥 [Bilibili Video Tutorial](https://space.bilibili.com/302402751)
267
- - 🎨 [Color Table Preview](https://ayin86.com/)
647
+ - 🏠 [官方网站](https://techui.net)
648
+ - 📦 [npm ](https://www.npmjs.com/package/@techui/colors)
649
+ - 💻 [GitHub 仓库](https://github.com/aYin86cn/ayin-color)
650
+ - 🎥 [Bilibili 视频教程](https://space.bilibili.com/302402751)
651
+ - 🎨 [颜色表预览](https://techui.net/)
268
652
 
269
- ## 👨‍💻 Author
653
+ ### 👨‍💻 作者
270
654
 
271
655
  **Ayin**
272
656
 
273
- - Email: <ayin86cn@gmail.com>
274
- - WeChat: jay1986cn
657
+ - Email: [ayin86cn@gmail.com](mailto:ayin86cn@gmail.com)
658
+ - WeChat: jay1986cn
275
659
 
276
- ## 🙏 Acknowledgments
660
+ ### 🙏 致谢
277
661
 
278
- - Built with [chroma.js](https://gka.github.io/chroma.js/)
279
- - Thanks to all developers who use and support @techui/colors
662
+ - 基于 [chroma.js](https://gka.github.io/chroma.js/) 开发
663
+ - 感谢所有使用和支持 @techui/colors 的开发者