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