├── image └── icon.png ├── pages ├── tools │ ├── shade │ │ ├── shade.json │ │ ├── shade.wxss │ │ ├── shade.wxml │ │ └── shade.js │ ├── triad │ │ ├── triad.json │ │ ├── triad.wxss │ │ ├── triad.wxml │ │ └── triad.js │ ├── analogous │ │ ├── analogous.json │ │ ├── analogous.wxss │ │ ├── analogous.wxml │ │ └── analogous.js │ ├── secondary │ │ ├── secondary.json │ │ ├── secondary.wxml │ │ ├── secondary.wxss │ │ └── secondary.js │ ├── complementary │ │ ├── complementary.json │ │ ├── complementary.wxss │ │ ├── complementary.wxml │ │ └── complementary.js │ ├── monochromatic │ │ ├── monochromatic.json │ │ ├── monochromatic.wxss │ │ ├── monochromatic.wxml │ │ └── monochromatic.js │ ├── tools.json │ ├── lucky │ │ ├── lucky.json │ │ ├── lucky.wxml │ │ ├── lucky.wxss │ │ └── lucky.js │ ├── tools.wxss │ ├── tools.wxml │ └── tools.js ├── web │ ├── csscolor │ │ ├── csscolor.json │ │ ├── csscolor.wxss │ │ ├── csscolor.wxml │ │ └── csscolor.js │ ├── webcolor │ │ ├── webcolor.json │ │ ├── webcolor.wxss │ │ ├── webcolor.wxml │ │ └── webcolor.js │ ├── colordetail.json │ ├── graylevel │ │ ├── graylevel.json │ │ ├── graylevel.wxss │ │ ├── graylevel.wxml │ │ └── graylevel.js │ ├── web.json │ ├── colordetail.wxss │ ├── web.wxml │ ├── web.wxss │ ├── web.js │ ├── colordetail.js │ └── colordetail.wxml ├── transition │ ├── transition.json │ ├── transition.wxss │ └── transition.wxml ├── about │ ├── about.json │ ├── about.wxss │ ├── about.js │ └── about.wxml ├── plaza │ ├── edit.json │ ├── china.json │ ├── japan.json │ ├── myfav.json │ ├── fav.json │ ├── detail.json │ ├── index.json │ ├── adobe.json │ ├── china.wxss │ ├── japan.wxss │ ├── adobe.wxss │ ├── myfav.wxss │ ├── index.wxml │ ├── china.wxml │ ├── japan.wxml │ ├── index.wxss │ ├── myfav.wxml │ ├── adobe.wxml │ ├── fav.wxss │ ├── detail.wxss │ ├── detail.wxml │ ├── fav.wxml │ ├── index.js │ ├── myfav.js │ ├── adobe.js │ ├── edit.wxml │ ├── edit.wxss │ ├── fav.js │ ├── detail.js │ ├── edit.js │ └── china.js └── index │ ├── index.json │ ├── index.wxml │ ├── index.wxss │ └── index.js ├── sitemap.json ├── project.config.json ├── app.wxss ├── utils ├── constant.js ├── functions.js ├── common.js ├── algorithm.js └── colors.js ├── app.json ├── app.js ├── README.md ├── CODE_OF_CONDUCT.md └── style └── iconfont.wxss /image/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czcaiwj/color/HEAD/image/icon.png -------------------------------------------------------------------------------- /pages/tools/shade/shade.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "渐变" 3 | } -------------------------------------------------------------------------------- /pages/tools/triad/triad.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "分裂补色" 3 | } -------------------------------------------------------------------------------- /pages/tools/analogous/analogous.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "类比色" 3 | } -------------------------------------------------------------------------------- /pages/web/csscolor/csscolor.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "CSS 颜色值" 3 | } -------------------------------------------------------------------------------- /pages/web/webcolor/webcolor.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "Web 安全色" 3 | } -------------------------------------------------------------------------------- /pages/tools/secondary/secondary.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "二次色配比" 3 | } -------------------------------------------------------------------------------- /pages/tools/complementary/complementary.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "互补色" 3 | } -------------------------------------------------------------------------------- /pages/tools/monochromatic/monochromatic.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "单色" 3 | } -------------------------------------------------------------------------------- /pages/web/colordetail.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePullDownRefresh": false, 3 | "disableScroll": true 4 | } -------------------------------------------------------------------------------- /pages/transition/transition.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "颜色转换", 3 | "backgroundColor": "#FFFFFF" 4 | } -------------------------------------------------------------------------------- /pages/web/graylevel/graylevel.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "灰阶灰度", 3 | "backgroundColor": "#FFFFFF" 4 | } -------------------------------------------------------------------------------- /pages/about/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "关于Color颜值", 3 | "navigationBarBackgroundColor": "#fff" 4 | } -------------------------------------------------------------------------------- /pages/plaza/edit.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "编辑收藏", 3 | "enablePullDownRefresh": false, 4 | "disableScroll": true 5 | } -------------------------------------------------------------------------------- /pages/tools/tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "色彩工具", 3 | "enablePullDownRefresh": false, 4 | "disableScroll": true 5 | } -------------------------------------------------------------------------------- /pages/web/web.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "Web 颜色", 3 | "enablePullDownRefresh": false, 4 | "disableScroll": true 5 | } -------------------------------------------------------------------------------- /pages/tools/lucky/lucky.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "I am Feeling Lucky", 3 | "enablePullDownRefresh": false, 4 | "disableScroll": true 5 | } -------------------------------------------------------------------------------- /pages/plaza/china.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "中国传统色彩", 3 | "navigationBarBackgroundColor": "#242424", 4 | "navigationBarTextStyle": "white" 5 | } -------------------------------------------------------------------------------- /pages/plaza/japan.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "日本传统色彩", 3 | "navigationBarBackgroundColor": "#242424", 4 | "navigationBarTextStyle": "white" 5 | } -------------------------------------------------------------------------------- /pages/plaza/myfav.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTextStyle": "white", 3 | "navigationBarBackgroundColor": "#242424", 4 | "navigationBarTitleText": "我的收藏" 5 | } -------------------------------------------------------------------------------- /sitemap.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", 3 | "rules": [{ 4 | "action": "allow", 5 | "page": "*" 6 | }] 7 | } -------------------------------------------------------------------------------- /pages/plaza/fav.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarBackgroundColor": "#242424", 3 | "navigationBarTextStyle": "white", 4 | "navigationBarTitleText": "配色详情", 5 | "enablePullDownRefresh": false, 6 | "disableScroll": true 7 | } -------------------------------------------------------------------------------- /pages/plaza/detail.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarBackgroundColor": "#242424", 3 | "navigationBarTextStyle": "white", 4 | "navigationBarTitleText": "配色详情", 5 | "enablePullDownRefresh": false, 6 | "disableScroll": true 7 | } -------------------------------------------------------------------------------- /pages/plaza/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "配色广场", 3 | "navigationBarBackgroundColor": "#cca4e3", 4 | "navigationBarTextStyle": "white", 5 | "enablePullDownRefresh": false, 6 | "disableScroll": true 7 | } -------------------------------------------------------------------------------- /pages/plaza/adobe.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTextStyle": "white", 3 | "navigationBarBackgroundColor": "#242424", 4 | "navigationBarTitleText": "Adobe 配色方案", 5 | "enablePullDownRefresh": false, 6 | "disableScroll": true 7 | } -------------------------------------------------------------------------------- /pages/web/graylevel/graylevel.wxss: -------------------------------------------------------------------------------- 1 | /* pages/web/graylevel/graylevel.wxss */ 2 | .box 3 | { 4 | display: flex; 5 | align-items: center; 6 | } 7 | 8 | .box p 9 | { 10 | min-width: 80px; 11 | } 12 | 13 | .cell 14 | { 15 | flex-grow: 1; 16 | } -------------------------------------------------------------------------------- /pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarBackgroundColor": "#1e8cd4", 3 | "backgroundColor": "#1e8cd4", 4 | "navigationBarTextStyle": "white", 5 | "navigationBarTitleText": " ", 6 | "enablePullDownRefresh": false, 7 | "disableScroll": true 8 | } -------------------------------------------------------------------------------- /pages/web/colordetail.wxss: -------------------------------------------------------------------------------- 1 | /* pages/common/colordetail.wxss */ 2 | .preview 3 | { 4 | margin-top: 20px; 5 | margin-bottom: 10px; 6 | } 7 | 8 | .value 9 | { 10 | margin-top: 20px; 11 | margin-bottom: 20px; 12 | } 13 | 14 | .value p 15 | { 16 | margin-bottom: 10px; 17 | } -------------------------------------------------------------------------------- /pages/plaza/china.wxss: -------------------------------------------------------------------------------- 1 | /* pages/plaza/china.wxss */ 2 | 3 | .layer { 4 | background-color: #242424; 5 | } 6 | 7 | .cell 8 | { 9 | display: flex; 10 | flex-direction: column; 11 | align-items: center; 12 | justify-content: center; 13 | margin: 15px; 14 | border-radius: 10px; 15 | padding: 20px; 16 | } -------------------------------------------------------------------------------- /pages/plaza/japan.wxss: -------------------------------------------------------------------------------- 1 | /* pages/plaza/china.wxss */ 2 | 3 | .layer { 4 | background-color: #242424; 5 | } 6 | 7 | .cell 8 | { 9 | display: flex; 10 | flex-direction: column; 11 | align-items: center; 12 | justify-content: center; 13 | margin: 15px; 14 | border-radius: 10px; 15 | padding: 20px; 16 | } -------------------------------------------------------------------------------- /pages/tools/tools.wxss: -------------------------------------------------------------------------------- 1 | /* pages/tools/tools.wxss */ 2 | .box 3 | { 4 | display: flex; 5 | flex-direction: column; 6 | color: white; 7 | } 8 | 9 | .cell 10 | { 11 | flex-grow: 1; 12 | display: flex; 13 | align-items: center; 14 | padding-left:20px; 15 | padding-right:10px; 16 | text-align: center; 17 | font-size: 1.2rem; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /pages/web/web.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |

CSS 颜色值

4 |

Web 安全色

5 |

Gray 灰度值

6 |
7 |
-------------------------------------------------------------------------------- /pages/about/about.wxss: -------------------------------------------------------------------------------- 1 | /* pages/about/about.wxss */ 2 | .post { 3 | margin-top: 15px; 4 | margin-bottom: 15px; 5 | padding: 15px 20px 10px 20px; 6 | border: 1px solid rgba(39, 48, 57, 0.08); 7 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 8 | border-radius:17px; 9 | } 10 | 11 | .post p 12 | { 13 | margin-bottom: 5px; 14 | } 15 | 16 | .bottom-ad { 17 | margin-bottom: 20px; 18 | } -------------------------------------------------------------------------------- /pages/plaza/adobe.wxss: -------------------------------------------------------------------------------- 1 | /* pages/plaza/adobe.wxss */ 2 | 3 | .layer { 4 | background-color: #242424; 5 | } 6 | 7 | .cell { 8 | display: flex; 9 | align-items: center; 10 | margin-top: 20px; 11 | } 12 | 13 | .random { 14 | padding: 10px; 15 | background-color: #5b7e91; 16 | color: white; 17 | text-align: center; 18 | position:fixed; 19 | bottom:0; 20 | left:0; 21 | right:0; 22 | } -------------------------------------------------------------------------------- /pages/plaza/myfav.wxss: -------------------------------------------------------------------------------- 1 | /* pages/plaza/myfav.wxss */ 2 | 3 | .layer { 4 | background-color: #242424; 5 | } 6 | 7 | .cell { 8 | display: flex; 9 | align-items: center; 10 | margin-top: 20px; 11 | } 12 | 13 | .random { 14 | padding: 10px; 15 | background-color: #5b7e91; 16 | color: white; 17 | text-align: center; 18 | position:fixed; 19 | bottom:0; 20 | left:0; 21 | right:0; 22 | } -------------------------------------------------------------------------------- /pages/web/csscolor/csscolor.wxss: -------------------------------------------------------------------------------- 1 | /* pages/web/csscolor/csscolor.wxss */ 2 | .post { 3 | margin-top: 15px; 4 | margin-bottom: 15px; 5 | padding: 15px 20px 10px 20px; 6 | border: 1px solid rgba(39, 48, 57, 0.08); 7 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 8 | } 9 | 10 | .post p { 11 | font-size: small; 12 | margin-bottom: 5px; 13 | } 14 | 15 | .color { 16 | padding: 20px; 17 | } 18 | -------------------------------------------------------------------------------- /pages/plaza/index.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
中国传统色彩
4 |
日本传统色彩
5 |
Adobe 配色方案
6 |
我的收藏
7 |
8 |
-------------------------------------------------------------------------------- /pages/web/graylevel/graylevel.wxml: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 |

{{item.hex}}

6 |
7 |
8 |
9 |
10 |
11 |
-------------------------------------------------------------------------------- /pages/plaza/china.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |

{{item.name}}

6 |

{{item.hex}}

7 |
8 |
9 |
10 |
-------------------------------------------------------------------------------- /pages/plaza/japan.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |

{{item.name}}

6 |

{{item.hex}}

7 |
8 |
9 |
10 |
-------------------------------------------------------------------------------- /pages/tools/tools.wxml: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | 5 |
6 |

{{item.name}}

7 |

8 |
9 |
10 |
11 |
-------------------------------------------------------------------------------- /pages/web/web.wxss: -------------------------------------------------------------------------------- 1 | /* pages/web/web.wxss */ 2 | .box 3 | { 4 | display: flex; 5 | flex-direction: column; 6 | } 7 | 8 | .cell 9 | { 10 | flex-grow: 1; 11 | display: flex; 12 | justify-content: center; 13 | align-items: center; 14 | color: white; 15 | } 16 | 17 | .css 18 | { 19 | background-color: #3498DB; 20 | } 21 | 22 | .web 23 | { 24 | background-color: #E74C3C; 25 | } 26 | 27 | .gray 28 | { 29 | background-color: #ECF0F1; 30 | color: black; 31 | } 32 | 33 | .cell p 34 | { 35 | font-size: 2rem; 36 | } -------------------------------------------------------------------------------- /pages/web/webcolor/webcolor.wxss: -------------------------------------------------------------------------------- 1 | /* pages/web/webcolor/webcolor.wxss */ 2 | .post { 3 | margin-top: 15px; 4 | margin-bottom: 15px; 5 | padding: 15px 20px 10px 20px; 6 | border: 1px solid rgba(39, 48, 57, 0.08); 7 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 8 | } 9 | 10 | .post p { 11 | font-size: small; 12 | margin-bottom: 5px; 13 | } 14 | 15 | .box 16 | { 17 | display: flex; 18 | align-items: center; 19 | margin-bottom: 10px; 20 | } 21 | 22 | .cell 23 | { 24 | flex-grow: 1; 25 | text-align: center; 26 | } -------------------------------------------------------------------------------- /pages/plaza/index.wxss: -------------------------------------------------------------------------------- 1 | /* pages/plaza/index.wxss */ 2 | .box 3 | { 4 | display: flex; 5 | flex-direction: column; 6 | color: white; 7 | } 8 | 9 | .cell 10 | { 11 | flex-grow: 1; 12 | display: flex; 13 | align-items: center; 14 | font-size: 1.2rem; 15 | justify-content:center; 16 | } 17 | 18 | .china 19 | { 20 | background-color: #ff461f; 21 | } 22 | 23 | .japan { 24 | background-color: #88ada6; 25 | } 26 | 27 | .adobe { 28 | background-color: #003371; 29 | } 30 | 31 | .fav { 32 | background-color: #ef7a82; 33 | } -------------------------------------------------------------------------------- /project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件。", 3 | "setting": { 4 | "urlCheck": true, 5 | "es6": true, 6 | "postcss": true, 7 | "minified": true, 8 | "newFeature": true 9 | }, 10 | "compileType": "miniprogram", 11 | "libVersion": "2.1.3", 12 | "appid": "wx76521f8fd4a8a481", 13 | "projectname": "%E4%BB%A3%E7%A0%81", 14 | "simulatorType": "wechat", 15 | "simulatorPluginLibVersion": {}, 16 | "condition": { 17 | "search": { 18 | "current": -1, 19 | "list": [] 20 | }, 21 | "conversation": { 22 | "current": -1, 23 | "list": [] 24 | }, 25 | "miniprogram": { 26 | "current": -1, 27 | "list": [] 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | /*重建样式表*/ 2 | /*@import "style/reset.wxss";*/ 3 | /*HTML基础样式*/ 4 | /*@import "style/base.wxss";*/ 5 | /*容器样式*/ 6 | /*@import "style/components.wxss"; 7 | /*图标字体*/ 8 | /*@import "style/iconfont.wxss"; */ 9 | /*主题文件*/ 10 | /*@import "style/theme.wxss";*/ 11 | 12 | 13 | @import 'style/codingui.wxss'; 14 | @import 'style/animated.wxss'; 15 | @import 'style/iconfont.wxss'; 16 | 17 | button::after { 18 | content: none; 19 | } 20 | 21 | .addfooter 22 | { 23 | height: 20px; 24 | } 25 | 26 | .layer 27 | { 28 | position: fixed; 29 | top: 0; 30 | left: 0; 31 | right: 0; 32 | bottom: 0; 33 | z-index: -2; 34 | } 35 | -------------------------------------------------------------------------------- /pages/index/index.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Color

4 |

颜值

5 |
6 |
7 |

配色广场

8 |

颜色转换

9 |

色彩工具

10 |

Web颜色

11 |

关于颜值

12 |
13 |
14 | 15 |
-------------------------------------------------------------------------------- /pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | .layer 2 | { 3 | background-color: #1e8cd4; 4 | } 5 | 6 | p { 7 | color: white; 8 | } 9 | 10 | .mainTitle 11 | { 12 | font-size: 3.5rem; 13 | margin-top: 40rpx; 14 | margin-bottom: 40rpx; 15 | } 16 | 17 | .subTitle 18 | { 19 | font-size: 2rem; 20 | margin-bottom: 70rpx; 21 | } 22 | 23 | .btn-item 24 | { 25 | background-color: rgba(255, 255, 255, .3); 26 | margin-bottom: 30rpx; 27 | padding: 16rpx; 28 | border-radius: 40rpx; 29 | } 30 | 31 | .btn-timeline 32 | { 33 | background-color: transparent; 34 | position: fixed; 35 | left: 0; 36 | bottom: 10px; 37 | } 38 | 39 | .btn-timeline p 40 | { 41 | font-size: 1.5rem; 42 | } 43 | 44 | .btn-share 45 | { 46 | background-color: transparent; 47 | position: fixed; 48 | right: 0; 49 | bottom: 10px; 50 | } 51 | 52 | .btn-share p 53 | { 54 | font-size: 1.5rem; 55 | } -------------------------------------------------------------------------------- /pages/plaza/myfav.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |

{{item.name}}

12 |
13 |
14 |
-------------------------------------------------------------------------------- /pages/about/about.js: -------------------------------------------------------------------------------- 1 | // pages/about/about.js 2 | const { onShare, httpGet } = require('../../utils/functions.js'); 3 | const { ABOUT_CONTENT } = require('../../utils/constant.js'); 4 | 5 | Page({ 6 | data: { 7 | about: '', 8 | author: '', 9 | email: '', 10 | show_contact: 0 11 | }, 12 | 13 | onLoad: function () { 14 | const url = ABOUT_CONTENT; 15 | const that = this; 16 | httpGet(url).then(data => { 17 | if (data.code == 0) { 18 | const res = data.data; 19 | that.setData({ 20 | about: res['about'].split("|"), 21 | author: res['author'], 22 | email: res['email'], 23 | show_contact: res['show_contact'] 24 | }); 25 | } 26 | }); 27 | }, 28 | 29 | onShareAppMessage: function (res) { 30 | return onShare("Color颜值,优秀的配色助手"); 31 | } 32 | }) -------------------------------------------------------------------------------- /pages/plaza/adobe.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |

{{item.name}}

12 |
13 |

Surprise Me

14 |
-------------------------------------------------------------------------------- /utils/constant.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 常量文件 3 | */ 4 | 5 | const ROOT_DOMAIN = 'https://imcoding.org/Color/'; // 根域名 6 | const ROOT_DOMAIN2 = 'https://junlink.cn/Color/'; 7 | 8 | const USER_LOGIN = ROOT_DOMAIN2 + 'User/login'; // 用户登录 9 | const GET_ADOBE_COLORS = ROOT_DOMAIN2 + 'Adobe/getAdobeColors'; // 随机获取Adobe配色方案 10 | const SAVE_USER_COLORS = ROOT_DOMAIN2 + 'User/saveColor'; // 保存用户配色方案 11 | const GET_USER_COLORS = ROOT_DOMAIN2 + 'User/getColor'; // 获取用户配色方案 12 | const DELETE_USER_COLORS = ROOT_DOMAIN2 + 'User/deleteColor'; // 删除用户配色方案 13 | const UPDATE_USER_COLORS = ROOT_DOMAIN2 + 'User/saveColor'; // 更新用户配色方案 14 | const ABOUT_CONTENT = ROOT_DOMAIN2 + 'Config/about'; // 获取关于信息 15 | 16 | module.exports = { 17 | USER_LOGIN, // 用户登录 18 | GET_ADOBE_COLORS, // 随机获取Adobe配色方案 19 | SAVE_USER_COLORS, // 保存用户配色方案 20 | GET_USER_COLORS, // 获取用户配色方案 21 | DELETE_USER_COLORS, // 删除用户配色方案 22 | UPDATE_USER_COLORS, // 更新用户配色方案 23 | ABOUT_CONTENT, // 获取关于信息 24 | }; -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index", 4 | "pages/plaza/index", 5 | "pages/plaza/china", 6 | "pages/plaza/japan", 7 | "pages/plaza/adobe", 8 | "pages/plaza/myfav", 9 | "pages/plaza/detail", 10 | "pages/plaza/edit", 11 | "pages/plaza/fav", 12 | "pages/transition/transition", 13 | "pages/tools/tools", 14 | "pages/tools/lucky/lucky", 15 | "pages/tools/analogous/analogous", 16 | "pages/tools/triad/triad", 17 | "pages/tools/monochromatic/monochromatic", 18 | "pages/tools/complementary/complementary", 19 | "pages/tools/shade/shade", 20 | "pages/tools/secondary/secondary", 21 | "pages/web/web", 22 | "pages/web/colordetail", 23 | "pages/web/webcolor/webcolor", 24 | "pages/web/graylevel/graylevel", 25 | "pages/web/csscolor/csscolor", 26 | "pages/about/about" 27 | ], 28 | "window": { 29 | "backgroundColor": "#FFFFFF", 30 | "backgroundTextStyle": "light", 31 | "navigationBarBackgroundColor": "#FFFFFF", 32 | "navigationBarTitleText": "Color颜值", 33 | "navigationBarTextStyle": "black", 34 | "enablePullDownRefresh": false 35 | }, 36 | "sitemapLocation": "sitemap.json" 37 | } -------------------------------------------------------------------------------- /pages/plaza/fav.wxss: -------------------------------------------------------------------------------- 1 | /* pages/plaza/fav.wxss */ 2 | 3 | .colorgroup 4 | { 5 | display: flex; 6 | justify-content: center; 7 | align-items: center; 8 | padding-top: 15px; 9 | padding-bottom: 5px; 10 | margin-left: 10px; 11 | margin-right: 10px; 12 | margin-top: 50px; 13 | margin-bottom: 50px; 14 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 15 | } 16 | 17 | .color-item 18 | { 19 | flex-grow: 1; 20 | } 21 | 22 | .colorgroup p 23 | { 24 | font-size: small; 25 | color: #888; 26 | padding: 5px; 27 | } 28 | 29 | 30 | .layer { 31 | background-color: #242424; 32 | } 33 | 34 | .box 35 | { 36 | display: flex; 37 | align-items: center; 38 | justify-content:center; 39 | } 40 | 41 | .name 42 | { 43 | border-bottom: 1px solid paleturquoise; 44 | padding: 5px; 45 | color: white; 46 | } 47 | 48 | .info { 49 | color: white; 50 | margin: 36px; 51 | } 52 | 53 | .info p { 54 | margin-bottom: 10px; 55 | font-size: small; 56 | } 57 | 58 | .save { 59 | padding: 10px; 60 | background-color: #4c6cb3; 61 | color: white; 62 | text-align: center; 63 | position:fixed; 64 | bottom:0; 65 | left:0; 66 | right:0; 67 | } -------------------------------------------------------------------------------- /pages/about/about.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 |
6 | 7 |

{{item}}

8 |
9 |
10 | 11 |
12 |

13 | {{author}} 14 |

15 | 16 |

17 | {{email}} 18 |

19 |

20 | Designed By Coding 21 |

22 |
23 |
24 |
25 |
26 | 27 |
-------------------------------------------------------------------------------- /pages/tools/tools.js: -------------------------------------------------------------------------------- 1 | // 配色入口页 2 | const { onShare, preventDoubleClick } = require('../../utils/functions.js'); 3 | 4 | Page({ 5 | data: { 6 | height: 0, 7 | array: [ 8 | { name: "I am Feeling Lucky", color: "#bf76cc", url: "lucky" }, 9 | { name: "类比色 相似色", color: "#00c3d9", url: "analogous" }, 10 | { name: "互补色", color: "#01d48f", url: "complementary" }, 11 | { name: "分裂补色", color: "#018884", url: "triad" }, 12 | { name: "单色", color: "#f3c300", url: "monochromatic" }, 13 | { name: "渐变", color: "#de6e02", url: "shade" }, 14 | { name: "二次色配比", color: "#fd694c", url: "secondary" } 15 | ] 16 | }, 17 | 18 | onLoad: function (options) { 19 | const res = wx.getSystemInfoSync(); 20 | const height = res.windowHeight; 21 | this.setData({ height: height }); 22 | }, 23 | 24 | click: function (event) { 25 | if (!this.data.buttonClicked) { 26 | preventDoubleClick(this); 27 | const name = event.currentTarget.dataset.name; 28 | let url = '/pages/tools/' + name + '/' + name; 29 | wx.navigateTo({ url }); 30 | } 31 | }, 32 | 33 | onShareAppMessage: function (res) { 34 | return onShare("Color颜值,优秀的配色助手"); 35 | } 36 | }) -------------------------------------------------------------------------------- /pages/web/web.js: -------------------------------------------------------------------------------- 1 | // web颜色入口页 2 | const { preventDoubleClick, onShare } = require('../../utils/functions.js'); 3 | 4 | Page({ 5 | // 页面的初始数据 6 | data: { 7 | height: 0 8 | }, 9 | 10 | // 生命周期函数--监听页面加载 11 | onLoad: function (options) { 12 | const res = wx.getSystemInfoSync(); 13 | this.setData({ height: res.windowHeight }); 14 | }, 15 | 16 | // 点击跳转 17 | click: function (event) { 18 | if (!this.data.buttonClicked) { 19 | preventDoubleClick(this); 20 | const name = event.currentTarget.dataset.name; 21 | switch (name) { 22 | case "css": 23 | wx.navigateTo({ 24 | url: 'csscolor/csscolor', 25 | }); 26 | break; 27 | case "web": 28 | wx.navigateTo({ 29 | url: 'webcolor/webcolor', 30 | }); 31 | break; 32 | case "gray": 33 | wx.navigateTo({ 34 | url: 'graylevel/graylevel', 35 | }); 36 | break; 37 | } 38 | } 39 | }, 40 | 41 | onShareAppMessage: function (res) { 42 | return onShare("CSS颜色、Web安全色、灰度值"); 43 | } 44 | }) -------------------------------------------------------------------------------- /pages/plaza/detail.wxss: -------------------------------------------------------------------------------- 1 | /* pages/plaza/detail.wxss */ 2 | 3 | 4 | .layer { 5 | background-color: #242424; 6 | } 7 | 8 | .title { 9 | text-align: center; 10 | color: #ccc; 11 | margin: 20px; 12 | } 13 | 14 | .cell { 15 | display: flex; 16 | align-items: center; 17 | } 18 | 19 | .color-block 20 | { 21 | width: 65px; 22 | height: 65px; 23 | } 24 | 25 | .value { 26 | color: #ccc; 27 | width:60px; 28 | margin-left:20px; 29 | } 30 | 31 | .fixed-bottom { 32 | display:flex; 33 | flex-direction:row; 34 | flex-wrap:nowrap; 35 | align-items:center; 36 | justify-content:center; 37 | position:fixed; 38 | bottom:0; 39 | left:0; 40 | right:0; 41 | } 42 | 43 | .delete { 44 | flex-grow: 1; 45 | padding: 10px; 46 | background-color: #ec6d71; 47 | color: white; 48 | text-align: center; 49 | } 50 | 51 | .edit { 52 | flex-grow: 1; 53 | padding: 10px; 54 | background-color: #2ca9e1; 55 | color: white; 56 | text-align: center; 57 | } 58 | 59 | .fav { 60 | flex-grow: 1; 61 | padding: 10px; 62 | background-color: #ee827c; 63 | color: white; 64 | text-align: center; 65 | } 66 | 67 | .copy { 68 | flex-grow: 1; 69 | padding: 10px; 70 | background-color: #09bb07; 71 | color: white; 72 | text-align: center; 73 | } -------------------------------------------------------------------------------- /pages/plaza/detail.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |

{{name}}

4 | 5 |
6 |
7 |
8 |

R: {{item.rgb[0]}}

9 |

H: {{item.hsb[0]}}

10 |
11 |
12 |

G: {{item.rgb[1]}}

13 |

S: {{item.hsb[1]}}%

14 |
15 |
16 |

B: {{item.rgb[2]}}

17 |

B: {{item.hsb[2]}}%

18 |
19 |
20 |
21 | 22 |
23 |

收藏

24 |

复制

25 |
26 |
27 | 28 |
29 |

复制

30 |

编辑

31 |

删除

32 |
33 |
34 |
-------------------------------------------------------------------------------- /pages/plaza/fav.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
6 |

{{color1}}

7 |
8 |
9 |
10 |

{{color2}}

11 |
12 |
13 |
14 |

{{color3}}

15 |
16 |
17 |
18 |

{{color4}}

19 |
20 |
21 |
22 |

{{color5}}

23 |
24 |
25 |
26 |

命名:

27 | 28 |
29 |
30 |

1、配色名称仅支持中文、英文和数字。

31 |

2、配色名称限定20个字符以内。

32 |

3、相同名称的配色方案会被覆盖。

33 |
34 |

保存

35 |
-------------------------------------------------------------------------------- /pages/plaza/index.js: -------------------------------------------------------------------------------- 1 | // pages/plaza/index.js 2 | 3 | const { preventDoubleClick, onShare } = require('../../utils/functions.js'); 4 | 5 | Page({ 6 | 7 | /** 8 | * 页面的初始数据 9 | */ 10 | data: { 11 | height: 0 12 | }, 13 | 14 | /** 15 | * 生命周期函数--监听页面加载 16 | */ 17 | onLoad: function (options) { 18 | const res = wx.getSystemInfoSync(); 19 | this.setData({ 20 | height: res.windowHeight 21 | }); 22 | }, 23 | 24 | jump: function (event) { 25 | if (!this.data.buttonClicked) { 26 | preventDoubleClick(this); 27 | const id = event.currentTarget.dataset.id; 28 | let url = ''; 29 | switch (id) { 30 | case 'china': 31 | url = '/pages/plaza/china'; 32 | break; 33 | case 'japan': 34 | url = '/pages/plaza/japan'; 35 | break; 36 | case 'adobe': 37 | url = '/pages/plaza/adobe'; 38 | break; 39 | case 'fav': 40 | url = '/pages/plaza/myfav'; 41 | break; 42 | } 43 | wx.navigateTo({ url }); 44 | } 45 | }, 46 | 47 | /** 48 | * 用户点击右上角分享 49 | */ 50 | onShareAppMessage: function () { 51 | return onShare('缺乏配色灵感?来配色广场逛逛呗'); 52 | } 53 | }) -------------------------------------------------------------------------------- /pages/web/webcolor/webcolor.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

Web标准的网络安全色一共有216种,是当计算机运行 256 色调色板时能够正确地显示颜色。

6 |

256色里有40种颜色在Mac和Windows显示效果不同,所以安全色只有216色。

7 |
8 |
9 |
10 |
11 | 12 |
13 |
14 |
15 |

{{color_array[item]}}

16 |
17 |
18 |
19 |

{{color_array[item + 1]}}

20 |
21 |
22 |
23 |

{{color_array[item + 2]}}

24 |
25 |
26 |
27 |
28 |
29 |
-------------------------------------------------------------------------------- /pages/transition/transition.wxss: -------------------------------------------------------------------------------- 1 | /* transition.wxss */ 2 | 3 | .mode 4 | { 5 | margin: 20px; 6 | padding: 10px; 7 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 8 | } 9 | 10 | .header 11 | { 12 | display: flex; 13 | justify-content: center; 14 | align-items: center; 15 | font-size: small; 16 | } 17 | 18 | .picker 19 | { 20 | margin-left: 20px; 21 | } 22 | 23 | .item 24 | { 25 | display: flex; 26 | align-items: center; 27 | color: #888; 28 | } 29 | 30 | .item p 31 | { 32 | color: #888; 33 | font-size: small; 34 | flex-shrink: 0; 35 | } 36 | 37 | .item slider { 38 | flex-grow: 1; 39 | } 40 | 41 | .item .in-value { 42 | width: 40px; 43 | flex-shrink: 0; 44 | font-size: small; 45 | text-align:center; 46 | } 47 | 48 | .preview 49 | { 50 | margin: 20px; 51 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 52 | text-align: center; 53 | padding-bottom: 5px; 54 | } 55 | 56 | .color 57 | { 58 | height: 50px; 59 | } 60 | 61 | .preview p 62 | { 63 | margin: 5px; 64 | font-size: small; 65 | } 66 | 67 | .box 68 | { 69 | margin: 20px; 70 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 71 | } 72 | 73 | .value 74 | { 75 | margin-top: 20px; 76 | margin-bottom: 20px; 77 | } 78 | 79 | .value p 80 | { 81 | margin-bottom: 10px; 82 | font-size: small; 83 | } 84 | 85 | 86 | .hexinput { 87 | display:block; 88 | width:100%; 89 | font-size:small; 90 | /*border-bottom:1px solid #1e8cd4;*/ 91 | padding-left: 10px; 92 | } -------------------------------------------------------------------------------- /pages/index/index.js: -------------------------------------------------------------------------------- 1 | // 小程序入口页 2 | const { preventDoubleClick, onShare } = require('../../utils/functions.js'); 3 | 4 | Page({ 5 | data: { 6 | 7 | }, 8 | 9 | onLoad: function () { 10 | 11 | }, 12 | 13 | click: function (event) { 14 | if (!this.data.buttonClicked) { 15 | preventDoubleClick(this); 16 | const name = event.currentTarget.dataset.name; 17 | switch (name) { 18 | case "plaza": // 配色广场 19 | wx.navigateTo({ 20 | url: '/pages/plaza/index', 21 | }) 22 | break; 23 | case "transition": // 颜色转换 24 | wx.navigateTo({ 25 | url: '/pages/transition/transition', 26 | }); 27 | break; 28 | case "tools": // 配色工具 29 | wx.navigateTo({ 30 | url: '/pages/tools/tools', 31 | }); 32 | break; 33 | case "web": // Web颜色 34 | wx.navigateTo({ 35 | url: '/pages/web/web', 36 | }); 37 | break; 38 | case "about": // 关于 39 | wx.navigateTo({ 40 | url: '/pages/about/about', 41 | }); 42 | break; 43 | } 44 | } 45 | }, 46 | 47 | onShareAppMessage: function (res) { 48 | return onShare("Color颜值,优秀的配色助手"); 49 | } 50 | }) 51 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | // 程序启动页 2 | 3 | const { USER_LOGIN } = require('/utils/constant.js'); 4 | 5 | App({ 6 | globalData: { 7 | cust_id: -1, 8 | openid: '' 9 | }, 10 | 11 | onLaunch: function () { 12 | this.userLogin(this); 13 | }, 14 | 15 | /** 16 | * 用户登录 17 | */ 18 | userLogin(self) { 19 | const promise = new Promise((resolve, reject) => { 20 | wx.login({ 21 | success: function (res) { 22 | if (res.code) { 23 | wx.request({ 24 | url: USER_LOGIN, 25 | data: { 26 | code: res.code 27 | }, 28 | success: function (result) { 29 | const data = result.data; 30 | if (data.code == 0) { 31 | const openid = data.data.openid; 32 | const cust_id = data.data.cust_id; 33 | wx.setStorageSync('cust_id', cust_id); 34 | wx.setStorageSync('openid', openid); 35 | self.globalData.cust_id = cust_id; 36 | self.globalData.openid = openid; 37 | } 38 | } 39 | }) 40 | } 41 | } 42 | }); 43 | }); 44 | return promise; 45 | } 46 | }) -------------------------------------------------------------------------------- /pages/web/graylevel/graylevel.js: -------------------------------------------------------------------------------- 1 | // 灰度值 2 | const { preventDoubleClick, onShare } = require('../../../utils/functions.js'); 3 | 4 | Page({ 5 | // 页面的初始数据 6 | data: { 7 | color: [ 8 | { hex: "#000000" }, 9 | { hex: "#080808" }, 10 | { hex: "#101010" }, 11 | { hex: "#181818" }, 12 | { hex: "#202020" }, 13 | { hex: "#282828" }, 14 | { hex: "#303030" }, 15 | { hex: "#383838" }, 16 | { hex: "#404040" }, 17 | { hex: "#484848" }, 18 | { hex: "#505050" }, 19 | { hex: "#585858" }, 20 | { hex: "#606060" }, 21 | { hex: "#686868" }, 22 | { hex: "#707070" }, 23 | { hex: "#787878" }, 24 | { hex: "#808080" }, 25 | { hex: "#888888" }, 26 | { hex: "#909090" }, 27 | { hex: "#989898" }, 28 | { hex: "#A0A0A0" }, 29 | { hex: "#A8A8A8" }, 30 | { hex: "#B0B0B0" }, 31 | { hex: "#B8B8B8" }, 32 | { hex: "#C0C0C0" }, 33 | { hex: "#C8C8C8" }, 34 | { hex: "#D0D0D0" }, 35 | { hex: "#D8D8D8" }, 36 | { hex: "#E0E0E0" }, 37 | { hex: "#E8E8E8" }, 38 | { hex: "#F0F0F0" }, 39 | { hex: "#F8F8F8" }, 40 | { hex: "#FFFFFF" }] 41 | }, 42 | 43 | click: function (e) { 44 | if (!this.data.buttonClicked) { 45 | preventDoubleClick(this); 46 | const color = e.currentTarget.dataset.color; 47 | wx.navigateTo({ 48 | url: '/pages/web/colordetail?color=' + color, 49 | }); 50 | } 51 | }, 52 | 53 | onShareAppMessage: function (res) { 54 | return onShare("灰度值参考"); 55 | } 56 | }) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Color颜值小程序 2 | 3 | Color颜值是一个基于色轮配色原理的小程序。通过这一小程序,可以搭配出协调的色彩,令你的配色工作更加轻松。 4 | 5 | 一、配色广场,提供了中国和日本传统颜色,Adobe Color CC上最受欢迎的配色方案以及自己收藏的配色方案。 6 | 7 | 二、颜色转换,提供了颜色在RGB、CMYK、LAB、HSB四个色彩空间以及HEX的换算操作,方便在查询色彩分量的同时,参考其他色彩空间的值。 8 | 9 | 三、配色工具,提供了基于六种颜色关系的配色算法。 1、类比色、相似色:相邻的颜色称为类比色。类比色都拥有相近的颜色,该配色原理根据给定的基准色和角度,计算两个与基准色夹角递增的类比色以及两个与基准色夹角递减的类比色。 10 | 11 | 1、类比色、相似色:相邻的颜色称为类比色。类比色都拥有相近的颜色,该配色原理根据给定的基准色和角度,计算两个与基准色夹角递增的类比色以及两个与基准色夹角递减的类比色。 12 | 13 | 2、互补色:在色轮上直线相对的两种颜色称为互补色。补色形成强列的对比效果,传达出活力、能量、兴奋等意义。 14 | 15 | 3、分裂补色:如果同时用补色及类比色的方法来确定的颜色关系,就称为分裂补色。这种颜色搭配既具有类比色的低对比度的美感,又具有补色的力量感。形成了一种既和谐又有重点的颜色关系。 16 | 17 | 4、单色:一种色相由暗、中、明三种色调组成。该算法根据基准色的色相,按比例调整配色的亮度和饱和度。 18 | 19 | 5、渐变:渐变由指定的基准色通过变化一定比例的亮度或饱和度来得到。 20 | 21 | 6、二次色配比:二次色之间都拥有一种共同的颜色,其中两种拥有相同的蓝色分量,两种拥有相同的绿色分量,两种拥有相同的红色分量。它们轻易能够形成协调的搭配。如果三种二次色同时使用,则显得很舒适、吸引,并具有丰富的色调。它们同时具有的颜色深度及广度。 22 | 23 | 7、I am Feeling Lucky是在使用者无需考虑配色原理的前提下,随机搭配一种配色算法给出的配色方案。 24 | 25 | 四、Web颜色,列举了Web标准规范中HTML和CSS定义的标准色和安全色。 26 | 27 | 扫码体验 28 | 29 | 30 | ![小程序码](http://imcoding.org/Public/resource/img/color/appcode.jpg) 31 | 32 | 小程序截图 33 | 34 | 35 | ![Color颜值](http://imcoding.org/Public/resource/img/color/color1-xs.jpg) 36 | ![配色广场](http://imcoding.org/Public/resource/img/color/color2-xs.jpg) 37 | ![中国传统色彩](http://imcoding.org/Public/resource/img/color/color3-xs.jpg) 38 | ![日本传统色彩](http://imcoding.org/Public/resource/img/color/color4-xs.jpg) 39 | ![Adobe配色方案](http://imcoding.org/Public/resource/img/color/color5-xs.jpg) 40 | ![Web颜色](http://imcoding.org/Public/resource/img/color/color6-xs.jpg) 41 | ![色彩工具](http://imcoding.org/Public/resource/img/color/color7-xs.jpg) 42 | ![互补色配色](http://imcoding.org/Public/resource/img/color/color8-xs.jpg) 43 | ![颜色转换](http://imcoding.org/Public/resource/img/color/color9-xs.jpg) 44 | 45 | 谢谢! 46 | 47 | 48 | -------------------------------------------------------------------------------- /pages/web/webcolor/webcolor.js: -------------------------------------------------------------------------------- 1 | // Web安全色 2 | const { preventDoubleClick, onShare, range } = require('../../../utils/functions.js'); 3 | 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | color_array: new Array(), 11 | index_array: new Array() 12 | }, 13 | 14 | onShow: function () { 15 | let array = new Array; 16 | for (let i = 0; i <= 255; i += 51) { 17 | let red = new Number(i); 18 | red = red.toString(16); 19 | red = this.numberFix(red); 20 | 21 | for (let j = 0; j <= 255; j += 51) { 22 | let green = new Number(j); 23 | green = green.toString(16); 24 | green = this.numberFix(green); 25 | 26 | for (let k = 0; k <= 255; k += 51) { 27 | let blue = new Number(k); 28 | blue = blue.toString(16); 29 | blue = this.numberFix(blue); 30 | 31 | let color = "#" + red + green + blue; 32 | array.push(color); 33 | } 34 | } 35 | } 36 | 37 | this.setData({ 38 | color_array: array, 39 | index_array: range(72) 40 | }); 41 | }, 42 | 43 | numberFix: function (a) { 44 | if (a.length == 1) { 45 | return "0" + a; 46 | } 47 | return a; 48 | }, 49 | 50 | click: function (e) { 51 | if (!this.data.buttonClicked) { 52 | preventDoubleClick(this); 53 | const color = e.currentTarget.dataset.color; 54 | wx.navigateTo({ 55 | url: '/pages/web/colordetail?color=' + color, 56 | }); 57 | } 58 | }, 59 | 60 | onShareAppMessage: function (res) { 61 | return onShare("Web安全色参考"); 62 | } 63 | }) -------------------------------------------------------------------------------- /pages/plaza/myfav.js: -------------------------------------------------------------------------------- 1 | // pages/plaza/myfav.js 2 | 3 | const { httpPost, httpGet, preventDoubleClick } = require('../../utils/functions.js'); 4 | const { GET_USER_COLORS } = require('../../utils/constant.js'); 5 | 6 | Page({ 7 | 8 | /** 9 | * 页面的初始数据 10 | */ 11 | data: { 12 | width: 0, 13 | colors: new Array 14 | }, 15 | 16 | /** 17 | * 生命周期函数--监听页面加载 18 | */ 19 | onLoad: function (options) { 20 | const res = wx.getSystemInfoSync(); 21 | this.setData({ 22 | width: (res.windowWidth - 30) / 5 23 | }); 24 | }, 25 | 26 | onShow: function () { 27 | const cust_id = wx.getStorageSync('cust_id'); 28 | const openid = wx.getStorageSync('openid'); 29 | const url = GET_USER_COLORS + '?cust_id=' + cust_id + '&openid=' + openid; 30 | const that = this; 31 | httpGet(url).then(data => { 32 | if (data.code == 0) { 33 | that.setData({ 34 | colors: data['data'] 35 | }); 36 | } 37 | }); 38 | }, 39 | 40 | detail: function (event) { 41 | if (!this.data.buttonClicked) { 42 | preventDoubleClick(this); 43 | const index = event.currentTarget.dataset.index; 44 | const name = this.data.colors[index].name; 45 | const id = this.data.colors[index].id; 46 | const color1 = this.data.colors[index].color1; 47 | const color2 = this.data.colors[index].color2; 48 | const color3 = this.data.colors[index].color3; 49 | const color4 = this.data.colors[index].color4; 50 | const color5 = this.data.colors[index].color5; 51 | wx.navigateTo({ 52 | url: '/pages/plaza/detail?source=my&id=' + id + '&name=' + name + '&color1=' + color1 + '&color2=' + color2 + '&color3=' + color3 + '&color4=' + color4 + '&color5=' + color5 53 | }); 54 | } 55 | } 56 | }) -------------------------------------------------------------------------------- /pages/web/colordetail.js: -------------------------------------------------------------------------------- 1 | // 颜色详情 2 | // pages/common/colordetail.js 3 | const colors = require('../../utils/colors.js'); 4 | const { onShare } = require('../../utils/functions.js'); 5 | 6 | Page({ 7 | 8 | /** 9 | * 页面的初始数据 10 | */ 11 | data: { 12 | name: 0, 13 | hex: 0, 14 | }, 15 | 16 | /** 17 | * 生命周期函数--监听页面加载 18 | */ 19 | onLoad: function (options) { 20 | if (options.color == undefined) { 21 | wx.navigateBack({ 22 | delta: 1 23 | }); 24 | } 25 | 26 | const hex = options.color; 27 | const name = options.name == undefined ? '色彩分量' : options.name; 28 | const rgb = colors.hex2rgb(hex); 29 | const hsb = colors.rgb2hsb(rgb[0], rgb[1], rgb[2]); 30 | const lab = colors.rgb2lab(rgb[0], rgb[1], rgb[2]); 31 | const cmyk = colors.rgb2cmyk(rgb[0], rgb[1], rgb[2]); 32 | 33 | this.setData({ 34 | hex: hex, 35 | name: name, 36 | red: rgb[0], 37 | green: rgb[1], 38 | blue: rgb[2], 39 | hue: hsb[0], 40 | saturation: hsb[1], 41 | brightness: hsb[2], 42 | luminosity: lab[0], 43 | a: lab[1], 44 | b: lab[2], 45 | cyan: cmyk[0], 46 | magenta: cmyk[1], 47 | yellow: cmyk[2], 48 | black: cmyk[3], 49 | }); 50 | }, 51 | 52 | onReady: function () { 53 | wx.setNavigationBarTitle({ 54 | title: this.data.name 55 | }); 56 | }, 57 | 58 | copy: function () { 59 | wx.setClipboardData({ 60 | data: this.data.name + ', HEX: ' + this.data.hex, 61 | success: function (res) { 62 | wx.showToast({ 63 | title: '复制HEX值成功', 64 | }); 65 | } 66 | }) 67 | }, 68 | 69 | onShareAppMessage: function () { 70 | return onShare(this.data.name + '的各颜色分量'); 71 | } 72 | }) -------------------------------------------------------------------------------- /pages/web/csscolor/csscolor.wxml: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |

HTML 和 CSS 颜色规范中定义了 147 中颜色名(17 种标准颜色加 130 种其他颜色)。下面的表格中列出了所有这些颜色,以及它们的十六进制值。

6 |

点击来查看相应颜色的详细分量值。

7 |
8 |
9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
CSS 标准色
颜色名HEX值预览
{{item.name}}{{item.hex}}
25 |
26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
CSS 颜色
颜色名HEX值预览
{{item.name}}{{item.hex}}
42 |
43 |
-------------------------------------------------------------------------------- /pages/plaza/adobe.js: -------------------------------------------------------------------------------- 1 | // pages/plaza/adobe.js 2 | 3 | const { preventDoubleClick, httpGet, onShare } = require('../../utils/functions.js'); 4 | const { GET_ADOBE_COLORS } = require('../../utils/constant.js'); 5 | 6 | Page({ 7 | 8 | /** 9 | * 页面的初始数据 10 | */ 11 | data: { 12 | width: 0, 13 | colors: new Array 14 | }, 15 | 16 | /** 17 | * 生命周期函数--监听页面加载 18 | */ 19 | onLoad: function (options) { 20 | const res = wx.getSystemInfoSync(); 21 | this.setData({ 22 | width: (res.windowWidth - 30) / 5 23 | }); 24 | this.random(); 25 | }, 26 | 27 | /** 28 | * 随机获取配色方案 29 | */ 30 | random: function () { 31 | if (!this.data.buttonClicked) { 32 | preventDoubleClick(this); 33 | const that = this; 34 | const url = GET_ADOBE_COLORS; 35 | httpGet(url).then(data => { 36 | if (data.code == 0) { 37 | that.setData({ 38 | colors: data.data 39 | }); 40 | } 41 | }); 42 | } 43 | }, 44 | 45 | detail: function (event) { 46 | if (!this.data.buttonClicked) { 47 | preventDoubleClick(this); 48 | const index = event.currentTarget.dataset.index; 49 | const name = this.data.colors[index].name; 50 | const color1 = this.data.colors[index].color1; 51 | const color2 = this.data.colors[index].color2; 52 | const color3 = this.data.colors[index].color3; 53 | const color4 = this.data.colors[index].color4; 54 | const color5 = this.data.colors[index].color5; 55 | wx.navigateTo({ 56 | url: '/pages/plaza/detail?name=' + name + '&color1=' + color1 + '&color2=' + color2 + '&color3=' + color3 + '&color4=' + color4 + '&color5=' + color5 57 | }); 58 | } 59 | }, 60 | 61 | /** 62 | * 用户点击右上角分享 63 | */ 64 | onShareAppMessage: function () { 65 | return onShare('Adobe高分配色方案'); 66 | } 67 | }) -------------------------------------------------------------------------------- /pages/tools/lucky/lucky.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |
6 |
7 |

{{item.hex}}

8 |
9 |
10 |
11 | 12 |
13 | 14 |
15 | {{array[index]}} 16 |
17 |
18 |
19 |

R:

20 | 21 |
22 |
23 |

G:

24 | 25 |
26 |
27 |

B:

28 | 29 |
30 |
31 |

饱和度

32 | 33 |
34 |
35 |

亮度

36 | 37 |
38 |
39 |
40 | 41 | 42 | 43 |
44 |
-------------------------------------------------------------------------------- /pages/plaza/edit.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

命名:

5 | 6 |
7 | 8 |
9 | 10 |
11 |
12 |

{{item.hex}}

13 |
14 |
15 |
16 | 17 |
18 | 19 |
20 | {{array[index]}} 21 |
22 |
23 |
24 |

R:

25 | 26 |
27 |
28 |

G:

29 | 30 |
31 |
32 |

B:

33 | 34 |
35 |
36 |

饱和度

37 | 38 |
39 |
40 |

亮度

41 | 42 |
43 |
44 |

保存

45 |
-------------------------------------------------------------------------------- /pages/tools/secondary/secondary.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

R:

6 | 7 |
8 |
9 |

G:

10 | 11 |
12 |
13 |

B:

14 | 15 |
16 |
17 |

饱和度

18 | 19 |
20 |
21 |

亮度

22 | 23 |
24 |
25 |
26 |

基准色

27 |
28 |

{{hex}}

29 |
30 |
31 |

32 | 配比色组 33 |

34 |
35 | 36 |
37 |
38 | 41 |
42 |
43 |
44 |
45 |
46 | 47 | 48 | 49 |
50 |
51 |
-------------------------------------------------------------------------------- /pages/tools/shade/shade.wxss: -------------------------------------------------------------------------------- 1 | .layer { 2 | background-color: #f7f7f7; 3 | } 4 | 5 | .box { 6 | padding: 10px; 7 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 8 | background-color: white; 9 | } 10 | 11 | .item { 12 | display: flex; 13 | align-items: center; 14 | color: #888; 15 | } 16 | 17 | .item p { 18 | color: #888; 19 | font-size: small; 20 | min-width: 30px; 21 | } 22 | 23 | .preview { 24 | margin: 20px 0px; 25 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 26 | text-align: center; 27 | padding-top: 5px; 28 | padding-bottom: 5px; 29 | background-color: white; 30 | } 31 | 32 | .color { 33 | height: 50px; 34 | } 35 | 36 | .preview p { 37 | margin: 5px; 38 | font-size: small; 39 | color: #888; 40 | } 41 | 42 | .test { 43 | background-color: white; 44 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 45 | margin-bottom: 20px; 46 | } 47 | 48 | .fixed { 49 | display: flex; 50 | justify-content: space-around; 51 | align-items: center; 52 | } 53 | 54 | .cell { 55 | font-size: small; 56 | min-width: 65px; 57 | } 58 | 59 | .cell-color { 60 | height: 60px; 61 | } 62 | 63 | .cell-footer { 64 | background-color: white; 65 | text-align: center; 66 | padding-top: 5px; 67 | padding-bottom: 5px; 68 | color: #888; 69 | } 70 | 71 | radio { 72 | padding: 0; 73 | box-sizing: border-box; 74 | margin: 0; 75 | } 76 | 77 | .wx-radio-input { 78 | width: 12px !important; 79 | height: 12px !important; 80 | } 81 | 82 | .adjust { 83 | margin: 20px 0; 84 | background-color: white; 85 | padding-bottom: 10px; 86 | } 87 | 88 | .board { 89 | display: flex; 90 | align-items: center; 91 | } 92 | 93 | .board p { 94 | color: #888; 95 | font-size: small; 96 | padding: 10px; 97 | } 98 | 99 | 100 | .btn-fav 101 | { 102 | flex-grow: 1; 103 | color:#fff; 104 | background-color:#e864b3; 105 | border-color:#5e96d1; 106 | border-radius: 20px; 107 | } 108 | 109 | .btn-random 110 | { 111 | flex-grow: 1; 112 | color:#fff; 113 | background-color:#5e96d1; 114 | border-color:#5e96d1; 115 | border-radius: 20px; 116 | } 117 | 118 | .btn-copy { 119 | flex-grow: 1; 120 | color:#fff; 121 | background-color:#09bb07; 122 | border-color:#09bb07; 123 | border-radius: 20px; 124 | } 125 | -------------------------------------------------------------------------------- /pages/tools/secondary/secondary.wxss: -------------------------------------------------------------------------------- 1 | .layer { 2 | background-color: #f7f7f7; 3 | } 4 | 5 | .box { 6 | padding: 10px; 7 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 8 | background-color: white; 9 | } 10 | 11 | .item { 12 | display: flex; 13 | align-items: center; 14 | color: #888; 15 | } 16 | 17 | .item p { 18 | color: #888; 19 | font-size: small; 20 | min-width: 40px; 21 | } 22 | 23 | .preview { 24 | margin: 20px 0px; 25 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 26 | text-align: center; 27 | padding-top: 5px; 28 | padding-bottom: 5px; 29 | background-color: white; 30 | } 31 | 32 | .color { 33 | height: 50px; 34 | } 35 | 36 | .preview p { 37 | margin: 5px; 38 | font-size: small; 39 | color: #888; 40 | } 41 | 42 | .test { 43 | background-color: white; 44 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 45 | margin-bottom: 20px; 46 | } 47 | 48 | .fixed { 49 | display: flex; 50 | justify-content: space-around; 51 | align-items: center; 52 | } 53 | 54 | .cell { 55 | font-size: small; 56 | min-width: 65px; 57 | } 58 | 59 | .cell-color { 60 | height: 60px; 61 | } 62 | 63 | .cell-footer { 64 | background-color: white; 65 | text-align: center; 66 | padding-top: 5px; 67 | padding-bottom: 5px; 68 | color: #888; 69 | } 70 | 71 | radio { 72 | padding: 0; 73 | box-sizing: border-box; 74 | margin: 0; 75 | } 76 | 77 | .wx-radio-input { 78 | width: 12px !important; 79 | height: 12px !important; 80 | } 81 | 82 | .adjust { 83 | margin: 20px 0; 84 | background-color: white; 85 | padding-bottom: 10px; 86 | } 87 | 88 | .board { 89 | display: flex; 90 | align-items: center; 91 | } 92 | 93 | .board p { 94 | color: #888; 95 | font-size: small; 96 | padding: 10px; 97 | } 98 | 99 | 100 | .btn-fav 101 | { 102 | flex-grow: 1; 103 | color:#fff; 104 | background-color:#e864b3; 105 | border-color:#5e96d1; 106 | border-radius: 20px; 107 | } 108 | 109 | .btn-random 110 | { 111 | flex-grow: 1; 112 | color:#fff; 113 | background-color:#5e96d1; 114 | border-color:#5e96d1; 115 | border-radius: 20px; 116 | } 117 | 118 | .btn-copy { 119 | flex-grow: 1; 120 | color:#fff; 121 | background-color:#09bb07; 122 | border-color:#09bb07; 123 | border-radius: 20px; 124 | } 125 | -------------------------------------------------------------------------------- /pages/tools/triad/triad.wxss: -------------------------------------------------------------------------------- 1 | .layer 2 | { 3 | background-color: #f7f7f7; 4 | } 5 | 6 | .box 7 | { 8 | padding: 10px; 9 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 10 | background-color: white; 11 | } 12 | 13 | .item 14 | { 15 | display: flex; 16 | align-items: center; 17 | color: #888; 18 | } 19 | 20 | .item p 21 | { 22 | color: #888; 23 | font-size: small; 24 | } 25 | 26 | .preview 27 | { 28 | margin: 20px 0px; 29 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 30 | text-align: center; 31 | padding-top: 5px; 32 | padding-bottom: 5px; 33 | background-color: white; 34 | } 35 | 36 | .color 37 | { 38 | height: 50px; 39 | } 40 | 41 | .preview p 42 | { 43 | margin: 5px; 44 | font-size: small; 45 | color: #888; 46 | } 47 | 48 | .test 49 | { 50 | background-color: white; 51 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 52 | } 53 | 54 | .fixed 55 | { 56 | display: flex; 57 | justify-content: space-around; 58 | align-items: center; 59 | } 60 | 61 | .cell 62 | { 63 | font-size: small; 64 | 65 | } 66 | 67 | .cell-color 68 | { 69 | height: 60px; 70 | } 71 | 72 | .cell-footer 73 | { 74 | background-color: white; 75 | text-align: center; 76 | padding-top:5px; 77 | padding-bottom:5px; 78 | color: #888; 79 | } 80 | 81 | radio 82 | { 83 | padding: 0; 84 | box-sizing: border-box; 85 | margin: 0; 86 | } 87 | 88 | .wx-radio-input 89 | { 90 | width:12px!important; 91 | height: 12px!important; 92 | } 93 | 94 | .adjust 95 | { 96 | margin: 20px 0; 97 | background-color: white; 98 | padding-bottom:10px; 99 | } 100 | 101 | .board 102 | { 103 | display: flex; 104 | align-items: center; 105 | } 106 | 107 | .board p 108 | { 109 | color: #888; 110 | font-size: small; 111 | padding:10px; 112 | } 113 | 114 | 115 | .btn-fav 116 | { 117 | flex-grow: 1; 118 | color:#fff; 119 | background-color:#e864b3; 120 | border-color:#5e96d1; 121 | border-radius: 20px; 122 | } 123 | 124 | .btn-random 125 | { 126 | flex-grow: 1; 127 | color:#fff; 128 | background-color:#5e96d1; 129 | border-color:#5e96d1; 130 | border-radius: 20px; 131 | } 132 | 133 | .btn-copy { 134 | flex-grow: 1; 135 | color:#fff; 136 | background-color:#09bb07; 137 | border-color:#09bb07; 138 | border-radius: 20px; 139 | } -------------------------------------------------------------------------------- /pages/tools/complementary/complementary.wxss: -------------------------------------------------------------------------------- 1 | .layer 2 | { 3 | background-color: #f7f7f7; 4 | } 5 | 6 | .box 7 | { 8 | padding: 10px; 9 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 10 | background-color: white; 11 | } 12 | 13 | .item 14 | { 15 | display: flex; 16 | align-items: center; 17 | color: #888; 18 | } 19 | 20 | .item p 21 | { 22 | color: #888; 23 | font-size: small; 24 | } 25 | 26 | .preview 27 | { 28 | margin: 20px 0px; 29 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 30 | text-align: center; 31 | padding-top: 5px; 32 | padding-bottom: 5px; 33 | background-color: white; 34 | } 35 | 36 | .color 37 | { 38 | height: 50px; 39 | } 40 | 41 | .preview p 42 | { 43 | margin: 5px; 44 | font-size: small; 45 | color: #888; 46 | } 47 | 48 | .test 49 | { 50 | background-color: white; 51 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 52 | } 53 | 54 | .fixed 55 | { 56 | display: flex; 57 | justify-content: space-around; 58 | align-items: center; 59 | } 60 | 61 | .cell 62 | { 63 | font-size: small; 64 | 65 | } 66 | 67 | .cell-color 68 | { 69 | height: 60px; 70 | } 71 | 72 | .cell-footer 73 | { 74 | background-color: white; 75 | text-align: center; 76 | padding-top:5px; 77 | padding-bottom:5px; 78 | color: #888; 79 | } 80 | 81 | radio 82 | { 83 | padding: 0; 84 | box-sizing: border-box; 85 | margin: 0; 86 | } 87 | 88 | .wx-radio-input 89 | { 90 | width:12px!important; 91 | height: 12px!important; 92 | } 93 | 94 | .adjust 95 | { 96 | margin: 20px 0; 97 | background-color: white; 98 | padding-bottom:10px; 99 | } 100 | 101 | .board 102 | { 103 | display: flex; 104 | align-items: center; 105 | } 106 | 107 | .board p 108 | { 109 | color: #888; 110 | font-size: small; 111 | padding:10px; 112 | } 113 | 114 | .btn-fav 115 | { 116 | flex-grow: 1; 117 | color:#fff; 118 | background-color:#e864b3; 119 | border-color:#5e96d1; 120 | border-radius: 20px; 121 | } 122 | 123 | .btn-random 124 | { 125 | flex-grow: 1; 126 | color:#fff; 127 | background-color:#5e96d1; 128 | border-color:#5e96d1; 129 | border-radius: 20px; 130 | } 131 | 132 | .btn-copy { 133 | flex-grow: 1; 134 | color:#fff; 135 | background-color:#09bb07; 136 | border-color:#09bb07; 137 | border-radius: 20px; 138 | } -------------------------------------------------------------------------------- /pages/tools/monochromatic/monochromatic.wxss: -------------------------------------------------------------------------------- 1 | .layer 2 | { 3 | background-color: #f7f7f7; 4 | } 5 | 6 | .box 7 | { 8 | padding: 10px; 9 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 10 | background-color: white; 11 | } 12 | 13 | .item 14 | { 15 | display: flex; 16 | align-items: center; 17 | color: #888; 18 | } 19 | 20 | .item p 21 | { 22 | color: #888; 23 | font-size: small; 24 | } 25 | 26 | .preview 27 | { 28 | margin: 20px 0px; 29 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 30 | text-align: center; 31 | padding-top: 5px; 32 | padding-bottom: 5px; 33 | background-color: white; 34 | } 35 | 36 | .color 37 | { 38 | height: 50px; 39 | } 40 | 41 | .preview p 42 | { 43 | margin: 5px; 44 | font-size: small; 45 | color: #888; 46 | } 47 | 48 | .test 49 | { 50 | background-color: white; 51 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 52 | } 53 | 54 | .fixed 55 | { 56 | display: flex; 57 | justify-content: space-around; 58 | align-items: center; 59 | } 60 | 61 | .cell 62 | { 63 | font-size: small; 64 | 65 | } 66 | 67 | .cell-color 68 | { 69 | height: 60px; 70 | } 71 | 72 | .cell-footer 73 | { 74 | background-color: white; 75 | text-align: center; 76 | padding-top:5px; 77 | padding-bottom:5px; 78 | color: #888; 79 | } 80 | 81 | radio 82 | { 83 | padding: 0; 84 | box-sizing: border-box; 85 | margin: 0; 86 | } 87 | 88 | .wx-radio-input 89 | { 90 | width:12px!important; 91 | height: 12px!important; 92 | } 93 | 94 | .adjust 95 | { 96 | margin: 20px 0; 97 | background-color: white; 98 | padding-bottom:10px; 99 | } 100 | 101 | .board 102 | { 103 | display: flex; 104 | align-items: center; 105 | } 106 | 107 | .board p 108 | { 109 | color: #888; 110 | font-size: small; 111 | padding:10px; 112 | } 113 | 114 | 115 | .btn-fav 116 | { 117 | flex-grow: 1; 118 | color:#fff; 119 | background-color:#e864b3; 120 | border-color:#5e96d1; 121 | border-radius: 20px; 122 | } 123 | 124 | .btn-random 125 | { 126 | flex-grow: 1; 127 | color:#fff; 128 | background-color:#5e96d1; 129 | border-color:#5e96d1; 130 | border-radius: 20px; 131 | } 132 | 133 | .btn-copy { 134 | flex-grow: 1; 135 | color:#fff; 136 | background-color:#09bb07; 137 | border-color:#09bb07; 138 | border-radius: 20px; 139 | } -------------------------------------------------------------------------------- /pages/tools/analogous/analogous.wxss: -------------------------------------------------------------------------------- 1 | .layer 2 | { 3 | background-color: #f7f7f7; 4 | } 5 | 6 | .box 7 | { 8 | padding: 10px; 9 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 10 | background-color: white; 11 | } 12 | 13 | .item 14 | { 15 | display: flex; 16 | align-items: center; 17 | color: #888; 18 | } 19 | 20 | .item p 21 | { 22 | color: #888; 23 | font-size: small; 24 | min-width:30px; 25 | } 26 | 27 | .preview 28 | { 29 | margin: 20px 0px; 30 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 31 | text-align: center; 32 | padding-top: 5px; 33 | padding-bottom: 5px; 34 | background-color: white; 35 | } 36 | 37 | .color 38 | { 39 | height: 50px; 40 | } 41 | 42 | .preview p 43 | { 44 | margin: 5px; 45 | font-size: small; 46 | color: #888; 47 | } 48 | 49 | .test 50 | { 51 | background-color: white; 52 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 53 | } 54 | 55 | .fixed 56 | { 57 | display: flex; 58 | justify-content: space-around; 59 | align-items: center; 60 | } 61 | 62 | .cell 63 | { 64 | font-size: small; 65 | 66 | } 67 | 68 | .cell-color 69 | { 70 | height: 60px; 71 | } 72 | 73 | .cell-footer 74 | { 75 | background-color: white; 76 | text-align: center; 77 | padding-top:5px; 78 | padding-bottom:5px; 79 | color: #888; 80 | } 81 | 82 | radio 83 | { 84 | padding: 0; 85 | box-sizing: border-box; 86 | margin: 0; 87 | } 88 | 89 | .wx-radio-input 90 | { 91 | width:12px!important; 92 | height: 12px!important; 93 | } 94 | 95 | .adjust 96 | { 97 | margin: 20px 0; 98 | background-color: white; 99 | padding-bottom:10px; 100 | } 101 | 102 | .board 103 | { 104 | display: flex; 105 | align-items: center; 106 | } 107 | 108 | .board p 109 | { 110 | color: #888; 111 | font-size: small; 112 | padding:10px; 113 | } 114 | 115 | .btn-fav 116 | { 117 | flex-grow: 1; 118 | color:#fff; 119 | background-color:#e864b3; 120 | border-color:#5e96d1; 121 | border-radius: 20px; 122 | } 123 | 124 | .btn-random 125 | { 126 | flex-grow: 1; 127 | color:#fff; 128 | background-color:#5e96d1; 129 | border-color:#5e96d1; 130 | border-radius: 20px; 131 | } 132 | 133 | .btn-copy { 134 | flex-grow: 1; 135 | color:#fff; 136 | background-color:#09bb07; 137 | border-color:#09bb07; 138 | border-radius: 20px; 139 | } -------------------------------------------------------------------------------- /pages/tools/shade/shade.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

R:

6 | 7 |
8 |
9 |

G:

10 | 11 |
12 |
13 |

B:

14 | 15 |
16 |
17 |

调整

18 | 19 | 亮度 20 | 饱和度 21 | 22 |
23 |
24 |

比例

25 | 26 |
27 |
28 |
29 |

基准色

30 |
31 |

{{hex}}

32 |
33 |
34 |

35 | 渐变色组 36 |

37 |
38 | 39 |
40 |
41 | 45 |
46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 |
54 |
55 |
-------------------------------------------------------------------------------- /pages/tools/triad/triad.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

R:

6 | 7 |
8 |
9 |

G:

10 | 11 |
12 |
13 |

B:

14 | 15 |
16 |
17 |
18 |

基准色

19 |
20 |

{{hex}}

21 |
22 |
23 |

24 | 分裂补色 25 |

26 | 27 | 28 |
29 |
30 | 33 | 36 |
37 |
38 |
39 |
40 |
41 |

42 | 调整补色 43 |

44 |
45 |

饱和度

46 | 47 |
48 |
49 |

亮度

50 | 51 |
52 |
53 |
54 | 55 | 56 | 57 |
58 |
59 |
-------------------------------------------------------------------------------- /pages/tools/monochromatic/monochromatic.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

R:

6 | 7 |
8 |
9 |

G:

10 | 11 |
12 |
13 |

B:

14 | 15 |
16 |
17 |
18 |

基准色

19 |
20 |

{{hex}}

21 |
22 |
23 |

24 | 单色组 25 |

26 | 27 | 28 |
29 |
30 | 33 | 36 |
37 |
38 |
39 |
40 |
41 |

42 | 调整单色 43 |

44 |
45 |

饱和度

46 | 47 |
48 |
49 |

亮度

50 | 51 |
52 |
53 |
54 | 55 | 56 | 57 |
58 |
59 |
-------------------------------------------------------------------------------- /pages/tools/complementary/complementary.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

R:

6 | 7 |
8 |
9 |

G:

10 | 11 |
12 |
13 |

B:

14 | 15 |
16 |
17 |
18 |

基准色

19 |
20 |

{{hex}}

21 |
22 |
23 |

24 | 辅色 + 补色组 25 |

26 | 27 | 28 |
29 |
30 | 33 | 36 |
37 |
38 |
39 |
40 |
41 |

42 | 调整补色 43 |

44 |
45 |

饱和度

46 | 47 |
48 |
49 |

亮度

50 | 51 |
52 |
53 |
54 | 55 | 56 | 57 |
58 |
59 |
-------------------------------------------------------------------------------- /pages/tools/lucky/lucky.wxss: -------------------------------------------------------------------------------- 1 | /* pages/tools/lucky/lucky.wxss */ 2 | .colorgroup 3 | { 4 | display: flex; 5 | justify-content: center; 6 | align-items: center; 7 | padding-top: 15px; 8 | padding-bottom: 5px; 9 | margin: 10px; 10 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 11 | background-color: white; 12 | } 13 | 14 | .color-item 15 | { 16 | flex-grow: 1; 17 | } 18 | 19 | .colorgroup p 20 | { 21 | font-size: small; 22 | color: #888; 23 | padding: 5px; 24 | } 25 | 26 | 27 | .layer { 28 | background-color: #f7f7f7; 29 | } 30 | 31 | .box { 32 | padding: 10px; 33 | margin: 10px; 34 | margin-top: 30px; 35 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 36 | background-color: white; 37 | } 38 | 39 | .item { 40 | display: flex; 41 | align-items: center; 42 | color: #888; 43 | } 44 | 45 | .item p { 46 | color: #888; 47 | 48 | font-size: small; 49 | min-width: 40px; 50 | } 51 | 52 | .preview { 53 | margin: 20px 0px; 54 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 55 | text-align: center; 56 | padding-top: 5px; 57 | padding-bottom: 5px; 58 | background-color: white; 59 | } 60 | 61 | .color { 62 | height: 50px; 63 | } 64 | 65 | .preview p { 66 | margin: 5px; 67 | font-size: small; 68 | color: #888; 69 | } 70 | 71 | .test { 72 | background-color: white; 73 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 74 | } 75 | 76 | .fixed { 77 | display: flex; 78 | justify-content: space-around; 79 | align-items: center; 80 | } 81 | 82 | .cell { 83 | font-size: small; 84 | min-width: 65px; 85 | } 86 | 87 | .cell-color { 88 | height: 60px; 89 | } 90 | 91 | .cell-footer { 92 | background-color: white; 93 | text-align: center; 94 | padding-top: 5px; 95 | padding-bottom: 5px; 96 | color: #888; 97 | } 98 | 99 | radio { 100 | padding: 0; 101 | box-sizing: border-box; 102 | margin: 0; 103 | } 104 | 105 | .wx-radio-input { 106 | width: 12px !important; 107 | height: 12px !important; 108 | } 109 | 110 | .adjust { 111 | margin: 20px 0; 112 | background-color: white; 113 | padding-bottom: 10px; 114 | } 115 | 116 | .board { 117 | display: flex; 118 | align-items: center; 119 | } 120 | 121 | .board p { 122 | color: #888; 123 | font-size: small; 124 | padding: 10px; 125 | } 126 | 127 | .btn-fav 128 | { 129 | flex-grow: 1; 130 | color:#fff; 131 | background-color:#e864b3; 132 | border-color:#5e96d1; 133 | border-radius: 20px; 134 | } 135 | 136 | .btn-random 137 | { 138 | flex-grow: 1; 139 | color:#fff; 140 | background-color:#5e96d1; 141 | border-color:#5e96d1; 142 | border-radius: 20px; 143 | } 144 | 145 | .btn-copy { 146 | flex-grow: 1; 147 | color:#fff; 148 | background-color:#09bb07; 149 | border-color:#09bb07; 150 | border-radius: 20px; 151 | } 152 | 153 | -------------------------------------------------------------------------------- /pages/plaza/edit.wxss: -------------------------------------------------------------------------------- 1 | .colorgroup 2 | { 3 | display: flex; 4 | justify-content: center; 5 | align-items: center; 6 | padding-top: 15px; 7 | padding-bottom: 5px; 8 | margin: 10px; 9 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 10 | background-color: white; 11 | } 12 | 13 | .color-item 14 | { 15 | flex-grow: 1; 16 | } 17 | 18 | .colorgroup p 19 | { 20 | font-size: small; 21 | color: #888; 22 | padding: 5px; 23 | } 24 | 25 | 26 | .layer { 27 | background-color: #f7f7f7; 28 | } 29 | 30 | .box { 31 | padding: 10px; 32 | margin: 10px; 33 | margin-top: 30px; 34 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 35 | background-color: white; 36 | } 37 | 38 | .item { 39 | display: flex; 40 | align-items: center; 41 | color: #888; 42 | } 43 | 44 | .item p { 45 | color: #888; 46 | 47 | font-size: small; 48 | min-width: 40px; 49 | } 50 | 51 | .preview { 52 | margin: 20px 0px; 53 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 54 | text-align: center; 55 | padding-top: 5px; 56 | padding-bottom: 5px; 57 | background-color: white; 58 | } 59 | 60 | .color { 61 | height: 50px; 62 | } 63 | 64 | .preview p { 65 | margin: 5px; 66 | font-size: small; 67 | color: #888; 68 | } 69 | 70 | .test { 71 | background-color: white; 72 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 73 | } 74 | 75 | .fixed { 76 | display: flex; 77 | justify-content: space-around; 78 | align-items: center; 79 | } 80 | 81 | .cell { 82 | font-size: small; 83 | min-width: 65px; 84 | } 85 | 86 | .cell-color { 87 | height: 60px; 88 | } 89 | 90 | .cell-footer { 91 | background-color: white; 92 | text-align: center; 93 | padding-top: 5px; 94 | padding-bottom: 5px; 95 | color: #888; 96 | } 97 | 98 | radio { 99 | padding: 0; 100 | box-sizing: border-box; 101 | margin: 0; 102 | } 103 | 104 | .wx-radio-input { 105 | width: 12px !important; 106 | height: 12px !important; 107 | } 108 | 109 | .adjust { 110 | margin: 20px 0; 111 | background-color: white; 112 | padding-bottom: 10px; 113 | } 114 | 115 | .board { 116 | display: flex; 117 | align-items: center; 118 | } 119 | 120 | .board p { 121 | color: #888; 122 | font-size: small; 123 | padding: 10px; 124 | } 125 | 126 | .save { 127 | padding: 10px; 128 | background-color: #4c6cb3; 129 | color: white; 130 | text-align: center; 131 | position:fixed; 132 | bottom:0; 133 | left:0; 134 | right:0; 135 | } 136 | 137 | 138 | .box-name 139 | { 140 | display: flex; 141 | align-items: center; 142 | justify-content:center; 143 | margin: 10px; 144 | margin-top: 15px; 145 | box-shadow: 10px 10px 5px rgba(39, 48, 57, 0.05); 146 | background-color: white; 147 | padding: 10px; 148 | } 149 | 150 | .name 151 | { 152 | border-bottom: 1px solid paleturquoise; 153 | padding: 5px; 154 | color: #888; 155 | } -------------------------------------------------------------------------------- /pages/tools/analogous/analogous.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

R:

6 | 7 |
8 |
9 |

G:

10 | 11 |
12 |
13 |

B:

14 | 15 |
16 |
17 |

角度:

18 | 19 |
20 |
21 |
22 |

基准色

23 |
24 |

{{hex}}

25 |
26 |
27 |

28 | 类比色组 29 |

30 | 31 | 32 |
33 |
34 | 37 | 40 |
41 |
42 |
43 |
44 |
45 |

46 | 调整类比色 47 |

48 |
49 |

饱和度

50 | 51 |
52 |
53 |

亮度

54 | 55 |
56 |
57 |
58 | 59 | 60 | 61 |
62 |
63 |
-------------------------------------------------------------------------------- /pages/plaza/fav.js: -------------------------------------------------------------------------------- 1 | // pages/plaza/fav.js 2 | 3 | const { SAVE_USER_COLORS } = require('../../utils/constant.js'); 4 | const { httpGet } = require('../../utils/functions.js'); 5 | 6 | Page({ 7 | 8 | /** 9 | * 页面的初始数据 10 | */ 11 | data: { 12 | color1: '', 13 | color2: '', 14 | color3: '', 15 | color4: '', 16 | color5: '', 17 | name: '' 18 | }, 19 | 20 | /** 21 | * 生命周期函数--监听页面加载 22 | */ 23 | onLoad: function (options) { 24 | this.setData({ 25 | color1: options.color1, 26 | color2: options.color2, 27 | color3: options.color3, 28 | color4: options.color4, 29 | color5: options.color5, 30 | name: options.name == undefined ? '' : options.name 31 | }); 32 | }, 33 | 34 | input: function (event) { 35 | const value = event.detail.value; 36 | if (value.length <= 20) { 37 | this.setData({ 38 | name: value 39 | }); 40 | } 41 | }, 42 | 43 | save: function () { 44 | if (this.data.name.length == 0) { 45 | wx.showToast({ 46 | title: '请输入配色名称', 47 | icon: 'none' 48 | }); 49 | } else { 50 | let data = { 51 | cust_id: wx.getStorageSync('cust_id'), 52 | openid: wx.getStorageSync('openid'), 53 | color1: this.data.color1, 54 | color2: this.data.color2, 55 | color3: this.data.color3, 56 | color4: this.data.color4, 57 | color5: this.data.color5, 58 | name: this.data.name 59 | }; 60 | httpGet(SAVE_USER_COLORS, data).then(data => { 61 | if (data.code == 0) { 62 | const value = data['data']; 63 | if (value == 1) { 64 | wx.showToast({ 65 | title: '保存配色成功', 66 | icon: 'success', 67 | success: function () { 68 | setTimeout(function () { 69 | wx.navigateBack({ 70 | delta: 1 71 | }); 72 | }, 1500); 73 | } 74 | }); 75 | } else if (value == 2) { 76 | wx.showToast({ 77 | title: '更新配色成功', 78 | icon: 'success', 79 | success: function () { 80 | setTimeout(function () { 81 | wx.navigateBack({ 82 | delta: 1 83 | }); 84 | }, 1500); 85 | } 86 | }); 87 | } 88 | } else { 89 | wx.showToast({ 90 | title: data.msg, 91 | }); 92 | } 93 | }); 94 | } 95 | } 96 | }) -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at admin@imcoding.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /utils/functions.js: -------------------------------------------------------------------------------- 1 | // 工具函数 2 | 3 | /** 4 | * 发送Get请求 5 | * @param url 请求的网址 6 | * @param data 发送的数据 7 | */ 8 | function httpGet(url, data = {}) { 9 | let promise = new Promise(function (resolve, reject) { 10 | wx.request({ 11 | url: url, 12 | data: data, 13 | method: 'GET', 14 | success: function (result) { 15 | if (result.statusCode == 200) { 16 | resolve(result.data); 17 | } 18 | else { 19 | reject(); 20 | } 21 | }, 22 | fail: function () { 23 | reject(); 24 | } 25 | }); 26 | }); 27 | return promise; 28 | } 29 | 30 | /** 31 | * 发送Post请求 32 | * @param url 请求的网址 33 | * @param data 发送的数据 34 | */ 35 | function httpPost(url, data = {}) { 36 | let promise = new Promise(function (resolve, reject) { 37 | wx.request({ 38 | url: url, 39 | data: data, 40 | method: 'POST', 41 | header: { 42 | 'content-type': 'application/x-www-form-urlencoded' 43 | }, 44 | success: function (result) { 45 | if (result.statusCode == 200) { 46 | resolve(result.data); 47 | } 48 | else { 49 | reject(); 50 | } 51 | }, 52 | fail: function () { 53 | reject(); 54 | } 55 | }); 56 | }); 57 | return promise; 58 | } 59 | 60 | /** 61 | * 生成范围数组 62 | */ 63 | function range(length) { 64 | let result = []; 65 | for (let i = 0; i < length; i++) { 66 | result.push(i); 67 | } 68 | return result; 69 | } 70 | 71 | /** 72 | * 防止快速点击 73 | */ 74 | function preventDoubleClick(self, timeout = 500) { 75 | self.setData({ buttonClicked: true }); 76 | setTimeout(function () { 77 | self.setData({ buttonClicked: false }) 78 | }, timeout); 79 | } 80 | 81 | /** 82 | * 判断对象是否为空{} 83 | */ 84 | function isEmptyObject(e) { 85 | var t; 86 | for (t in e) 87 | return !1; 88 | return !0 89 | } 90 | 91 | /** 92 | * 路径参数对象转换为字符串 93 | */ 94 | function object_to_string(obj) { 95 | if (isEmptyObject(obj)) { 96 | return ""; 97 | } 98 | 99 | var str = "?"; 100 | for (var p in obj) { 101 | if (obj.hasOwnProperty(p)) { 102 | str += p + "=" + obj[p] + "&"; 103 | } 104 | } 105 | 106 | if (str.charAt(str.length - 1) == "&") { 107 | str = str.substring(0, str.length - 1); 108 | } 109 | return str; 110 | } 111 | 112 | /** 113 | * 转发函数 114 | */ 115 | function onShare(title) { 116 | const array = getCurrentPages(); 117 | const page = array[array.length - 1]; 118 | const options = page.options; 119 | const route = page.route; 120 | const path = "/" + route + object_to_string(options); 121 | return { 122 | title: title, 123 | path: path, 124 | success: function (res) { 125 | wx.showToast({ 126 | title: '谢谢你的分享' 127 | }); 128 | } 129 | }; 130 | } 131 | 132 | module.exports = { 133 | httpGet, 134 | httpPost, 135 | range, 136 | preventDoubleClick, 137 | onShare 138 | } -------------------------------------------------------------------------------- /utils/common.js: -------------------------------------------------------------------------------- 1 | const colors = require("colors.js"); 2 | 3 | 4 | // rgb滑块变化触发 5 | function rgbChange(event, that) { 6 | const value = event.detail.value; 7 | const id = event.currentTarget.id; 8 | switch (id) { 9 | case "red": 10 | that.valueChange(value, that.data.green, that.data.blue); 11 | break; 12 | case "green": 13 | that.valueChange(that.data.red, value, that.data.blue); 14 | break; 15 | case "blue": 16 | that.valueChange(that.data.red, that.data.green, value); 17 | break; 18 | } 19 | } 20 | 21 | // 带角度滑块的rgb滑块变化触发 22 | function rgbaChange(event, that, a) { 23 | const value = event.detail.value; 24 | const id = event.currentTarget.id; 25 | switch (id) { 26 | case "red": 27 | that.valueChange(value, that.data.green, that.data.blue, a); 28 | break; 29 | case "green": 30 | that.valueChange(that.data.red, value, that.data.blue, a); 31 | break; 32 | case "blue": 33 | that.valueChange(that.data.red, that.data.green, value, a); 34 | break; 35 | } 36 | } 37 | 38 | // 基准色变化时触发 39 | function baseValueChange(r, g, b, that) { 40 | const hsb = colors.rgb2hsb(r, g, b); 41 | that.setData({ 42 | red: r, 43 | green: g, 44 | blue: b, 45 | hex: colors.rgb2hex(r, g, b), 46 | saturation: hsb[1], 47 | brightness: hsb[2], 48 | render_color: that.render(r, g, b) 49 | }); 50 | } 51 | 52 | // 改变渲染组单选框时触发 53 | function radioChange(event, that) { 54 | const index = event.detail.value; 55 | const info = that.data.render_color[index]; 56 | const s = info.s; 57 | const b = info.b; 58 | 59 | that.setData({ 60 | check_index: index, 61 | saturation: s, 62 | brightness: b 63 | }); 64 | } 65 | 66 | // 饱和度滑块变化触发 67 | function saturationChange(event, that) { 68 | let temp = that.data.render_color; 69 | // 新亮度值 70 | const value = event.detail.value; 71 | const index = that.data.check_index; 72 | // 原始颜色 73 | const color = that.data.render_color[index]; 74 | const rgb = colors.hsb2rgb(color.h, value, color.b); 75 | const hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]) 76 | temp[index] = { hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: color.h, s: value, b: color.b }; 77 | that.setData({ 78 | saturation: value, 79 | render_color: temp 80 | }); 81 | } 82 | 83 | // 亮度滑块变化触发 84 | function brightnessChange(event, that) { 85 | let temp = that.data.render_color; 86 | // 新亮度值 87 | const value = event.detail.value; 88 | const index = that.data.check_index; 89 | // 原始颜色 90 | const color = that.data.render_color[index]; 91 | const rgb = colors.hsb2rgb(color.h, color.s, value); 92 | const hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]) 93 | temp[index] = { hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: color.h, s: color.s, b: value }; 94 | that.setData({ 95 | brightness: value, 96 | render_color: temp 97 | }); 98 | } 99 | 100 | 101 | module.exports = { 102 | rgbChange, // rgb滑块变化触发 103 | rgbaChange, // 带角度滑块的rgb滑块变化触发 104 | baseValueChange, // 基准色变化时触发 105 | radioChange, // 改变渲染组单选框时触发 106 | saturationChange, // 饱和度滑块变化触发 107 | brightnessChange, // 亮度滑块变化触发 108 | } -------------------------------------------------------------------------------- /style/iconfont.wxss: -------------------------------------------------------------------------------- 1 | 2 | @font-face {font-family: "iconfont"; 3 | src: url('//at.alicdn.com/t/font_586402_4kmgb6fpyb9pmn29.eot?t=1520692954907'); /* IE9*/ 4 | src: url('//at.alicdn.com/t/font_586402_4kmgb6fpyb9pmn29.eot?t=1520692954907#iefix') format('embedded-opentype'), /* IE6-IE8 */ 5 | url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAe0AAsAAAAACzwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFZW7kk5Y21hcAAAAYAAAACTAAACAgvicFdnbHlmAAACFAAAA2cAAARIvTxuCWhlYWQAAAV8AAAALwAAADYQs2PPaGhlYQAABawAAAAcAAAAJAfeA4pobXR4AAAFyAAAABQAAAAkI+kAAGxvY2EAAAXcAAAAFAAAABQE+AXobWF4cAAABfAAAAAfAAAAIAEbAF1uYW1lAAAGEAAAAUUAAAJtPlT+fXBvc3QAAAdYAAAAWQAAAHPdvQSJeJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2Bk/ss4gYGVgYOpk+kMAwNDP4RmfM1gxMjBwMDEwMrMgBUEpLmmMDgwVDz3Ym7438AQw9zA0AAUZgTJAQAqjQy8eJzFkcsNwkAMRMfkK7QHSkgBNJJUQQkcUwQnKkh1dgu5hbEdKUADGeut5JHXu7IBNAAqcic1IG8IXC+6En6Fa/g1HsxvDK+fteiipqsNNm3bnzOG8y2Jm0e4c2Gnnn0btOhotDhNct7TvypxPvesJ/MOv6gl4eSgS+LbUEu8XtfEt2lD4lu2MeGsYVOC7gPzey2cAHicVZPdaxxVGMbPcybzvTOTnc+d2e7ndGd203aTbjYzFE2iJrutRYygoCGBInjhjYKIBMWLXviJInolVChWlP4HitILg1WkIHjRmqAXEirkqjeCN0JOPbNbAg7DObznvO8zv/M+Z4hIyP0D4YZQIQ7pkrNknTxFCKRTaJu0hlY67NNT8FqiF7imkMZpS47bfWEZQVty/UE2TAJJliyYqGOxNcjSPk2xNFyhD2Hg14CwGj1td07YwsfQKmn9bXaRfgGvEZ+wVs6wx0+vuoOmo+yUbDu07Q8VSRQVSmcsEy8FviqqmsS+FK3Iu9Ho0QZKYRo9sWk0q/bz7w1frnUCFbh8GU61aV5fLUdl/r4Z+Y4dyrOGUomM+KSLnb/0ilOqJXcJf8DPel34TdghpwnpmJA72dIw7XDyFeR9pHzFDcSkmOsIslzk43RHWJy/6LFPzVm87j/WHW1RujUa85G90l0s5q1xNof3ha310Tal26N7mE++qZ/sND+rtXk42ga2R0bpqyqmdWj8vLZJJzuUcymc6yfhWyEjMrFIhTRJjztxjjzKkadYBYQs5FkScC8mSMIgy1eQdtLyFLJAzh1Z8oUpPdJEkk14Ir2CjbX1DSD9fHCB4jbmltgezsCjtPInHS/0U7BLb2Bjneew368+yDk32afoPYnzC/0E14T6dIXt3ZxU3MH519gflNetbRwdzPXPXqB0zG5TD7QC9H7gSbh2h45xZZLCP/8vevOF+sQHQugu3SWzhKhITPjcy+I+5ciG9Gv2vRbZUNFl+5oTanhEw0foqXBDld1jB1roqsi06v91OnxtmLRlrhPAX0Ghs4+uZkca1ytEQvtZNOCokauyPa2qsVsqnJA84BGeoQu8+6TDa1NMhOrIcgihEWsldqso2JswwPnOUGODK2rHpMcaw0LD6fMfglMU5+HG4VANXZ7V4xrISlpssAOaqDhGM2LVYPuETjRepL+SNnmYY7WlGiS51U6Wytkit32YxK22JBeO82iZx3nKm9eARAPJz/Iky2XexWyVd0IIdAvK0d8zIhSs6pals90oBuKImlFsLb+j1xR98+5VUfBrM8K7P15Syp7ygYxXLf1QgThDdQWWb8XR0T/TskPd+uUtXalrz1XvE9fyVCvYD15QvFkonyjef84aveMAeJxjYGRgYADif2+Ll8bz23xl4GZhAIFrp/hvIej/y1kYmMuBXA4GJpAoAGamC/QAeJxjYGRgYG7438AQw8IAAkCSkQEVcAIARw8CcnicY2FgYGB+ycDAwoAbAwAfCwENAAAAAAB2AMIBOgFeAYIBpAHGAiR4nGNgZGBg4GQIZOBgAAEmIOYCQgaG/2A+AwAR3gF5AHicZY9NTsMwEIVf+gekEqqoYIfkBWIBKP0Rq25YVGr3XXTfpk6bKokjx63UA3AejsAJOALcgDvwSCebNpbH37x5Y08A3OAHHo7fLfeRPVwyO3INF7gXrlN/EG6QX4SbaONVuEX9TdjHM6bCbXRheYPXuGL2hHdhDx18CNdwjU/hOvUv4Qb5W7iJO/wKt9Dx6sI+5l5XuI1HL/bHVi+cXqnlQcWhySKTOb+CmV7vkoWt0uqca1vEJlODoF9JU51pW91T7NdD5yIVWZOqCas6SYzKrdnq0AUb5/JRrxeJHoQm5Vhj/rbGAo5xBYUlDowxQhhkiMro6DtVZvSvsUPCXntWPc3ndFsU1P9zhQEC9M9cU7qy0nk6T4E9XxtSdXQrbsuelDSRXs1JErJCXta2VELqATZlV44RelzRiT8oZ0j/AAlabsgAAAB4nG3BWw5AMBAF0LkepazFoorRNGRajYnavQ+/zqGKPgP9s6hQo0ELgw49LAZC6TeWEpz4MbH4J+qpTlqWi7PJfGkWk9yyazIqWzxWe/M8hSXKRPQC23YWGAAAAA==') format('woff'), 6 | url('//at.alicdn.com/t/font_586402_4kmgb6fpyb9pmn29.ttf?t=1520692954907') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/ 7 | url('//at.alicdn.com/t/font_586402_4kmgb6fpyb9pmn29.svg?t=1520692954907#iconfont') format('svg'); /* iOS 4.1- */ 8 | } 9 | 10 | .iconfont { 11 | font-family:"iconfont" !important; 12 | font-size:16px; 13 | font-style:normal; 14 | -webkit-font-smoothing: antialiased; 15 | -moz-osx-font-smoothing: grayscale; 16 | } 17 | 18 | .icon-fenxiang:before { content: "\e60c"; } 19 | 20 | .icon-pengyouquan:before { content: "\e6a0"; } 21 | 22 | .icon-enter:before { content: "\e6f8"; } 23 | 24 | .icon-return:before { content: "\e720"; } 25 | 26 | .icon-packup:before { content: "\e749"; } 27 | 28 | .icon-unfold:before { content: "\e74a"; } 29 | 30 | .icon-web-icon-:before { content: "\e6e7"; } 31 | -------------------------------------------------------------------------------- /pages/web/colordetail.wxml: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |

{{hex}}

6 |
7 |
8 |
9 |
10 |

RGB分量

11 |
12 |

R:

13 |
{{red}}
14 |
15 |
16 |

G:

17 |
{{green}}
18 |
19 |
20 |

B:

21 |
{{blue}}
22 |
23 |
24 |
25 |
26 |
27 |

CMYK分量

28 |
29 |

C:

30 |
{{cyan}}%
31 |
32 |
33 |

M:

34 |
{{magenta}}%
35 |
36 |
37 |

Y:

38 |
{{yellow}}%
39 |
40 |
41 |

K:

42 |
{{black}}%
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |

Lab分量

51 |
52 |

L:

53 |
{{luminosity}}
54 |
55 |
56 |

a:

57 |
{{a}}
58 |
59 |
60 |

b:

61 |
{{b}}
62 |
63 |
64 |
65 |
66 |
67 |

HSB分量

68 |
69 |

H:

70 |
{{hue}}%
71 |
72 |
73 |

S:

74 |
{{saturation}}%
75 |
76 |
77 |

B:

78 |
{{brightness}}%
79 |
80 |
81 |
82 |
83 |
-------------------------------------------------------------------------------- /pages/tools/monochromatic/monochromatic.js: -------------------------------------------------------------------------------- 1 | // 单色 2 | // pages/monochromatic/monochromatic.js 3 | const { 4 | check_rgb_value, 5 | rgb2hsb, 6 | hsb2rgb, 7 | rgb2hex 8 | } = require('../../../utils/colors.js'); 9 | 10 | const { preventDoubleClick, onShare } = require('../../../utils/functions.js'); 11 | 12 | const { 13 | rgbChange, 14 | baseValueChange, 15 | radioChange, 16 | saturationChange, 17 | brightnessChange, 18 | } = require('../../../utils/common.js'); 19 | 20 | Page({ 21 | // 页面的初始数据 22 | data: { 23 | red: 0, // 红值 24 | green: 0, // 绿值 25 | blue: 0, // 蓝值 26 | hex: "#000000", // 十六进制RGB值 27 | render_color: new Array, // 要渲染的4个单色 28 | saturation: 0, // 饱和度 29 | brightness: 0, // 亮度 30 | check_index: 0, // 勾选的单选框 31 | }, 32 | 33 | // 页面加载时, 读取传入的颜色信息,如果没有则随机,然后缓存页面颜色值 34 | onLoad: function (options) { 35 | const red = options.red; 36 | const green = options.green; 37 | const blue = options.blue; 38 | if (!check_rgb_value(red) || !check_rgb_value(green) || !check_rgb_value(blue)) { 39 | this.random_value_change(); 40 | } 41 | else { 42 | this.valueChange(red, green, blue); 43 | } 44 | }, 45 | 46 | // 输入值发生变化 47 | valueChange: function (r, g, b) { 48 | baseValueChange(r, g, b, this); 49 | }, 50 | 51 | // 改变RGB颜色 52 | rgbChange: function (event) { 53 | rgbChange(event, this); 54 | }, 55 | 56 | // 改变单选框 57 | radioChange: function (event) { 58 | radioChange(event, this); 59 | }, 60 | 61 | // 改变饱和度 62 | saturationChange: function (event) { 63 | saturationChange(event, this); 64 | }, 65 | 66 | // 改变亮度 67 | brightnessChange: function (event) { 68 | brightnessChange(event, this); 69 | }, 70 | 71 | // 计算单色 72 | render: function (r, g, b) { 73 | let render_color = new Array; 74 | const hsl = rgb2hsb(r, g, b); 75 | const h = hsl[0]; 76 | const s = hsl[1]; 77 | const l = hsl[2]; 78 | // 变化基数 = 10 79 | const saturation_base = s < 50 ? 10 : -10; 80 | const brightness_base = l < 50 ? 10 : -10; 81 | 82 | for (let i = 1; i < 5; i++) { 83 | const new_s = s + saturation_base * i; 84 | const new_b = l + brightness_base * i; 85 | const rgb = hsb2rgb(h, new_s, new_b); 86 | const hex = rgb2hex(rgb[0], rgb[1], rgb[2]); 87 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: h, s: new_s, b: new_b }); 88 | } 89 | return render_color; 90 | }, 91 | 92 | // 点击收藏按钮 93 | fav: function (event) { 94 | if (!this.data.buttonClicked) { 95 | preventDoubleClick(this); 96 | const color1 = this.data.hex; 97 | const color2 = this.data.render_color[0].hex; 98 | const color3 = this.data.render_color[1].hex; 99 | const color4 = this.data.render_color[2].hex; 100 | const color5 = this.data.render_color[3].hex; 101 | wx.navigateTo({ 102 | url: '/pages/plaza/fav?name=&color1=' + color1 + "&color2=" + color2 + "&color3=" + color3 + "&color4=" + color4 + "&color5=" + color5 103 | }); 104 | } 105 | }, 106 | 107 | // 随机颜色值 108 | random_value_change: function () { 109 | if (!this.data.buttonClicked) { 110 | preventDoubleClick(this); 111 | const r = Math.round(Math.random() * 255); 112 | const g = Math.round(Math.random() * 255); 113 | const b = Math.round(Math.random() * 255); 114 | this.valueChange(r, g, b); 115 | } 116 | }, 117 | 118 | copy: function (event) { 119 | const hex = event.currentTarget.dataset.color; 120 | wx.setClipboardData({ 121 | data: hex, 122 | success: function (res) { 123 | wx.showToast({ 124 | title: '复制HEX值成功', 125 | }); 126 | } 127 | }); 128 | }, 129 | 130 | copyAll: function () { 131 | let content = '基准色:' + this.data.hex + ', 单色组:'; 132 | for (let i = 0; i < this.data.render_color.length; i++) { 133 | content += this.data.render_color[i].hex + ', ' 134 | }; 135 | wx.setClipboardData({ 136 | data: content.substring(0, content.lastIndexOf(',')), 137 | success: function (res) { 138 | wx.showToast({ 139 | title: '复制配色方案成功', 140 | }); 141 | } 142 | }); 143 | }, 144 | 145 | onShareAppMessage: function (res) { 146 | return onShare("单色配色方案"); 147 | } 148 | }) -------------------------------------------------------------------------------- /pages/tools/triad/triad.js: -------------------------------------------------------------------------------- 1 | // 分裂补色 2 | // pages/traid/traid.js 3 | const { 4 | check_rgb_value, 5 | rgb2hsb, 6 | hsb2rgb, 7 | rgb2hex 8 | } = require('../../../utils/colors.js'); 9 | 10 | const { preventDoubleClick, onShare } = require('../../../utils/functions.js'); 11 | 12 | const { 13 | rgbChange, 14 | baseValueChange, 15 | radioChange, 16 | saturationChange, 17 | brightnessChange, 18 | } = require('../../../utils/common.js'); 19 | 20 | 21 | Page({ 22 | // 页面的初始数据 23 | data: { 24 | red: 0, // 红值 25 | green: 0, // 绿值 26 | blue: 0, // 蓝值 27 | hex: "#000000", // 十六进制RGB值 28 | render_color: new Array, // 要渲染的4个单色 29 | saturation: 0, // 饱和度 30 | brightness: 0, // 亮度 31 | check_index: 0, // 勾选的单选框 32 | }, 33 | 34 | // 页面加载时, 读取传入的颜色信息,如果没有则随机,然后缓存页面颜色值 35 | onLoad: function (options) { 36 | const red = options.red; 37 | const green = options.green; 38 | const blue = options.blue; 39 | if (!check_rgb_value(red) || !check_rgb_value(green) || !check_rgb_value(blue)) { 40 | this.random_value_change(); 41 | } 42 | else { 43 | this.valueChange(red, green, blue); 44 | } 45 | }, 46 | 47 | // 随机颜色值 48 | random_value_change: function () { 49 | if (!this.data.buttonClicked) { 50 | preventDoubleClick(this); 51 | const r = Math.round(Math.random() * 255); 52 | const g = Math.round(Math.random() * 255); 53 | const b = Math.round(Math.random() * 255); 54 | this.valueChange(r, g, b); 55 | } 56 | }, 57 | 58 | // 输入值发生变化 59 | valueChange: function (r, g, b) { 60 | baseValueChange(r, g, b, this); 61 | }, 62 | 63 | // 改变RGB颜色 64 | rgbChange: function (event) { 65 | rgbChange(event, this); 66 | }, 67 | 68 | // 改变单选框 69 | radioChange: function (event) { 70 | console.log(event); 71 | radioChange(event, this); 72 | }, 73 | 74 | // 改变饱和度 75 | saturationChange: function (event) { 76 | saturationChange(event, this); 77 | }, 78 | 79 | // 改变亮度 80 | brightnessChange: function (event) { 81 | brightnessChange(event, this); 82 | }, 83 | 84 | // 计算分裂补色 85 | render: function (r, g, b) { 86 | let render_color = new Array; 87 | const hsl = rgb2hsb(r, g, b); 88 | const h = hsl[0]; 89 | const s = hsl[1]; 90 | const l = hsl[2]; 91 | const saturation = s > 50 ? s - 25 : s + 25; 92 | 93 | for (let i = 1; i <= 2; i++) { 94 | // 分裂补色组第1值 95 | let hue = (h + 120 * i) % 360; 96 | let rgb = hsb2rgb(hue, s, l); 97 | let hex = rgb2hex(rgb[0], rgb[1], rgb[2]); 98 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: hue, s: s, b: l }); 99 | 100 | // 分裂补色组第2值 101 | rgb = hsb2rgb(hue, saturation, l); 102 | hex = rgb2hex(rgb[0], rgb[1], rgb[2]); 103 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: hue, s: saturation, b: l }); 104 | } 105 | 106 | return render_color; 107 | }, 108 | 109 | // 点击收藏按钮 110 | fav: function (event) { 111 | if (!this.data.buttonClicked) { 112 | preventDoubleClick(this); 113 | const color1 = this.data.hex; 114 | const color2 = this.data.render_color[0].hex; 115 | const color3 = this.data.render_color[1].hex; 116 | const color4 = this.data.render_color[2].hex; 117 | const color5 = this.data.render_color[3].hex; 118 | wx.navigateTo({ 119 | url: '/pages/plaza/fav?name=&color1=' + color1 + "&color2=" + color2 + "&color3=" + color3 + "&color4=" + color4 + "&color5=" + color5 120 | }); 121 | } 122 | }, 123 | 124 | copy: function (event) { 125 | const hex = event.currentTarget.dataset.color; 126 | wx.setClipboardData({ 127 | data: hex, 128 | success: function (res) { 129 | wx.showToast({ 130 | title: '复制HEX值成功', 131 | }); 132 | } 133 | }); 134 | }, 135 | 136 | copyAll: function () { 137 | let content = '基准色:' + this.data.hex + ', 分裂补色:'; 138 | for (let i = 0; i < this.data.render_color.length; i++) { 139 | content += this.data.render_color[i].hex + ', ' 140 | }; 141 | wx.setClipboardData({ 142 | data: content.substring(0, content.lastIndexOf(',')), 143 | success: function (res) { 144 | wx.showToast({ 145 | title: '复制配色方案成功', 146 | }); 147 | } 148 | }); 149 | }, 150 | 151 | onShareAppMessage: function (res) { 152 | return onShare("分裂补色配色方案"); 153 | } 154 | }) -------------------------------------------------------------------------------- /pages/tools/analogous/analogous.js: -------------------------------------------------------------------------------- 1 | // 类比色 2 | // pages/analogous/analogous.js 3 | const { 4 | check_rgb_value, 5 | rgb2hsb, 6 | hsb2rgb, 7 | rgb2hex 8 | } = require('../../../utils/colors.js'); 9 | 10 | const { preventDoubleClick, onShare } = require('../../../utils/functions.js'); 11 | 12 | const { 13 | rgbChange, 14 | baseValueChange, 15 | radioChange, 16 | saturationChange, 17 | brightnessChange, 18 | rgbaChange, 19 | } = require('../../../utils/common.js'); 20 | 21 | Page({ 22 | // 页面的初始数据 23 | data: { 24 | red: 0, // 红值 25 | green: 0, // 绿值 26 | blue: 0, // 蓝值 27 | hex: "#000000", // 十六进制RGB值 28 | render_color: new Array(), // 要渲染的4个类比色 29 | saturation: 0, // 饱和度 30 | brightness: 0, // 亮度 31 | check_index: 0, // 勾选的单选框 32 | angle: 1, // 角度 33 | }, 34 | 35 | // 页面加载时, 读取传入的颜色信息,如果没有则随机,然后缓存页面颜色值 36 | onLoad: function (options) { 37 | const red = options.red; 38 | const green = options.green; 39 | const blue = options.blue; 40 | if (!check_rgb_value(red) || !check_rgb_value(green) || !check_rgb_value(blue) || angle > 72 || angle < 1 || isNaN(angle)) { 41 | this.random_value_change(); 42 | } 43 | else { 44 | this.valueChange(red, green, blue, angle); 45 | } 46 | }, 47 | 48 | // 输入值发生变化 缓存页面颜色值 49 | valueChange: function (r, g, b, angle) { 50 | const hsb = rgb2hsb(r, g, b, angle); 51 | this.setData({ 52 | red: r, 53 | green: g, 54 | blue: b, 55 | angle: angle, 56 | hex: rgb2hex(r, g, b), 57 | saturation: hsb[1], 58 | brightness: hsb[2], 59 | render_color: this.render(r, g, b, angle) 60 | }); 61 | }, 62 | 63 | // 改变RGB颜色 64 | rgbChange: function (event) { 65 | rgbaChange(event, this, this.data.angle); 66 | }, 67 | 68 | // 改变单选框 69 | radioChange: function (event) { 70 | common.radioChange(event, this); 71 | }, 72 | 73 | // 改变饱和度 74 | saturationChange: function (event) { 75 | saturationChange(event, this); 76 | }, 77 | 78 | // 改变亮度 79 | brightnessChange: function (event) { 80 | common.brightnessChange(event, this); 81 | }, 82 | 83 | // 改变角度 84 | angleChange: function (event) { 85 | this.valueChange(this.data.red, this.data.green, this.data.blue, event.detail.value); 86 | }, 87 | 88 | // 计算类比色 89 | render: function (r, g, b, angle) { 90 | let render_color = new Array; 91 | const hsl = rgb2hsb(r, g, b); 92 | const h = hsl[0]; 93 | const s = hsl[1]; 94 | const l = hsl[2]; 95 | for (let i = 1; i < 5; i++) { 96 | const a = angle * i; 97 | const new_h = (h + a) % 360; 98 | const rgb = hsb2rgb(new_h, s, l); 99 | const hex = rgb2hex(rgb[0], rgb[1], rgb[2]); 100 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: new_h, s: s, b: l }); 101 | } 102 | return render_color; 103 | }, 104 | 105 | // 点击收藏按钮 106 | fav: function (event) { 107 | if (!this.data.buttonClicked) { 108 | preventDoubleClick(this); 109 | const color1 = this.data.hex; 110 | const color2 = this.data.render_color[0].hex; 111 | const color3 = this.data.render_color[1].hex; 112 | const color4 = this.data.render_color[2].hex; 113 | const color5 = this.data.render_color[3].hex; 114 | wx.navigateTo({ 115 | url: '/pages/plaza/fav?name=&color1=' + color1 + "&color2=" + color2 + "&color3=" + color3 + "&color4=" + color4 + "&color5=" + color5 116 | }); 117 | } 118 | }, 119 | 120 | // 随机颜色值 121 | random_value_change: function () { 122 | if (!this.data.buttonClicked) { 123 | preventDoubleClick(this); 124 | const r = Math.round(Math.random() * 255); 125 | const g = Math.round(Math.random() * 255); 126 | const b = Math.round(Math.random() * 255); 127 | const a = Math.round(Math.random() * 100) % 72 + 1; 128 | this.valueChange(r, g, b, a); 129 | } 130 | }, 131 | 132 | copy: function (event) { 133 | const hex = event.currentTarget.dataset.color; 134 | wx.setClipboardData({ 135 | data: hex, 136 | success: function (res) { 137 | wx.showToast({ 138 | title: '复制HEX值成功', 139 | }); 140 | } 141 | }); 142 | }, 143 | 144 | copyAll: function () { 145 | let content = '基准色:' + this.data.hex + ', 类比色组:'; 146 | for (let i = 0; i < this.data.render_color.length; i++) { 147 | content += this.data.render_color[i].hex + ', ' 148 | }; 149 | wx.setClipboardData({ 150 | data: content.substring(0, content.lastIndexOf(',')), 151 | success: function (res) { 152 | wx.showToast({ 153 | title: '复制配色方案成功', 154 | }); 155 | } 156 | }); 157 | }, 158 | 159 | onShareAppMessage: function (res) { 160 | return onShare("类比色(相似色)配色方案"); 161 | } 162 | }) -------------------------------------------------------------------------------- /pages/tools/complementary/complementary.js: -------------------------------------------------------------------------------- 1 | // 互补色 2 | // pages/complementary/complementary.js 3 | const { 4 | check_rgb_value, 5 | rgb2hsb, 6 | hsb2rgb, 7 | rgb2hex 8 | } = require('../../../utils/colors.js'); 9 | 10 | const { preventDoubleClick, onShare } = require('../../../utils/functions.js'); 11 | 12 | const { 13 | rgbChange, 14 | baseValueChange, 15 | radioChange, 16 | saturationChange, 17 | brightnessChange, 18 | } = require('../../../utils/common.js'); 19 | 20 | Page({ 21 | // 页面的初始数据 22 | data: { 23 | red: 0, // 红值 24 | green: 0, // 绿值 25 | blue: 0, // 蓝值 26 | hex: "#000000", // 十六进制RGB值 27 | render_color: new Array(0), // 要渲染的4个单色 28 | saturation: 0, // 饱和度 29 | brightness: 0, // 亮度 30 | check_index: 0, // 勾选的单选框 31 | }, 32 | 33 | // 页面加载时, 读取传入的颜色信息,如果没有则随机,然后缓存页面颜色值 34 | onLoad: function (options) { 35 | const red = options.red; 36 | const green = options.green; 37 | const blue = options.blue; 38 | if (!check_rgb_value(red) || !check_rgb_value(green) || !check_rgb_value(blue)) { 39 | this.random_value_change(); 40 | } 41 | else { 42 | this.valueChange(red, green, blue); 43 | } 44 | }, 45 | 46 | // 输入值发生变化 47 | valueChange: function (r, g, b) { 48 | baseValueChange(r, g, b, this); 49 | }, 50 | 51 | // 改变RGB颜色 52 | rgbChange: function (event) { 53 | rgbChange(event, this); 54 | }, 55 | 56 | // 改变单选框 57 | radioChange: function (event) { 58 | radioChange(event, this); 59 | }, 60 | 61 | // 改变饱和度 62 | saturationChange: function (event) { 63 | saturationChange(event, this); 64 | }, 65 | 66 | // 改变亮度 67 | brightnessChange: function (event) { 68 | brightnessChange(event, this); 69 | }, 70 | 71 | // 计算补色 72 | render: function (r, g, b) { 73 | let render_color = new Array; 74 | const hsl = rgb2hsb(r, g, b); 75 | const h = hsl[0]; 76 | const s = hsl[1]; 77 | const l = hsl[2]; 78 | 79 | // 变化基数 = 10 80 | const hue_base = s < 50 ? 10 : -10; 81 | 82 | // 辅色 H变化,S,B和主色一样 83 | let new_h = (h + hue_base) % 360; 84 | let rgb = hsb2rgb(new_h, s, l); 85 | let hex = rgb2hex(rgb[0], rgb[1], rgb[2]); 86 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: new_h, s: s, b: l }); 87 | 88 | // 补色1 H + 180, S、B和主色一样 89 | new_h = (h + 180) % 360; 90 | rgb = hsb2rgb(new_h, s, l); 91 | hex = rgb2hex(rgb[0], rgb[1], rgb[2]); 92 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: new_h, s: s, b: l }); 93 | 94 | // 补色2 95 | new_h = (h + 180 + hue_base) % 360; 96 | rgb = hsb2rgb(new_h, s, l); 97 | hex = rgb2hex(rgb[0], rgb[1], rgb[2]); 98 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: new_h, s: s, b: l }); 99 | 100 | // 补色3 101 | new_h = (h + 180 - hue_base) % 360; 102 | rgb = hsb2rgb(new_h, s, l); 103 | hex = rgb2hex(rgb[0], rgb[1], rgb[2]); 104 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: new_h, s: s, b: l }); 105 | 106 | return render_color; 107 | }, 108 | 109 | // 点击收藏按钮 110 | fav: function (event) { 111 | if (!this.data.buttonClicked) { 112 | preventDoubleClick(this); 113 | const color1 = this.data.hex; 114 | const color2 = this.data.render_color[0].hex; 115 | const color3 = this.data.render_color[1].hex; 116 | const color4 = this.data.render_color[2].hex; 117 | const color5 = this.data.render_color[3].hex; 118 | wx.navigateTo({ 119 | url: '/pages/plaza/fav?name=&color1=' + color1 + "&color2=" + color2 + "&color3=" + color3 + "&color4=" + color4 + "&color5=" + color5 120 | }); 121 | } 122 | }, 123 | 124 | // 随机颜色值 125 | random_value_change: function () { 126 | if (!this.data.buttonClicked) { 127 | preventDoubleClick(this); 128 | const r = Math.round(Math.random() * 255); 129 | const g = Math.round(Math.random() * 255); 130 | const b = Math.round(Math.random() * 255); 131 | this.valueChange(r, g, b); 132 | } 133 | }, 134 | 135 | copy: function (event) { 136 | const hex = event.currentTarget.dataset.color; 137 | wx.setClipboardData({ 138 | data: hex, 139 | success: function (res) { 140 | wx.showToast({ 141 | title: '复制HEX值成功', 142 | }); 143 | } 144 | }); 145 | }, 146 | 147 | copyAll: function () { 148 | let content = '基准色:' + this.data.hex + ', 辅色+补色组:'; 149 | for (let i = 0; i < this.data.render_color.length; i++) { 150 | content += this.data.render_color[i].hex + ', ' 151 | }; 152 | wx.setClipboardData({ 153 | data: content.substring(0, content.lastIndexOf(',')), 154 | success: function (res) { 155 | wx.showToast({ 156 | title: '复制配色方案成功', 157 | }); 158 | } 159 | }); 160 | }, 161 | 162 | onShareAppMessage: function (res) { 163 | return onShare("互补色配色方案"); 164 | } 165 | }) -------------------------------------------------------------------------------- /pages/plaza/detail.js: -------------------------------------------------------------------------------- 1 | // pages/plaza/detail.js 2 | 3 | const { 4 | hex2rgb, 5 | rgb2hsb 6 | } = require('../../utils/colors.js'); 7 | 8 | const { preventDoubleClick, onShare, httpPost, httpGet } = require('../../utils/functions.js'); 9 | const { DELETE_USER_COLORS } = require('../../utils/constant.js'); 10 | 11 | Page({ 12 | 13 | /** 14 | * 页面的初始数据 15 | */ 16 | data: { 17 | name: '', 18 | colors: new Array, 19 | source: '', 20 | id: -1 21 | }, 22 | 23 | /** 24 | * 生命周期函数--监听页面加载 25 | */ 26 | onLoad: function (options) { 27 | const source = options.source == 'my' ? 'my' : 'other'; 28 | const id = options.id == undefined ? -1 : options.id; 29 | const name = options.name; 30 | const color1 = options.color1; 31 | const color2 = options.color2; 32 | const color3 = options.color3; 33 | const color4 = options.color4; 34 | const color5 = options.color5; 35 | let colors = new Array(color1, color2, color3, color4, color5); 36 | 37 | let result = new Array; 38 | for (let i = 0; i < 5; i++) { 39 | const color = colors[i]; 40 | const rgb = hex2rgb(color); 41 | const hsb = rgb2hsb(rgb[0], rgb[1], rgb[2]); 42 | result.push({ 43 | hex: color, 44 | rgb: rgb, 45 | hsb: hsb 46 | }); 47 | } 48 | 49 | this.setData({ 50 | id: id, 51 | source: source, 52 | name: name, 53 | colors: result 54 | }); 55 | }, 56 | 57 | /** 58 | * 颜色详情 59 | */ 60 | detail: function (event) { 61 | if (!this.data.buttonClicked) { 62 | preventDoubleClick(this); 63 | const hex = event.currentTarget.dataset.color; 64 | wx.navigateTo({ 65 | url: '/pages/web/colordetail?color=' + hex 66 | }); 67 | } 68 | }, 69 | 70 | /** 71 | * 收藏 72 | */ 73 | fav: function () { 74 | if (!this.data.buttonClicked) { 75 | preventDoubleClick(this); 76 | wx.navigateTo({ 77 | url: '/pages/plaza/fav?name=' + this.data.name + 78 | '&color1=' + this.data.colors[0].hex + 79 | '&color2=' + this.data.colors[1].hex + 80 | '&color3=' + this.data.colors[2].hex + 81 | '&color4=' + this.data.colors[3].hex + 82 | '&color5=' + this.data.colors[4].hex 83 | }); 84 | } 85 | }, 86 | 87 | copy: function () { 88 | let content = ""; 89 | for (let i = 0; i < this.data.colors.length; i++) { 90 | content += this.data.colors[i].hex + ', '; 91 | } 92 | content = content.substring(0, content.lastIndexOf(',')); 93 | wx.setClipboardData({ 94 | data: content, 95 | success: function (res) { 96 | wx.showToast({ 97 | title: '复制配色方案成功', 98 | }); 99 | } 100 | }); 101 | }, 102 | 103 | drop: function () { 104 | if (!this.data.buttonClicked) { 105 | preventDoubleClick(this); 106 | const that = this; 107 | if (this.data.source == 'my' && this.data.id != -1) { 108 | wx.showModal({ 109 | title: '提示', 110 | content: '删除配色方案' + that.data.name + '?', 111 | showCancel: true, 112 | success: function (res) { 113 | if (res.confirm) { 114 | const url = DELETE_USER_COLORS; 115 | const data = { 116 | cust_id: wx.getStorageSync('cust_id'), 117 | openid: wx.getStorageSync('openid'), 118 | id: that.data.id 119 | }; 120 | httpGet(url, data).then(data => { 121 | if (data.code == 0) { 122 | wx.showToast({ 123 | title: '删除成功', 124 | success: function () { 125 | setTimeout(function () { 126 | wx.navigateBack({ 127 | delta: 1 128 | }); 129 | }, 1500); 130 | } 131 | }) 132 | } 133 | }); 134 | } 135 | } 136 | }); 137 | } 138 | } 139 | }, 140 | 141 | edit: function () { 142 | if (!this.data.buttonClicked) { 143 | preventDoubleClick(this); 144 | const name = this.data.name; 145 | const color1 = this.data.colors[0].hex; 146 | const color2 = this.data.colors[1].hex; 147 | const color3 = this.data.colors[2].hex; 148 | const color4 = this.data.colors[3].hex; 149 | const color5 = this.data.colors[4].hex; 150 | const id = this.data.id; 151 | wx.navigateTo({ 152 | url: '/pages/plaza/edit?id=' + id + '&name=' + name + 153 | '&color1=' + color1 + 154 | '&color2=' + color2 + 155 | '&color3=' + color3 + 156 | '&color4=' + color4 + 157 | '&color5=' + color5 158 | }); 159 | } 160 | }, 161 | 162 | /** 163 | * 用户点击右上角分享 164 | */ 165 | onShareAppMessage: function () { 166 | return onShare('配色方案' + this.data.name + '详情'); 167 | } 168 | }) -------------------------------------------------------------------------------- /pages/tools/secondary/secondary.js: -------------------------------------------------------------------------------- 1 | // 二次色配比 2 | const { 3 | check_rgb_value, 4 | rgb2hsb, 5 | hsb2rgb, 6 | rgb2hex 7 | } = require('../../../utils/colors.js'); 8 | 9 | const { preventDoubleClick, onShare } = require('../../../utils/functions.js'); 10 | 11 | const { rgbChange } = require('../../../utils/common.js'); 12 | 13 | Page({ 14 | data: { 15 | red: 0, 16 | green: 0, 17 | blue: 0, 18 | hex: 0, 19 | render_color: new Array, 20 | hue: 0, 21 | saturation: 0, 22 | brightness: 0 23 | }, 24 | 25 | // 页面加载时, 读取传入的颜色信息,如果没有则随机,然后缓存页面颜色值 26 | onLoad: function (options) { 27 | const red = options.red; 28 | const green = options.green; 29 | const blue = options.blue; 30 | const saturation = options.saturation; 31 | const brightness = options.brightness; 32 | if (!check_rgb_value(red) || !check_rgb_value(green) || !check_rgb_value(blue) || 33 | brightness < 0 || brightness > 100 || saturation < 0 || saturation > 100) { 34 | this.random_value_change(); 35 | } 36 | else { 37 | this.valueChange(red, green, blue); 38 | } 39 | }, 40 | 41 | valueChange: function (r, g, b) { 42 | var hsb = rgb2hsb(r, g, b); 43 | this.setData({ 44 | red: r, 45 | green: g, 46 | blue: b, 47 | hex: rgb2hex(r, g, b), 48 | hue: hsb[0], 49 | saturation: hsb[1], 50 | brightness: hsb[2] 51 | }); 52 | this.render(); 53 | }, 54 | 55 | rgbChange: function (event) { 56 | rgbChange(event, this); 57 | }, 58 | 59 | saturationChange: function (event) { 60 | const value = event.detail.value; 61 | const rgb = hsb2rgb(this.data.hue, value, this.data.brightness); 62 | this.valueChange(rgb[0], rgb[1], rgb[2]); 63 | }, 64 | 65 | brightnessChange: function (event) { 66 | const value = event.detail.value; 67 | const rgb = hsb2rgb(this.data.hue, this.data.saturation, value); 68 | this.valueChange(rgb[0], rgb[1], rgb[2]); 69 | }, 70 | 71 | render: function () { 72 | let render_color = new Array; 73 | 74 | const r1 = Math.round(Math.random() * 255); 75 | const g1 = Math.round(Math.random() * 255); 76 | const b1 = Math.round(Math.random() * 255); 77 | const r2 = Math.round(Math.random() * 255); 78 | const g2 = Math.round(Math.random() * 255); 79 | const b2 = Math.round(Math.random() * 255); 80 | 81 | const hex1 = rgb2hex(this.data.red, g1, b1); 82 | const hex2 = rgb2hex(this.data.red, this.data.green, b2); 83 | const hex3 = rgb2hex(r1, this.data.green, this.data.blue); 84 | const hex4 = rgb2hex(r2, g2, this.data.blue); 85 | 86 | const hsb1 = rgb2hsb(this.data.red, g1, b1); 87 | const hsb2 = rgb2hsb(this.data.red, this.data.green, b2); 88 | const hsb3 = rgb2hsb(r1, this.data.green, this.data.blue); 89 | const hsb4 = rgb2hsb(r2, g2, this.data.blue); 90 | 91 | render_color.push({ 92 | hex: hex1, 93 | red: this.data.red, green: g1, blue: b1, 94 | h: hsb1[0], s: hsb1[1], b: hsb1[2] 95 | }); 96 | 97 | render_color.push({ 98 | hex: hex2, 99 | red: this.data.red, green: this.data.green, blue: b2, 100 | h: hsb2[0], s: hsb2[1], b: hsb2[2] 101 | }); 102 | 103 | render_color.push({ 104 | hex: hex3, 105 | red: r1, green: this.data.green, blue: this.data.blue, 106 | h: hsb3[0], s: hsb3[1], b: hsb3[2] 107 | }); 108 | 109 | render_color.push({ 110 | hex: hex4, 111 | red: r2, green: g2, blue: this.data.blue, 112 | h: hsb4[0], s: hsb4[1], b: hsb4[2] 113 | }); 114 | 115 | this.setData({ render_color: render_color }); 116 | }, 117 | 118 | // 点击收藏按钮 119 | fav: function (event) { 120 | if (!this.data.buttonClicked) { 121 | preventDoubleClick(this); 122 | const color1 = this.data.hex; 123 | const color2 = this.data.render_color[0].hex; 124 | const color3 = this.data.render_color[1].hex; 125 | const color4 = this.data.render_color[2].hex; 126 | const color5 = this.data.render_color[3].hex; 127 | wx.navigateTo({ 128 | url: '/pages/plaza/fav?name=&color1=' + color1 + "&color2=" + color2 + "&color3=" + color3 + "&color4=" + color4 + "&color5=" + color5 129 | }); 130 | } 131 | }, 132 | 133 | // 点击随机按钮,随机颜色值 134 | random_value_change: function () { 135 | if (!this.data.buttonClicked) { 136 | preventDoubleClick(this); 137 | const r = Math.round(Math.random() * 255); 138 | const g = Math.round(Math.random() * 255); 139 | const b = Math.round(Math.random() * 255); 140 | this.valueChange(r, g, b); 141 | } 142 | }, 143 | 144 | copy: function (event) { 145 | const hex = event.currentTarget.dataset.color; 146 | wx.setClipboardData({ 147 | data: hex, 148 | success: function (res) { 149 | wx.showToast({ 150 | title: '复制HEX值成功', 151 | }); 152 | } 153 | }); 154 | }, 155 | 156 | copyAll: function () { 157 | let content = '基准色:' + this.data.hex + ', 配比色组:'; 158 | for (let i = 0; i < this.data.render_color.length; i++) { 159 | content += this.data.render_color[i].hex + ', ' 160 | }; 161 | wx.setClipboardData({ 162 | data: content.substring(0, content.lastIndexOf(',')), 163 | success: function (res) { 164 | wx.showToast({ 165 | title: '复制配色方案成功', 166 | }); 167 | } 168 | }); 169 | }, 170 | 171 | onShareAppMessage: function (res) { 172 | return onShare("二次色配比配色方案"); 173 | } 174 | }) -------------------------------------------------------------------------------- /pages/tools/shade/shade.js: -------------------------------------------------------------------------------- 1 | // 渐变色 2 | // pages/shade/shade.js 3 | const { 4 | check_rgb_value, 5 | rgb2hsb, 6 | hsb2rgb, 7 | rgb2hex 8 | } = require('../../../utils/colors.js'); 9 | 10 | const { preventDoubleClick, onShare } = require('../../../utils/functions.js'); 11 | 12 | Page({ 13 | // 页面的初始数据 14 | data: { 15 | red: 0, // 红值 16 | green: 0, // 绿值 17 | blue: 0, // 蓝值 18 | saturation_percent: 0, // 饱和度比例 19 | brightness_percent: 0, // 亮度比例 20 | percent: 0, // 比例 21 | kind: "lightness", // 勾选的单选框 22 | hex: "#000000", // 十六进制RGB值 23 | render_color: new Array(0), // 要渲染的4个单色 24 | }, 25 | 26 | // 页面加载时, 读取传入的颜色信息,如果没有则随机,然后缓存页面颜色值 27 | onLoad: function (options) { 28 | const red = options.red; 29 | const green = options.green; 30 | const blue = options.blue; 31 | const kind = options.kind; 32 | const percent = options.percent; 33 | 34 | if (!check_rgb_value(red) || 35 | !check_rgb_value(green) || 36 | !check_rgb_value(blue) || 37 | (kind != "lightness" && kind != "saturation") || 38 | percent < -25 || percent > 25 || isNaN(percent)) { 39 | this.random_value_change(); 40 | } 41 | else { 42 | this.valueChange(red, green, blue, percent, kind); 43 | } 44 | }, 45 | 46 | // 输入值发生变化 47 | valueChange: function (r, g, b, p, kind) { 48 | this.setData({ 49 | red: r, 50 | green: g, 51 | blue: b, 52 | percent: p, 53 | kind: kind, 54 | hex: rgb2hex(r, g, b), 55 | render_color: this.render(r, g, b, p, kind) 56 | }); 57 | }, 58 | 59 | // 改变RGB颜色 60 | rgbChange: function (event) { 61 | const value = event.detail.value; 62 | const id = event.currentTarget.id; 63 | switch (id) { 64 | case "red": 65 | this.valueChange(value, this.data.green, this.data.blue, this.data.percent, this.data.kind); 66 | break; 67 | case "green": 68 | this.valueChange(this.data.red, value, this.data.blue, this.data.percent, this.data.kind); 69 | break; 70 | case "blue": 71 | this.valueChange(this.data.red, this.data.green, value, this.data.percent, this.data.kind); 72 | break; 73 | } 74 | }, 75 | 76 | radioChange: function (event) { 77 | this.setData({ kind: event.detail.value }); 78 | this.valueChange(this.data.red, this.data.green, this.data.blue, this.data.percent, this.data.kind); 79 | }, 80 | 81 | percentChange: function (event) { 82 | this.setData({ percent: event.detail.value }); 83 | this.valueChange(this.data.red, this.data.green, this.data.blue, this.data.percent, this.data.kind); 84 | }, 85 | 86 | render: function (r, g, b, percent, kind) { 87 | const hsb = rgb2hsb(r, g, b); 88 | const hue = hsb[0]; 89 | const saturation = hsb[1]; 90 | const lightness = hsb[2]; 91 | let render_color = new Array; 92 | 93 | for (let i = 1; i <= 4; i++) { 94 | let l = lightness; 95 | let s = saturation; 96 | if (kind == "lightness") { 97 | l = lightness + percent * i; 98 | l = l > 100 ? 100 : l; 99 | l = l < 0 ? 0 : l; 100 | } 101 | else { 102 | s = saturation + percent * i; 103 | s = s > 100 ? 100 : s; 104 | s = s < 0 ? 0 : s; 105 | } 106 | const rgb = hsb2rgb(hue, s, l); 107 | const hex = rgb2hex(rgb[0], rgb[1], rgb[2]); 108 | render_color.push({ hex: hex, percent: percent * i + "%" }); 109 | } 110 | return render_color; 111 | }, 112 | 113 | // 点击收藏按钮 114 | fav: function (event) { 115 | if (!this.data.buttonClicked) { 116 | preventDoubleClick(this); 117 | const color1 = this.data.hex; 118 | const color2 = this.data.render_color[0].hex; 119 | const color3 = this.data.render_color[1].hex; 120 | const color4 = this.data.render_color[2].hex; 121 | const color5 = this.data.render_color[3].hex; 122 | wx.navigateTo({ 123 | url: '/pages/plaza/fav?name=&color1=' + color1 + "&color2=" + color2 + "&color3=" + color3 + "&color4=" + color4 + "&color5=" + color5 124 | }); 125 | } 126 | }, 127 | 128 | // 点击随机按钮,随机颜色值 129 | random_value_change: function () { 130 | if (!this.data.buttonClicked) { 131 | preventDoubleClick(this); 132 | const r = Math.round(Math.random() * 255); // 随机R值 133 | const g = Math.round(Math.random() * 255); // 随机R值 134 | const b = Math.round(Math.random() * 255); // 随机R值 135 | const p = Math.round(Math.random() * 50) - 25; // 随机比例 136 | this.valueChange(r, g, b, p, this.data.kind); // 初始化 137 | } 138 | }, 139 | 140 | copy: function (event) { 141 | const hex = event.currentTarget.dataset.color; 142 | wx.setClipboardData({ 143 | data: hex, 144 | success: function (res) { 145 | wx.showToast({ 146 | title: '复制HEX值成功', 147 | }); 148 | } 149 | }); 150 | }, 151 | 152 | copyAll: function () { 153 | let content = '基准色:' + this.data.hex + ', 渐变色:'; 154 | for (let i = 0; i < this.data.render_color.length; i++) { 155 | content += this.data.render_color[i].hex + ', ' 156 | }; 157 | wx.setClipboardData({ 158 | data: content.substring(0, content.lastIndexOf(',')), 159 | success: function (res) { 160 | wx.showToast({ 161 | title: '复制配色方案成功', 162 | }); 163 | } 164 | }); 165 | }, 166 | 167 | onShareAppMessage: function (res) { 168 | return onShare("渐变配色方案"); 169 | } 170 | }) -------------------------------------------------------------------------------- /utils/algorithm.js: -------------------------------------------------------------------------------- 1 | // 配色算法 2 | const colors = require("colors.js"); 3 | 4 | // 类比色算法 5 | function render_analogous(r, g, b, angle) { 6 | let render_color = new Array; 7 | const hsl = colors.rgb2hsb(r, g, b); 8 | const h = hsl[0]; 9 | const s = hsl[1]; 10 | const l = hsl[2]; 11 | for (let i = 1; i < 5; i++) { 12 | const a = angle * i; 13 | const new_h = (h + a) % 360; 14 | const rgb = colors.hsb2rgb(new_h, s, l); 15 | const hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 16 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: new_h, s: s, b: l }); 17 | } 18 | return render_color; 19 | } 20 | 21 | // 补色算法 22 | function render_complementary(r, g, b) { 23 | let render_color = new Array; 24 | const hsl = colors.rgb2hsb(r, g, b); 25 | const h = hsl[0]; 26 | const s = hsl[1]; 27 | const l = hsl[2]; 28 | 29 | // 变化基数 = 10 30 | const hue_base = s < 50 ? 10 : -10; 31 | 32 | // 辅色 H变化,S,B和主色一样 33 | let new_h = h + hue_base; 34 | let rgb = colors.hsb2rgb(new_h, s, l); 35 | let hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 36 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: new_h, s: s, b: l }); 37 | 38 | // 补色1 H + 180, S、B和主色一样 39 | new_h = (h + 180) % 360; 40 | rgb = colors.hsb2rgb(new_h, s, l); 41 | hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 42 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: new_h, s: s, b: l }); 43 | 44 | // 补色2 45 | new_h = (new_h + hue_base) % 360; 46 | rgb = colors.hsb2rgb(new_h, s, l); 47 | hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 48 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: new_h, s: s, b: l }); 49 | 50 | // 补色3 51 | new_h = (new_h + hue_base) % 360; 52 | rgb = colors.hsb2rgb(new_h, s, l); 53 | hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 54 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: new_h, s: s, b: l }); 55 | 56 | return render_color; 57 | } 58 | 59 | // 分裂补色算法 60 | function render_triad(r, g, b) { 61 | let render_color = new Array; 62 | const hsl = colors.rgb2hsb(r, g, b); 63 | const h = hsl[0]; 64 | const s = hsl[1]; 65 | const l = hsl[2]; 66 | 67 | const saturation = s > 50 ? s - 25 : s + 25; 68 | 69 | for (let i = 1; i <= 2; i++) { 70 | // 分裂补色组第1值 71 | const hue = (h + 120 * i) % 360; 72 | let rgb = colors.hsb2rgb(hue, s, l); 73 | let hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 74 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: hue, s: s, b: l }); 75 | 76 | // 分裂补色组第2值 77 | rgb = colors.hsb2rgb(hue, saturation, l); 78 | hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 79 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: hue, s: saturation, b: l }); 80 | } 81 | 82 | return render_color; 83 | } 84 | 85 | // 单色算法 86 | function render_monochromatic(r, g, b) { 87 | let render_color = new Array; 88 | const hsl = colors.rgb2hsb(r, g, b); 89 | const h = hsl[0]; 90 | const s = hsl[1]; 91 | const l = hsl[2]; 92 | // 变化基数 = 10 93 | const saturation_base = s < 50 ? 10 : -10; 94 | const brightness_base = l < 50 ? 10 : -10; 95 | 96 | for (let i = 1; i < 5; i++) { 97 | const new_s = s + saturation_base * i; 98 | const new_b = l + brightness_base * i; 99 | const rgb = colors.hsb2rgb(h, new_s, new_b); 100 | const hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 101 | render_color.push({ hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: h, s: new_s, b: new_b }); 102 | } 103 | return render_color; 104 | } 105 | 106 | // 渐变算法 107 | function render_shade(r, g, b, percent, kind) { 108 | const hsb = colors.rgb2hsb(r, g, b); 109 | const hue = hsb[0]; 110 | const saturation = hsb[1]; 111 | const lightness = hsb[2]; 112 | let render_color = new Array; 113 | 114 | for (let i = 1; i <= 4; i++) { 115 | let l = lightness; 116 | let s = saturation; 117 | if (kind == "lightness") { 118 | l = lightness + percent * i; 119 | l = l > 100 ? 100 : l; 120 | l = l < 0 ? 0 : l; 121 | } 122 | else { 123 | s = saturation + percent * i; 124 | s = s > 100 ? 100 : s; 125 | s = s < 0 ? 0 : s; 126 | } 127 | const rgb = colors.hsb2rgb(hue, s, l); 128 | const hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 129 | render_color.push({ hex: hex, percent: percent * i + "%" }); 130 | } 131 | return render_color; 132 | } 133 | 134 | // 二次色配比算法 135 | function render_secondary(r, g, b) { 136 | const hex = colors.rgb2hex(r, g, b); 137 | const hsb = colors.rgb2hsb(r, g, b); 138 | let render_color = new Array({ hex: hex, red: r, green: g, blue: b, h: hsb[0], s: hsb[1], b: hsb[2] }); 139 | 140 | const r1 = Math.round(Math.random() * 255); 141 | const g1 = Math.round(Math.random() * 255); 142 | const b1 = Math.round(Math.random() * 255); 143 | const r2 = Math.round(Math.random() * 255); 144 | const g2 = Math.round(Math.random() * 255); 145 | const b2 = Math.round(Math.random() * 255); 146 | 147 | const hex1 = colors.rgb2hex(r, g1, b1); 148 | const hex2 = colors.rgb2hex(r, g, b2); 149 | const hex3 = colors.rgb2hex(r1, g, b); 150 | const hex4 = colors.rgb2hex(r2, g2, b); 151 | 152 | const hsb1 = colors.rgb2hsb(r, g1, b1); 153 | const hsb2 = colors.rgb2hsb(r, g, b2); 154 | const hsb3 = colors.rgb2hsb(r1, g, b); 155 | const hsb4 = colors.rgb2hsb(r2, g2, b); 156 | 157 | render_color.push({ 158 | hex: hex1, 159 | red: r, green: g1, blue: b1, 160 | h: hsb1[0], s: hsb1[1], b: hsb1[2] 161 | }); 162 | 163 | render_color.push({ 164 | hex: hex2, 165 | red: r, green: g, blue: b2, 166 | h: hsb2[0], s: hsb2[1], b: hsb2[2] 167 | }); 168 | 169 | render_color.push({ 170 | hex: hex3, 171 | red: r1, green: g, blue: b, 172 | h: hsb3[0], s: hsb3[1], b: hsb3[2] 173 | }); 174 | 175 | render_color.push({ 176 | hex: hex4, 177 | red: r2, green: g2, blue: b, 178 | h: hsb4[0], s: hsb4[1], b: hsb4[2] 179 | }); 180 | 181 | return render_color; 182 | } 183 | 184 | module.exports = { 185 | render_analogous, // 类比色算法 186 | render_complementary, // 补色算法 187 | render_triad, // 分裂补色算法 188 | render_monochromatic, // 单色算法 189 | render_shade, // 渐变算法 190 | render_secondary // 二次色配比算法 191 | }; -------------------------------------------------------------------------------- /utils/colors.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 检查RGB某一分量值是否合法 3 | * @param int value 分量值 4 | */ 5 | function check_rgb_value(value) { 6 | if (value === undefined || value === null || value == "" || value < 0 || value > 255 || isNaN(value)) { 7 | return false; 8 | } 9 | return true; 10 | } 11 | 12 | /** 13 | * RGB值转十六进制表示 14 | */ 15 | function rgb2hex(red, green, blue) { 16 | let r = new Number(red).toString(16); 17 | let g = new Number(green).toString(16); 18 | let b = new Number(blue).toString(16); 19 | if (r.length == 1) { 20 | r = "0" + r; 21 | } 22 | 23 | if (g.length == 1) { 24 | g = "0" + g; 25 | } 26 | 27 | if (b.length == 1) { 28 | b = "0" + b; 29 | } 30 | 31 | return "#" + r + g + b; 32 | } 33 | 34 | /** 35 | * 十六进制表示转RGB值 36 | */ 37 | function hex2rgb(hex) { 38 | hex = hex.indexOf("#") == -1 ? hex : hex.substring(hex.indexOf("#") + 1) 39 | var r = hex.length == 6 ? hex.substring(0, 2) : hex.substring(0, 1); 40 | var g = hex.length == 6 ? hex.substring(2, 4) : hex.substring(1, 2); 41 | var b = hex.length == 6 ? hex.substring(4) : hex.substring(2); 42 | 43 | r = parseInt(r, 16); 44 | g = parseInt(g, 16); 45 | b = parseInt(b, 16); 46 | 47 | return new Array(r, g, b); 48 | } 49 | 50 | /** 51 | * RGB值转HSB值 52 | * 输入 53 | * r:0~255 54 | * g:0~255 55 | * b:0~255 56 | * 输出 57 | * h:0~359 58 | * s:0~100 59 | * b:0~100 60 | */ 61 | function rgb2hsb(r, g, b) { 62 | let rgb = new Array(r, g, b); 63 | rgb = rgb.sort(function (i, j) { return i - j; }); 64 | let max = rgb[2]; 65 | let min = rgb[0]; 66 | 67 | let hsb_b = max / 255.0; 68 | let hsb_s = max == 0 ? 0 : (max - min) / max 69 | let hsb_h = 0; 70 | if (max == min) { 71 | hsb_h = 0; 72 | } 73 | else if (max == r && g >= b) { 74 | hsb_h = 60 * (g - b) / (max - min); 75 | } 76 | else if (max == r && g < b) { 77 | hsb_h = 60 * (g - b) / (max - min) + 360; 78 | } 79 | else if (max == g) { 80 | hsb_h = 60 * (b - r) / (max - min) + 120; 81 | } 82 | else if (max == b) { 83 | hsb_h = 60 * (r - g) / (max - min) + 240; 84 | } 85 | return new Array(Math.round(hsb_h), Math.round(hsb_s * 100), Math.round(hsb_b * 100)); 86 | } 87 | 88 | 89 | /** 90 | * RGB值转CMYK值 91 | * 输入 92 | * r:0~255 93 | * g:0~255 94 | * b:0~255 95 | * 输出 96 | * c:0~100 97 | * m:0~100 98 | * y:0~100 99 | * k:0~100 100 | */ 101 | function rgb2cmyk(r, g, b) { 102 | let c = 1 - r / 255; 103 | let m = 1 - g / 255; 104 | let y = 1 - b / 255; 105 | let k = 1; 106 | k = c < k ? c : k; 107 | k = m < k ? m : k; 108 | k = y < k ? y : k; 109 | if (k == 1) { 110 | c = 0; 111 | m = 0; 112 | y = 0 113 | } 114 | else { 115 | c = (c - k) / (1 - k) 116 | m = (m - k) / (1 - k) 117 | y = (y - k) / (1 - k) 118 | } 119 | return new Array(Math.round(c * 100), Math.round(m * 100), Math.round(y * 100), Math.round(k * 100)); 120 | } 121 | 122 | /** 123 | * RGB值转LAB值 124 | * 输入 125 | * r:0~255 126 | * g:0~255 127 | * b:0~255 128 | * 输出 129 | * l:0~100 130 | * a:-128~127 131 | * b:-128~127 132 | */ 133 | function rgb2lab(r, g, b) { 134 | r /= 255 135 | g /= 255 136 | b /= 255 137 | 138 | r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92; 139 | g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92; 140 | b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92; 141 | 142 | r *= 100 143 | g *= 100 144 | b *= 100 145 | 146 | let x = r * 0.4124 + g * 0.3576 + b * 0.1805 147 | let y = r * 0.2126 + g * 0.7152 + b * 0.0722 148 | let z = r * 0.0193 + g * 0.1192 + b * 0.9505 149 | 150 | x /= 95.047 151 | y /= 100.0 152 | z /= 108.883 153 | 154 | x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116; 155 | y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116; 156 | z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116; 157 | 158 | let l1 = 116 * y - 16; 159 | let a1 = 500 * (x - y); 160 | let b1 = 200 * (y - z); 161 | 162 | return new Array(Math.round(l1), Math.round(a1), Math.round(b1)); 163 | } 164 | 165 | /** 166 | * CMYK值转RGB值 167 | * 输入 168 | * c:0~100 169 | * m:0~100 170 | * y:0~100 171 | * k:0~100 172 | * 输出 173 | * r:0~255 174 | * g:0~255 175 | * b:0~255 176 | */ 177 | function cmyk2rgb(c, m, y, k) { 178 | const oc = c, om = m, oy = y, ok = k; 179 | c /= 100; 180 | m /= 100; 181 | y /= 100; 182 | k /= 100; 183 | c = c * (1 - k) + k; 184 | m = m * (1 - k) + k; 185 | y = y * (1 - k) + k; 186 | const r = (1 - c) * 255; 187 | const g = (1 - m) * 255; 188 | const b = (1 - y) * 255; 189 | return new Array(Math.round(r), Math.round(g), Math.round(b)); 190 | } 191 | 192 | /** 193 | * LAB值转RGB值 194 | * 输入 195 | * l:0~100 196 | * a:-128~127 197 | * b:-128~127 198 | * 输出 199 | * r:0~255 200 | * g:0~255 201 | * b:0~255 202 | */ 203 | function lab2rgb(l, a, b) { 204 | let y = (l + 16) / 116; 205 | let x = a / 500 + y; 206 | let z = y - b / 200; 207 | 208 | x = Math.pow(x, 3) > 0.008856 ? Math.pow(x, 3) : (x - 16 / 116) / 7.787; 209 | y = Math.pow(y, 3) > 0.008856 ? Math.pow(y, 3) : (y - 16 / 116) / 7.787; 210 | z = Math.pow(z, 3) > 0.008856 ? Math.pow(z, 3) : (z - 16 / 116) / 7.787; 211 | 212 | x *= 95.047; 213 | y *= 100.0; 214 | z *= 108.883; 215 | 216 | x /= 100.0; 217 | y /= 100.0; 218 | z /= 100.0; 219 | 220 | let red = x * 3.2406 + y * -1.5372 + z * -0.4986; 221 | let green = x * -0.9689 + y * 1.8758 + z * 0.0415; 222 | let blue = x * 0.0557 + y * -0.2040 + z * 1.0570; 223 | 224 | red = red > 0.0031308 ? 1.055 * Math.pow(red, 1 / 2.4) - 0.055 : red * 12.92; 225 | green = green > 0.0031308 ? 1.055 * Math.pow(green, 1 / 2.4) - 0.055 : green * 12.92; 226 | blue = blue > 0.0031308 ? 1.055 * Math.pow(blue, 1 / 2.4) - 0.055 : blue * 12.92; 227 | 228 | red *= 255; 229 | green *= 255; 230 | blue *= 255; 231 | 232 | red = red < 0 ? 0 : red > 255 ? 255 : red; 233 | green = green < 0 ? 0 : green > 255 ? 255 : green; 234 | blue = blue < 0 ? 0 : blue > 255 ? 255 : blue; 235 | return new Array(Math.round(red), Math.round(green), Math.round(blue)); 236 | } 237 | 238 | /** 239 | * HSB值转RGB值 240 | * 输入 241 | * h:0~359 242 | * s:0~100 243 | * b:0~100 244 | * 输出 245 | * r:0~255 246 | * g:0~255 247 | * b:0~255 248 | */ 249 | function hsb2rgb(h, s, b) { 250 | h = h % 360; 251 | s = s / 100.0; 252 | b = b / 100.0; 253 | let hi = parseInt((h / 60) % 6); 254 | let f = h / 60 - hi; 255 | let p = b * (1 - s); 256 | let q = b * (1 - f * s); 257 | let t = b * (1 - (1 - f) * s); 258 | let red = 0, green = 0, blue = 0; 259 | 260 | switch (hi) { 261 | case 0: 262 | red = b, green = t, blue = p; 263 | break; 264 | case 1: 265 | red = q, green = b, blue = p; 266 | break; 267 | case 2: 268 | red = p, green = b, blue = t; 269 | break; 270 | case 3: 271 | red = p, green = q, blue = b; 272 | break; 273 | case 4: 274 | red = t, green = p, blue = b; 275 | break; 276 | case 5: 277 | red = b, green = p, blue = q; 278 | break; 279 | } 280 | 281 | red *= 255; 282 | green *= 255; 283 | blue *= 255; 284 | return new Array(parseInt(red.toFixed(0)), parseInt(green.toFixed(0)), parseInt(blue.toFixed(0))); 285 | } 286 | 287 | module.exports = { 288 | check_rgb_value, // 检查RGB某一分量值是否合法 289 | rgb2hex, // RGB值转十六进制表示 290 | hex2rgb, // 十六进制表示转RGB值 291 | rgb2hsb, // RGB值转HSB值 292 | rgb2cmyk, // RGB值转CMYK值 293 | rgb2lab, // RGB值转LAB值 294 | cmyk2rgb, // CMYK值转RGB值 295 | lab2rgb, // LAB值转RGB值 296 | hsb2rgb, // HSB值转RGB值 297 | } -------------------------------------------------------------------------------- /pages/tools/lucky/lucky.js: -------------------------------------------------------------------------------- 1 | // pages/tools/lucky/lucky.js 2 | const colors = require('../../../utils/colors.js'); 3 | const algorithm = require('../../../utils/algorithm.js'); 4 | const { preventDoubleClick, onShare } = require('../../../utils/functions.js'); 5 | 6 | 7 | Page({ 8 | // 页面的初始数据(8个动态数据) 9 | data: { 10 | red: 0, // 颜色版-红色分量 11 | green: 0, // 颜色版-绿色分量 12 | blue: 0, // 颜色版-蓝色分量 13 | saturation: 0, // 颜色版-饱和度 14 | brightness: 0, // 颜色版-亮度 15 | index: 0, // 颜色1 16 | algorithm_index: 0, // 算法索引 17 | render_color: new Array(), // 颜色数组 18 | array: ["颜色1", "颜色2", "颜色3", "颜色4", "颜色5"], 19 | algorithm: ["analogous", "complementary", "triad", "monochromatic", "shade", "secondary"] // 颜色算法 20 | }, 21 | 22 | // 生命周期函数--监听页面加载,外来配置参数为5个color{n}=#hex 23 | onLoad: function (options) { 24 | const color1 = options.color1; 25 | const color2 = options.color2; 26 | const color3 = options.color3; 27 | const color4 = options.color4; 28 | const color5 = options.color5; 29 | if (color1 == undefined || 30 | color2 == undefined || 31 | color3 == undefined || 32 | color4 == undefined || 33 | color5 == undefined) { 34 | this.random_value(); 35 | } 36 | else { 37 | const rgb = colors.hex2rgb(color1); 38 | const hsb = colors.rgb2hsb(rgb[0], rgb[1], rgb[2]); 39 | const render_color = [color1, color2, color3, color4, color5]; 40 | this.setData({ 41 | red: rgb[0], 42 | green: rgb[1], 43 | blue: rgb[2], 44 | saturation: hsb[1], 45 | brightness: hsb[2], 46 | index: 0, 47 | algorithm_index: 0, 48 | render_color: render_color 49 | }); 50 | } 51 | }, 52 | 53 | // 随机算法 54 | random_value: function () { 55 | if (!this.data.buttonClicked) { 56 | preventDoubleClick(this); 57 | const length = this.data.algorithm.length - 1; 58 | const algorithm_index = Math.round(Math.random() * length); 59 | this.setData({ index: 0 }); 60 | this.render(algorithm_index); 61 | } 62 | }, 63 | 64 | // 生成颜色数组 65 | render: function (algorithm_index) { 66 | const r = Math.round(Math.random() * 255); 67 | const g = Math.round(Math.random() * 255); 68 | const b = Math.round(Math.random() * 255); 69 | let a = 20; 70 | let color = ''; 71 | switch (this.data.algorithm[algorithm_index]) { 72 | case "analogous": 73 | a = Math.round(Math.random() * 100) % 52 + 20; 74 | color = algorithm.render_analogous(r, g, b, a); 75 | break; 76 | case "complementary": 77 | color = algorithm.render_complementary(r, g, b); 78 | break; 79 | case "triad": 80 | color = algorithm.render_triad(r, g, b); 81 | break; 82 | case "monochromatic": 83 | color = algorithm.render_monochromatic(r, g, b); 84 | break; 85 | case "shade": 86 | let p = Math.round(Math.random() * 50) - 25; // 随机比例 87 | let k = Math.round(Math.random() * 1) == 1 ? "lightness" : "saturation"; 88 | color = algorithm.render_shade(r, g, b, p, k); 89 | break; 90 | case "secondary": 91 | color = algorithm.render_complementary(r, g, b); 92 | break; 93 | default: 94 | a = Math.round(Math.random() * 100) % 52 + 20; 95 | color = algorithm.render_analogous(r, g, b, a); 96 | break; 97 | } 98 | const hex = colors.rgb2hex(r, g, b); 99 | const hsb = colors.rgb2hsb(r, g, b); 100 | let render_color = [{ hex: hex, red: r, green: g, blue: b, h: hsb[0], s: hsb[1], b: hsb[2] }]; 101 | render_color = render_color.concat(color); 102 | 103 | this.setData({ 104 | red: r, 105 | green: g, 106 | blue: b, 107 | saturation: hsb[1], 108 | brightness: hsb[2], 109 | algorithm_index: algorithm, 110 | render_color: render_color 111 | }); 112 | this.render_color_board(); 113 | }, 114 | 115 | // 渲染颜色版分量 116 | render_color_board: function () { 117 | const index = this.data.index; 118 | const color = this.data.render_color[index]; 119 | this.setData({ 120 | red: color.red, 121 | green: color.green, 122 | blue: color.blue, 123 | saturation: color.s, 124 | brightness: color.b 125 | }); 126 | }, 127 | 128 | // 点击下拉菜单 129 | pickerChange: function (event) { 130 | this.setData({ index: event.detail.value }); 131 | this.render_color_board(); 132 | }, 133 | 134 | // 点击收藏按钮 135 | fav: function (event) { 136 | if (!this.data.buttonClicked) { 137 | preventDoubleClick(this); 138 | const color1 = this.data.render_color[0].hex; 139 | const color2 = this.data.render_color[1].hex; 140 | const color3 = this.data.render_color[2].hex; 141 | const color4 = this.data.render_color[3].hex; 142 | const color5 = this.data.render_color[4].hex; 143 | wx.navigateTo({ 144 | url: '/pages/plaza/fav?name=&color1=' + color1 + "&color2=" + color2 + "&color3=" + color3 + "&color4=" + color4 + "&color5=" + color5 145 | }); 146 | } 147 | }, 148 | 149 | // 拖动rgb滑块 150 | rgbChange: function (event) { 151 | const render_color = this.data.render_color; 152 | const color_index = this.data.index; 153 | let color = render_color[color_index]; 154 | let r = color.red; 155 | let g = color.green; 156 | let b = color.blue; 157 | 158 | const value = event.detail.value; 159 | const id = event.currentTarget.id; 160 | switch (id) { 161 | case "red": 162 | r = value; 163 | break; 164 | case "green": 165 | g = value; 166 | break; 167 | case "blue": 168 | b = value; 169 | break; 170 | } 171 | const hex = colors.rgb2hex(r, g, b); 172 | const hsb = colors.rgb2hsb(r, g, b); 173 | color = { hex: hex, red: r, green: g, blue: b, h: hsb[0], s: hsb[1], b: hsb[2] }; 174 | render_color[color_index] = color; 175 | this.setData({ 176 | red: r, 177 | green: g, 178 | blue: b, 179 | saturation: hsb[1], 180 | brightness: hsb[2], 181 | index: color_index, 182 | render_color: render_color 183 | }); 184 | }, 185 | 186 | // 改变饱和度 187 | saturationChange: function (event) { 188 | const render_color = this.data.render_color; 189 | const color_index = this.data.index; 190 | let color = render_color[color_index]; 191 | const h = color.h; 192 | const s = event.detail.value; 193 | const b = color.b; 194 | 195 | const rgb = colors.hsb2rgb(h, s, b); 196 | const hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 197 | color = { hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: h, s: s, b: b }; 198 | render_color[color_index] = color; 199 | this.setData({ render_color: render_color }); 200 | }, 201 | 202 | // 改变亮度 203 | brightnessChange: function (event) { 204 | const render_color = this.data.render_color; 205 | const color_index = this.data.index; 206 | let color = render_color[color_index]; 207 | const h = color.h; 208 | const s = color.s; 209 | const b = event.detail.value; 210 | 211 | const rgb = colors.hsb2rgb(h, s, b); 212 | const hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 213 | color = { hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: h, s: s, b: b }; 214 | render_color[color_index] = color; 215 | this.setData({ render_color: render_color }); 216 | }, 217 | 218 | detail: function (e) { 219 | if (!this.data.buttonClicked) { 220 | preventDoubleClick(this); 221 | const color = e.currentTarget.dataset.color; 222 | wx.navigateTo({ 223 | url: '/pages/web/colordetail?color=' + color 224 | }); 225 | } 226 | }, 227 | 228 | copyAll: function () { 229 | let content = '配色方案:'; 230 | for (let i = 0; i < this.data.render_color.length; i++) { 231 | content += this.data.render_color[i].hex + ', ' 232 | }; 233 | wx.setClipboardData({ 234 | data: content.substring(0, content.lastIndexOf(',')), 235 | success: function (res) { 236 | wx.showToast({ 237 | title: '复制配色方案成功', 238 | }); 239 | } 240 | }); 241 | }, 242 | 243 | onShareAppMessage: function (res) { 244 | return onShare("Color颜值,优秀的配色助手"); 245 | } 246 | }) -------------------------------------------------------------------------------- /pages/plaza/edit.js: -------------------------------------------------------------------------------- 1 | // pages/plaza/edit.js 2 | 3 | const colors = require('../../utils/colors.js'); 4 | const { UPDATE_USER_COLORS } = require('../../utils/constant.js'); 5 | const { httpGet } = require('../../utils/functions.js'); 6 | 7 | Page({ 8 | 9 | /** 10 | * 页面的初始数据 11 | */ 12 | data: { 13 | id: -1, 14 | name: '', 15 | red: 0, // 颜色版-红色分量 16 | green: 0, // 颜色版-绿色分量 17 | blue: 0, // 颜色版-蓝色分量 18 | saturation: 0, // 颜色版-饱和度 19 | brightness: 0, // 颜色版-亮度 20 | index: 0, // 颜色1 21 | render_color: new Array(), // 颜色数组 22 | array: ["颜色1", "颜色2", "颜色3", "颜色4", "颜色5"], 23 | }, 24 | 25 | /** 26 | * 生命周期函数--监听页面加载 27 | */ 28 | onLoad: function (options) { 29 | const id = options.id; 30 | const name = options.name; 31 | const color1 = options.color1; 32 | const color2 = options.color2; 33 | const color3 = options.color3; 34 | const color4 = options.color4; 35 | const color5 = options.color5; 36 | if (color1 == undefined || 37 | color2 == undefined || 38 | color3 == undefined || 39 | color4 == undefined || 40 | color5 == undefined || id == undefined || name == undefined) { 41 | wx.navigateBack({ 42 | delta: 1 43 | }); 44 | } else { 45 | let colors_array = new Array; 46 | const rgb1 = colors.hex2rgb(color1); 47 | const hsb1 = colors.rgb2hsb(rgb1[0], rgb1[1], rgb1[2]); 48 | colors_array.push({ 49 | hex: color1, 50 | red: rgb1[0], 51 | green: rgb1[1], 52 | blue: rgb1[2], 53 | h: hsb1[0], 54 | s: hsb1[1], 55 | b: hsb1[2] 56 | }); 57 | 58 | const rgb2 = colors.hex2rgb(color2); 59 | const hsb2 = colors.rgb2hsb(rgb2[0], rgb2[1], rgb2[2]); 60 | colors_array.push({ 61 | hex: color2, 62 | red: rgb2[0], 63 | green: rgb2[1], 64 | blue: rgb2[2], 65 | h: hsb2[0], 66 | s: hsb2[1], 67 | b: hsb2[2] 68 | }); 69 | 70 | const rgb3 = colors.hex2rgb(color3); 71 | const hsb3 = colors.rgb2hsb(rgb3[0], rgb3[1], rgb3[2]); 72 | colors_array.push({ 73 | hex: color3, 74 | red: rgb3[0], 75 | green: rgb3[1], 76 | blue: rgb3[2], 77 | h: hsb3[0], 78 | s: hsb3[1], 79 | b: hsb3[2] 80 | }); 81 | 82 | const rgb4 = colors.hex2rgb(color4); 83 | const hsb4 = colors.rgb2hsb(rgb4[0], rgb4[1], rgb4[2]); 84 | colors_array.push({ 85 | hex: color4, 86 | red: rgb4[0], 87 | green: rgb4[1], 88 | blue: rgb4[2], 89 | h: hsb4[0], 90 | s: hsb4[1], 91 | b: hsb4[2] 92 | }); 93 | 94 | const rgb5 = colors.hex2rgb(color5); 95 | const hsb5 = colors.rgb2hsb(rgb5[0], rgb5[1], rgb5[2]); 96 | colors_array.push({ 97 | hex: color5, 98 | red: rgb5[0], 99 | green: rgb5[1], 100 | blue: rgb5[2], 101 | h: hsb5[0], 102 | s: hsb5[1], 103 | b: hsb5[2] 104 | }); 105 | 106 | const rgb = colors.hex2rgb(color1); 107 | const hsb = colors.rgb2hsb(rgb[0], rgb[1], rgb[2]); 108 | this.setData({ 109 | id: id, 110 | name: name, 111 | render_color: colors_array, 112 | red: rgb[0], 113 | green: rgb[1], 114 | blue: rgb[2], 115 | saturation: hsb[1], 116 | brightness: hsb[2] 117 | }); 118 | } 119 | }, 120 | 121 | // 渲染颜色版分量 122 | render_color_board: function () { 123 | const index = this.data.index; 124 | const color = this.data.render_color[index]; 125 | this.setData({ 126 | red: color.red, 127 | green: color.green, 128 | blue: color.blue, 129 | saturation: color.s, 130 | brightness: color.b 131 | }); 132 | }, 133 | 134 | // 点击下拉菜单 135 | pickerChange: function (event) { 136 | this.setData({ index: event.detail.value }); 137 | this.render_color_board(); 138 | }, 139 | 140 | // 拖动rgb滑块 141 | rgbChange: function (event) { 142 | const render_color = this.data.render_color; 143 | const color_index = this.data.index; 144 | let color = render_color[color_index]; 145 | let r = color.red; 146 | let g = color.green; 147 | let b = color.blue; 148 | 149 | const value = event.detail.value; 150 | const id = event.currentTarget.id; 151 | switch (id) { 152 | case "red": 153 | r = value; 154 | break; 155 | case "green": 156 | g = value; 157 | break; 158 | case "blue": 159 | b = value; 160 | break; 161 | } 162 | const hex = colors.rgb2hex(r, g, b); 163 | const hsb = colors.rgb2hsb(r, g, b); 164 | color = { hex: hex, red: r, green: g, blue: b, h: hsb[0], s: hsb[1], b: hsb[2] }; 165 | render_color[color_index] = color; 166 | this.setData({ 167 | red: r, 168 | green: g, 169 | blue: b, 170 | saturation: hsb[1], 171 | brightness: hsb[2], 172 | index: color_index, 173 | render_color: render_color 174 | }); 175 | }, 176 | 177 | // 改变饱和度 178 | saturationChange: function (event) { 179 | const render_color = this.data.render_color; 180 | const color_index = this.data.index; 181 | let color = render_color[color_index]; 182 | const h = color.h; 183 | const s = event.detail.value; 184 | const b = color.b; 185 | 186 | const rgb = colors.hsb2rgb(h, s, b); 187 | const hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 188 | color = { hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: h, s: s, b: b }; 189 | render_color[color_index] = color; 190 | this.setData({ render_color: render_color }); 191 | }, 192 | 193 | // 改变亮度 194 | brightnessChange: function (event) { 195 | const render_color = this.data.render_color; 196 | const color_index = this.data.index; 197 | let color = render_color[color_index]; 198 | const h = color.h; 199 | const s = color.s; 200 | const b = event.detail.value; 201 | 202 | const rgb = colors.hsb2rgb(h, s, b); 203 | const hex = colors.rgb2hex(rgb[0], rgb[1], rgb[2]); 204 | color = { hex: hex, red: rgb[0], green: rgb[1], blue: rgb[2], h: h, s: s, b: b }; 205 | render_color[color_index] = color; 206 | this.setData({ render_color: render_color }); 207 | }, 208 | 209 | input: function (event) { 210 | const value = event.detail.value; 211 | if (value.length <= 20) { 212 | this.setData({ 213 | name: value 214 | }); 215 | } 216 | }, 217 | 218 | save: function () { 219 | if (this.data.name.length == 0) { 220 | wx.showToast({ 221 | title: '请输入配色名称', 222 | icon: 'none' 223 | }); 224 | } else { 225 | let data = { 226 | id: this.data.id, 227 | cust_id: wx.getStorageSync('cust_id'), 228 | openid: wx.getStorageSync('openid'), 229 | color1: this.data.render_color[0].hex, 230 | color2: this.data.render_color[1].hex, 231 | color3: this.data.render_color[2].hex, 232 | color4: this.data.render_color[3].hex, 233 | color5: this.data.render_color[4].hex, 234 | name: this.data.name 235 | }; 236 | httpGet(UPDATE_USER_COLORS, data).then(data => { 237 | if (data.code == 0) { 238 | wx.showToast({ 239 | title: '更新配色成功', 240 | icon: 'success', 241 | success: function () { 242 | setTimeout(function () { 243 | wx.navigateBack({ 244 | delta: 2 245 | }); 246 | }, 1500); 247 | } 248 | }); 249 | } else { 250 | wx.showToast({ 251 | title: data.msg, 252 | }); 253 | } 254 | }); 255 | } 256 | }, 257 | 258 | copy: function (event) { 259 | const index = event.currentTarget.dataset.index; 260 | wx.setClipboardData({ 261 | data: this.data.render_color[index].hex, 262 | success: function (res) { 263 | wx.showToast({ 264 | title: '复制HEX值成功', 265 | }); 266 | } 267 | }); 268 | }, 269 | }) -------------------------------------------------------------------------------- /pages/web/csscolor/csscolor.js: -------------------------------------------------------------------------------- 1 | // CSS颜色值 2 | const { preventDoubleClick, onShare } = require('../../../utils/functions.js'); 3 | 4 | Page({ 5 | /** 6 | * 页面的初始数据 7 | */ 8 | data: { 9 | standard: [ 10 | { name: "aqua", hex: "#00FFFF" }, 11 | { name: "black", hex: "#000000" }, 12 | { name: "blue", hex: "#0000FF" }, 13 | { name: "fuchsia", hex: "#FF00FF" }, 14 | { name: "gray", hex: "#808080" }, 15 | { name: "green", hex: "#008000" }, 16 | { name: "lime", hex: "#00FF00" }, 17 | { name: "maroon", hex: "#800000" }, 18 | { name: "navy", hex: "#000080" }, 19 | { name: "olive", hex: "#808000" }, 20 | { name: "orange", hex: "#FFA500" }, 21 | { name: "purple", hex: "#800080" }, 22 | { name: "red", hex: "#FF0000" }, 23 | { name: "silver", hex: "#C0C0C0" }, 24 | { name: "teal", hex: "#008080" }, 25 | { name: "white", hex: "#FFFFFF" }, 26 | { name: "yellow", hex: "#FFFF00" }], 27 | 28 | color: [ 29 | { name: "maroon", hex: "#800000" }, 30 | { name: "brown", hex: "#A52A2A" }, 31 | { name: "crimson", hex: "#DC143C" }, 32 | { name: "darkred", hex: "#8B0000" }, 33 | { name: "firebrick", hex: "#B22222" }, 34 | { name: "red", hex: "#FF0000" }, 35 | { name: "mediumvioletred", hex: "#C71585" }, 36 | { name: "deeppink", hex: "#FF1493" }, 37 | { name: "hotpink", hex: "#FF69B4" }, 38 | { name: "lightpink", hex: "#FFB6C1" }, 39 | { name: "lavenderblush", hex: "#FFF0F5" }, 40 | { name: "palevioletred", hex: "#D87093" }, 41 | { name: "fuchsia(magenta)", hex: "#FF00FF" }, 42 | { name: "pink", hex: "#FFC0CB" }, 43 | { name: "mistyrose", hex: "#FFE4E1" }, 44 | { name: "indigo", hex: "#4B0082" }, 45 | { name: "darkmagenta", hex: "#8B008B" }, 46 | { name: "blueviolet", hex: "#8A2BE2" }, 47 | { name: "slateblue", hex: "#6A5ACD" }, 48 | { name: "mediumslateblue", hex: "#7B68EE" }, 49 | { name: "violet", hex: "#EE82EE" }, 50 | { name: "thistle", hex: "#D8BFD8" }, 51 | { name: "purple", hex: "#800080" }, 52 | { name: "darkorchid", hex: "#9932CC" }, 53 | { name: "darkviolet", hex: "#9400D3" }, 54 | { name: "mediumpurple", hex: "#9370DB" }, 55 | { name: "mediumorchid", hex: "#BA55D3" }, 56 | { name: "plum", hex: "#DDA0DD" }, 57 | { name: "lavender", hex: "#E6E6FA" }, 58 | { name: "saddlebrown", hex: "#8B4513" }, 59 | { name: "chocolate", hex: "#D2691E" }, 60 | { name: "rosybrown", hex: "#BC8F8F" }, 61 | { name: "salmon", hex: "#FA8072" }, 62 | { name: "orangered", hex: "#FF4500" }, 63 | { name: "coral", hex: "#FF7F50" }, 64 | { name: "sandybrown", hex: "#F4A460" }, 65 | { name: "tan", hex: "#D2B48C" }, 66 | { name: "wheat", hex: "#F5DEB3" }, 67 | { name: "navajowhite", hex: "#FFDEAD" }, 68 | { name: "bisque", hex: "#FFE4C4" }, 69 | { name: "papayawhip", hex: "#FFEFD5" }, 70 | { name: "oldlace", hex: "#FDF5E6" }, 71 | { name: "seashell", hex: "#FFF5EE" }, 72 | { name: "floralwhite", hex: "#FFFAF0" }, 73 | { name: "sienna", hex: "#A0522D" }, 74 | { name: "indianred", hex: "#CD5C5C" }, 75 | { name: "lightcoral", hex: "#F08080" }, 76 | { name: "lightsalmon", hex: "#FFA07A" }, 77 | { name: "tomato", hex: "#FF6347" }, 78 | { name: "darkorange", hex: "#FF8C00" }, 79 | { name: "peru", hex: "#CD853F" }, 80 | { name: "burlywood", hex: "#DEB887" }, 81 | { name: "moccasin", hex: "#FFE4B5" }, 82 | { name: "peachpuff", hex: "#FFDAB9" }, 83 | { name: "antiquewhite", hex: "#FAEBD7" }, 84 | { name: "cornsilk", hex: "#FFF8DC" }, 85 | { name: "linen", hex: "#FAF0E6" }, 86 | { name: "snow", hex: "#FFFAFA" }, 87 | { name: "ivory", hex: "#FFFFF0" }, 88 | { name: "darkgoldenrod", hex: "#B8860B" }, 89 | { name: "gold", hex: "#FFD700" }, 90 | { name: "darkkhaki", hex: "#BDB76B" }, 91 | { name: "palegoldenrod", hex: "#EEE8AA" }, 92 | { name: "lemonchiffon", hex: "#FFFACD" }, 93 | { name: "lightyellow", hex: "#FFFFE0" }, 94 | { name: "goldenrod", hex: "#DAA520" }, 95 | { name: "yellow", hex: "#FFFF00" }, 96 | { name: "khaki", hex: "#F0E68C" }, 97 | { name: "beige", hex: "#F5F5DC" }, 98 | { name: "lightgoldenrodyellow", hex: "#FAFAD2" }, 99 | { name: "darkslategray", hex: "#2F4F4F" }, 100 | { name: "olive", hex: "#808000" }, 101 | { name: "forestgreen", hex: "#228B22" }, 102 | { name: "green(teal)", hex: "#008080" }, 103 | { name: "yellowgreen", hex: "#9ACD32" }, 104 | { name: "lime", hex: "#00FF00" }, 105 | { name: "lawngreen", hex: "#7CFC00" }, 106 | { name: "mediumspringgreen", hex: "#00FA9A" }, 107 | { name: "lightgreen", hex: "#90EE90" }, 108 | { name: "aquamarine", hex: "#7FFFD4" }, 109 | { name: "mintcream", hex: "#F5FFFA" }, 110 | { name: "darkolivegreen", hex: "#556B2F" }, 111 | { name: "darkgreen", hex: "#006400" }, 112 | { name: "seagreen", hex: "#2E8B57" }, 113 | { name: "madiumaquamarine", hex: "#66CDAA" }, 114 | { name: "limegreen", hex: "#32CD32" }, 115 | { name: "chartreuse", hex: "#7FFF00" }, 116 | { name: "greenyellow", hex: "#ADFF2F" }, 117 | { name: "springgreen", hex: "#00FF7F" }, 118 | { name: "palegreen", hex: "#98F898" }, 119 | { name: "honeydew", hex: "#F0FFF0" }, 120 | { name: "midnightblue", hex: "#191970" }, 121 | { name: "darkblue", hex: "#00008B" }, 122 | { name: "mediumblue", hex: "#0000CD" }, 123 | { name: "dodgerblue", hex: "#1E90FF" }, 124 | { name: "deepskyblue", hex: "#00BFFF" }, 125 | { name: "lightsteelblue", hex: "#B0C4DE" }, 126 | { name: "steelblue", hex: "#4682B4" }, 127 | { name: "cadetblue", hex: "#5F9EA0" }, 128 | { name: "mediumturquoise", hex: "#48D1CC" }, 129 | { name: "skyblue", hex: "#87CECB" }, 130 | { name: "paleturquoise", hex: "#AFEEEE" }, 131 | { name: "azure", hex: "#F0FFFF" }, 132 | { name: "aqua(cyan)", hex: "#00FFFF" }, 133 | { name: "navy", hex: "#000080" }, 134 | { name: "darkslateblue", hex: "#483D8B" }, 135 | { name: "royalblue", hex: "#4169E1" }, 136 | { name: "cornflowerblue", hex: "#6495ED" }, 137 | { name: "lightskyblue", hex: "#87CEFA" }, 138 | { name: "lightblue", hex: "#ADD8E6" }, 139 | { name: "darkcyan", hex: "#008B8B" }, 140 | { name: "darkturquoise", hex: "#00CED1" }, 141 | { name: "turquoise", hex: "#40E0D0" }, 142 | { name: "powderblue", hex: "#B0E0E6" }, 143 | { name: "lightcyan", hex: "#E0FFFF" }, 144 | { name: "aliceblue", hex: "#F0F8FF" }, 145 | { name: "black", hex: "#000000" }, 146 | { name: "gray", hex: "#808000" }, 147 | { name: "lightslategray", hex: "#778899" }, 148 | { name: "silver", hex: "#C0C0C0" }, 149 | { name: "gainsboro", hex: "#DCDCDC" }, 150 | { name: "ghostwhite", hex: "#F8F8FF" }, 151 | { name: "blanchedalmond", hex: "#FFEBCD" }, 152 | { name: "cyan", hex: "#00FFFF" }, 153 | { name: "darkgray", hex: "#A9A9A9" }, 154 | { name: "darksalmon", hex: "#E9967A" }, 155 | { name: "darkseagreen", hex: "#8FBC8F" }, 156 | { name: "dimgray", hex: "#696969" }, 157 | { name: "feldspar", hex: "#D19275" }, 158 | { name: "lightgrey", hex: "#D3D3D3" }, 159 | { name: "lightseagreen", hex: "#20B2AA" }, 160 | { name: "lightslateblue", hex: "#8470FF" }, 161 | { name: "magenta", hex: "#FF00FF" }, 162 | { name: "mediumaquamarine", hex: "#66CDAA" }, 163 | { name: "mediumseagreen", hex: "#3CB371" }, 164 | { name: "olivedrab", hex: "#6B8E23" }, 165 | { name: "orchid", hex: "#DA70D6" }, 166 | { name: "slategray", hex: "#708090" }, 167 | { name: "violetred", hex: "#D02090" }, 168 | { name: "whitesmoke", hex: "#F5F5F5" }] 169 | }, 170 | 171 | jump: function (event) { 172 | if (!this.data.buttonClicked) { 173 | preventDoubleClick(this); 174 | const name = event.currentTarget.dataset.name; 175 | const hex = event.currentTarget.dataset.hex; 176 | wx.navigateTo({ 177 | url: '../colordetail?color=' + hex + '&name=' + name 178 | }); 179 | } 180 | }, 181 | 182 | copy: function (event) { 183 | const index = event.currentTarget.dataset.index; 184 | const source = event.currentTarget.dataset.source; 185 | if (source == 'standard') { 186 | wx.setClipboardData({ 187 | data: this.data.standard[index].name + ", HEX: " + this.data.standard[index].hex, 188 | success: function (res) { 189 | wx.showToast({ 190 | title: '复制HEX值成功', 191 | }); 192 | } 193 | }); 194 | } else { 195 | wx.setClipboardData({ 196 | data: this.data.color[index].name + ", HEX: " + this.data.color[index].hex, 197 | success: function (res) { 198 | wx.showToast({ 199 | title: '复制HEX值成功', 200 | }); 201 | } 202 | }); 203 | } 204 | }, 205 | 206 | onShareAppMessage: function (res) { 207 | return onShare("CSS颜色参考"); 208 | } 209 | }) -------------------------------------------------------------------------------- /pages/transition/transition.wxml: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

模式选择

5 | 6 |

7 | {{mode[index]}} 8 | 9 |

10 |
11 |
12 | 13 |
14 |

R:

15 | 16 | 17 |
18 |
19 |

G:

20 | 21 | 22 |
23 |
24 |

B:

25 | 26 | 27 |
28 |
29 | 30 |
31 |

C:

32 | 33 | % 34 |
35 |
36 |

M:

37 | 38 | % 39 |
40 |
41 |

Y:

42 | 43 | % 44 |
45 |
46 |

K:

47 | 48 | % 49 |
50 |
51 | 52 |
53 |

L:

54 | 55 | 56 |
57 |
58 |

a:

59 | 60 | 61 |
62 |
63 |

b:

64 | 65 | 66 |
67 |
68 | 69 |
70 |

H:

71 | 72 | % 73 |
74 |
75 |

S:

76 | 77 | % 78 |
79 |
80 |

B:

81 | 82 | % 83 |
84 |
85 | 86 |
87 |

#

88 | 89 |
90 |
91 |
92 |
93 |

预览

94 |
95 |

{{hex}}

96 |
97 | 98 |
99 |
100 |
101 |
102 |

RGB分量

103 |
104 |
105 |

R:

106 |
107 |

{{red}}

108 |
109 |
110 |
111 |

G:

112 |
113 |

{{green}}

114 |
115 |
116 |
117 |

B:

118 |
119 |

{{blue}}

120 |
121 |
122 |
123 |
124 |
125 |

CMYK分量

126 |
127 |
128 |

C:

129 |
130 |

{{cyan}}%

131 |
132 |
133 |
134 |

M:

135 |
136 |

{{magenta}}%

137 |
138 |
139 |
140 |

Y:

141 |
142 |

{{yellow}}%

143 |
144 |
145 |
146 |

K:

147 |
148 |

{{black}}%

149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |

Lab分量

157 |
158 |
159 |

L:

160 |
161 |

{{luminosity}}

162 |
163 |
164 |
165 |

a:

166 |
167 |

{{a}}

168 |
169 |
170 |
171 |

b:

172 |
173 |

{{b}}

174 |
175 |
176 |
177 |
178 |
179 |

HSB分量

180 |
181 |
182 |

H:

183 |
184 |

{{hue}}%

185 |
186 |
187 |
188 |

S:

189 |
190 |

{{saturation}}%

191 |
192 |
193 |
194 |

B:

195 |
196 |

{{brightness}}%

197 |
198 |
199 |
200 |
201 |
202 |
-------------------------------------------------------------------------------- /pages/plaza/china.js: -------------------------------------------------------------------------------- 1 | // pages/plaza/china.js 2 | 3 | const { preventDoubleClick, onShare } = require('../../utils/functions.js'); 4 | 5 | Page({ 6 | 7 | /** 8 | * 页面的初始数据 9 | */ 10 | data: { 11 | colors: [ 12 | { name: '精白', hex: '#ffffff', color: 'black' }, 13 | { name: '银白', hex: '#e9e7ef', color: 'black' }, 14 | { name: '铅白', hex: '#f0f0f4', color: 'black' }, 15 | { name: '霜色', hex: '#e9f1f6', color: 'black' }, 16 | { name: '雪白', hex: '#f0fcff', color: 'black' }, 17 | { name: '莹白', hex: '#e3f9fd', color: 'black' }, 18 | { name: '月白', hex: '#d6ecf0', color: 'black' }, 19 | { name: '象牙白', hex: '#fffbf0', color: 'black' }, 20 | { name: '缟', hex: '#f2ecde', color: 'black' }, 21 | { name: '鱼肚白', hex: '#fcefe8', color: 'black' }, 22 | { name: '白粉', hex: '#fff2df', color: 'black' }, 23 | { name: '荼白', hex: '#f3f9f1', color: 'black' }, 24 | { name: '鸭卵青', hex: '#e0eee8', color: 'black' }, 25 | { name: '素', hex: '#e0f0e9', color: 'black' }, 26 | { name: '青白', hex: '#c0ebd7', color: 'black' }, 27 | { name: '蟹壳青', hex: '#bbcdc5', color: 'black' }, 28 | { name: '花白', hex: '#c2ccd0', color: 'black' }, 29 | { name: '老银', hex: '#bacac6', color: 'black' }, 30 | { name: '灰色', hex: '#808080', color: 'white' }, 31 | { name: '苍色', hex: '#75878a', color: 'white' }, 32 | { name: '水色', hex: '#88ada6', color: 'white' }, 33 | { name: '黝', hex: '#6b6882', color: 'white' }, 34 | { name: '乌色', hex: '#725e82', color: 'white' }, 35 | { name: '玄青', hex: '#3d3b4f', color: 'white' }, 36 | { name: '乌黑', hex: '#392f41', color: 'white' }, 37 | { name: '黎', hex: '#75664d', color: 'white' }, 38 | { name: '黧', hex: '#5d513c', color: 'white' }, 39 | { name: '黝黑', hex: '#665757', color: 'white' }, 40 | { name: '缁色', hex: '#493131', color: 'white' }, 41 | { name: '煤黑', hex: '#312520', color: 'white' }, 42 | { name: '漆黑', hex: '#161823', color: 'white' }, 43 | { name: '黑色', hex: '#000000', color: 'white' }, 44 | { name: '樱草色', hex: '#eaff56', color: 'black' }, 45 | { name: '鹅黄', hex: '#fff143', color: 'black' }, 46 | { name: '鸭黄', hex: '#faff72', color: 'black' }, 47 | { name: '杏黄', hex: '#ffa631', color: 'white' }, 48 | { name: '橙黄', hex: '#ffa400', color: 'white' }, 49 | { name: '橙色', hex: '#fa8c35', color: 'white' }, 50 | { name: '杏红', hex: '#ff8c31', color: 'white' }, 51 | { name: '橘黄', hex: '#ff8936', color: 'white' }, 52 | { name: '橘红', hex: '#ff7500', color: 'white' }, 53 | { name: '藤黄', hex: '#ffb61e', color: 'white' }, 54 | { name: '姜黄', hex: '#ffc773', color: 'white' }, 55 | { name: '雌黄', hex: '#ffc64b', color: 'white' }, 56 | { name: '赤金', hex: '#f2be45', color: 'white' }, 57 | { name: '缃色', hex: '#f0c239', color: 'white' }, 58 | { name: '雄黄', hex: '#e9bb1d', color: 'white' }, 59 | { name: '秋香色', hex: '#d9b611', color: 'white' }, 60 | { name: '金色', hex: '#eacd76', color: 'white' }, 61 | { name: '牙色', hex: '#eedeb0', color: 'white' }, 62 | { name: '枯黄', hex: '#d3b17d', color: 'white' }, 63 | { name: '黄栌', hex: '#e29c45', color: 'white' }, 64 | { name: '乌金', hex: '#a78e44', color: 'white' }, 65 | { name: '昏黄', hex: '#c89b40', color: 'white' }, 66 | { name: '棕黄', hex: '#ae7000', color: 'white' }, 67 | { name: '琥珀', hex: '#ca6924', color: 'white' }, 68 | { name: '棕色', hex: '#b25d25', color: 'white' }, 69 | { name: '茶色', hex: '#b35c44', color: 'white' }, 70 | { name: '棕红', hex: '#9b4400', color: 'white' }, 71 | { name: '赭', hex: '#9c5333', color: 'white' }, 72 | { name: '驼色', hex: '#a88462', color: 'white' }, 73 | { name: '秋色', hex: '#896c39', color: 'white' }, 74 | { name: '棕绿', hex: '#827100', color: 'white' }, 75 | { name: '褐色', hex: '#6e511e', color: 'white' }, 76 | { name: '棕黑', hex: '#7c4b00', color: 'white' }, 77 | { name: '赭色', hex: '#955539', color: 'white' }, 78 | { name: '赭石', hex: '#845a33', color: 'white' }, 79 | { name: '松花色', hex: '#bce672', color: 'white' }, 80 | { name: '柳黄', hex: '#c9dd22', color: 'white' }, 81 | { name: '嫩绿', hex: '#bddd22', color: 'white' }, 82 | { name: '柳绿', hex: '#afdd22', color: 'white' }, 83 | { name: '葱黄', hex: '#a3d900', color: 'white' }, 84 | { name: '葱绿', hex: '#9ed900', color: 'white' }, 85 | { name: '豆绿', hex: '#9ed048', color: 'white' }, 86 | { name: '豆青', hex: '#96ce54', color: 'white' }, 87 | { name: '油绿', hex: '#00bc12', color: 'white' }, 88 | { name: '葱倩', hex: '#0eb83a', color: 'white' }, 89 | { name: '葱青', hex: '#0eb83a', color: 'white' }, 90 | { name: '青葱', hex: '#0aa344', color: 'white' }, 91 | { name: '石绿', hex: '#16a951', color: 'white' }, 92 | { name: '松柏绿', hex: '#21a675', color: 'white' }, 93 | { name: '松花绿', hex: '#057748', color: 'white' }, 94 | { name: '绿沈', hex: '#0c8918', color: 'white' }, 95 | { name: '绿色', hex: '#00e500', color: 'white' }, 96 | { name: '草绿', hex: '#40de5a', color: 'white' }, 97 | { name: '青翠', hex: '#00e079', color: 'white' }, 98 | { name: '青色', hex: '#00e09e', color: 'white' }, 99 | { name: '翡翠色', hex: '#3de1ad', color: 'white' }, 100 | { name: '碧绿', hex: '#2add9c', color: 'white' }, 101 | { name: '玉色', hex: '#2edfa3', color: 'white' }, 102 | { name: '缥', hex: '#7fecad', color: 'white' }, 103 | { name: '艾绿', hex: '#a4e2c6', color: 'white' }, 104 | { name: '石青', hex: '#7bcfa6', color: 'white' }, 105 | { name: '碧色', hex: '#1bd1a5', color: 'white' }, 106 | { name: '青碧', hex: '#48c0a3', color: 'white' }, 107 | { name: '铜绿', hex: '#549688', color: 'white' }, 108 | { name: '竹青', hex: '#789262', color: 'white' }, 109 | { name: '墨灰', hex: '#758a99', color: 'white' }, 110 | { name: '墨色', hex: '#50616d', color: 'white' }, 111 | { name: '鸦青', hex: '#424c50', color: 'white' }, 112 | { name: '黯', hex: '#41555d', color: 'white' }, 113 | { name: '朱砂', hex: '#ff461f', color: 'white' }, 114 | { name: '火红', hex: '#ff2d51', color: 'white' }, 115 | { name: '朱膘', hex: '#f36838', color: 'white' }, 116 | { name: '妃色', hex: '#ed5736', color: 'white' }, 117 | { name: '洋红', hex: '#ff4777', color: 'white' }, 118 | { name: '品红', hex: '#f00056', color: 'white' }, 119 | { name: '粉红', hex: '#ffb3a7', color: 'white' }, 120 | { name: '桃红', hex: '#f47983', color: 'white' }, 121 | { name: '海棠红', hex: '#db5a6b', color: 'white' }, 122 | { name: '樱桃色', hex: '#c93756', color: 'white' }, 123 | { name: '酡颜', hex: '#f9906f', color: 'white' }, 124 | { name: '银红', hex: '#f05654', color: 'white' }, 125 | { name: '大红', hex: '#ff2121', color: 'white' }, 126 | { name: '石榴红', hex: '#f20c00', color: 'white' }, 127 | { name: '绛紫', hex: '#8c4356', color: 'white' }, 128 | { name: '绯红', hex: '#c83c23', color: 'white' }, 129 | { name: '胭脂', hex: '#9d2933', color: 'white' }, 130 | { name: '朱红', hex: '#ff4c00', color: 'white' }, 131 | { name: '丹', hex: '#ff4e20', color: 'white' }, 132 | { name: '彤', hex: '#f35336', color: 'white' }, 133 | { name: '酡红', hex: '#dc3023', color: 'white' }, 134 | { name: '炎', hex: '#ff3300', color: 'white' }, 135 | { name: '茜色', hex: '#cb3a56', color: 'white' }, 136 | { name: '绾', hex: '#a98175', color: 'white' }, 137 | { name: '檀', hex: '#b36d61', color: 'white' }, 138 | { name: '嫣红', hex: '#ef7a82', color: 'white' }, 139 | { name: '洋红', hex: '#ff0097', color: 'white' }, 140 | { name: '枣红', hex: '#c32136', color: 'white' }, 141 | { name: '殷红', hex: '#be002f', color: 'white' }, 142 | { name: '赫赤', hex: '#c91f37', color: 'white' }, 143 | { name: '银朱', hex: '#bf242a', color: 'white' }, 144 | { name: '赤', hex: '#c3272b', color: 'white' }, 145 | { name: '胭脂', hex: '#9d2933', color: 'white' }, 146 | { name: '栗色', hex: '#60281e', color: 'white' }, 147 | { name: '玄色', hex: '#622a1d', color: 'white' }, 148 | { name: '蔚蓝', hex: '#70f3ff', color: 'black' }, 149 | { name: '蓝', hex: '#44cef6', color: 'white' }, 150 | { name: '碧蓝', hex: '#3eede7', color: 'white' }, 151 | { name: '石青', hex: '#1685a9', color: 'white' }, 152 | { name: '靛青', hex: '#177cb0', color: 'white' }, 153 | { name: '靛蓝', hex: '#065279', color: 'white' }, 154 | { name: '花青', hex: '#003472', color: 'white' }, 155 | { name: '宝蓝', hex: '#4b5cc4', color: 'white' }, 156 | { name: '蓝灰色', hex: '#a1afc9', color: 'white' }, 157 | { name: '藏青', hex: '#2e4e7e', color: 'white' }, 158 | { name: '藏蓝', hex: '#3b2e7e', color: 'white' }, 159 | { name: '黛', hex: '#4a4266', color: 'white' }, 160 | { name: '黛绿', hex: '#426666', color: 'white' }, 161 | { name: '黛蓝', hex: '#425066', color: 'white' }, 162 | { name: '黛紫', hex: '#574266', color: 'white' }, 163 | { name: '紫色', hex: '#8d4bbb', color: 'white' }, 164 | { name: '紫酱', hex: '#815463', color: 'white' }, 165 | { name: '酱紫', hex: '#815476', color: 'white' }, 166 | { name: '紫檀', hex: '#4c221b', color: 'white' }, 167 | { name: '绀青', hex: '#003371', color: 'white' }, 168 | { name: '紫棠', hex: '#56004f', color: 'white' }, 169 | { name: '青莲', hex: '#801dae', color: 'white' }, 170 | { name: '群青', hex: '#4c8dae', color: 'white' }, 171 | { name: '雪青', hex: '#b0a4e3', color: 'white' }, 172 | { name: '丁香色', hex: '#cca4e3', color: 'white' }, 173 | { name: '藕色', hex: '#edd1d8', color: 'white' }, 174 | { name: '藕荷色', hex: '#e4c6d0', color: 'white' }] 175 | }, 176 | 177 | jump: function (event) { 178 | if (!this.data.buttonClicked) { 179 | preventDoubleClick(this); 180 | const name = event.currentTarget.dataset.name; 181 | const color = event.currentTarget.dataset.color; 182 | wx.navigateTo({ 183 | url: '/pages/web/colordetail?color=' + color + '&name=' + name 184 | }); 185 | } 186 | }, 187 | 188 | /** 189 | * 用户点击右上角分享 190 | */ 191 | onShareAppMessage: function () { 192 | return onShare('中国传统色彩'); 193 | } 194 | }) --------------------------------------------------------------------------------