给定RGB值计算色谱上相应的坐标
来源:互联网 发布:淘宝买csgo钥匙 编辑:程序博客网 时间:2024/05/18 17:04
<html xmlns="http://www.w3.org/1999/xhtml" ><head><title>Color Picker</title><script type="text/javascript" src="jquery.min.js"></script><script type="text/javascript">var configColorArea = { minX: 1, maxX: 209, minY: 1, maxY: 119};function changeRGB(R,G,B){var k = parseInt(R),j = parseInt(G),h = parseInt(B),i;if (isNaN(k) || k > 255 || k < 0) {R = 255} if (isNaN(j) || j > 255 || j < 0) {G = 255} if (isNaN(h) || h > 255 || h < 0) {B = 255} i = rgb2hsl(R / 255, G / 255, B / 255);var hue = Math.round(i.h);var sat = Math.round(i.s * 100);var lum = Math.round(i.l * 100);refreshCoordinatesByHSL(hue, sat, lum);}function rgb2hsl(j, i, d){var h, f, c;var a = Math.max(j, i, d),e = Math.min(j, i, d);c = 0.5 * (a + e);if (a == e) {h = 0} else {if (a == j) {h = 60 * (i - d) / (a - e);if (i < d) {h += 360}} else {if (a == i) {h = 60 * (d - j) / (a - e) + 120} else {h = 60 * (j - i) / (a - e) + 240}}}if (c == 0 || a == e) {f = 0} else {if (c <= 0.5) {f = 0.5 * (a - e) / c} else {f = 0.5 * (a - e) / (1 - c)}}return {h: h,s: f,l: c}}function refreshCoordinatesByHSL(f, e, b){ a = Math.round((configColorArea.maxX - configColorArea.minX) * f / 359) + configColorArea.minX; d = Math.round((configColorArea.maxY - configColorArea.minY) * (100 - b) / 100) + configColorArea.minY; c = Math.round((configColorArea.maxY - configColorArea.minY) * (100 - e) / 100) + configColorArea.minY; setColorAreaXY(a, d);}function setColorAreaXY(a, c){ var b = configColorArea; a = parseInt(a); var x=0; var y=0; if (b.minX > a) { x = b.minX } else { if (a > b.maxX) { x = b.maxX } else { if (!isNaN(a)) { x = a } } } c = parseInt(c); if (b.minY > c) { y = b.minY } else { if (c > b.maxY) { y = b.maxY } else { if (!isNaN(c)) { y = c } } } refreshPosition(x,y)}function refreshPosition(x,y){//定义一个点的css样式var innerHTML="<div style='position: absolute; top: "+y+"px; left: "+x+"px; height: 20px; width: 20px;'><div style='position: absolute; width: 4px; height: 20px; left: 8px; top: 0px; background: rgb(255, 255, 255);'></div><div style='position: absolute; height: 4px; width: 20px; top: 8px; left: 0px; background: rgb(255, 255, 255);'></div><div style='position: absolute; height: 18px; width: 2px; left: 9px; top: 1px; background: rgb(76, 76, 76);'></div><div style='position: absolute; width: 18px; height: 2px; top: 9px; left: 1px; background: rgb(76, 76, 76);'></div></div>";$("#positions").append(innerHTML);}$(function(){/*changeRGB(0, 0, 0);changeRGB(255, 255, 255);changeRGB(228, 185, 170);changeRGB(228, 170, 187);*/})</script></head><body><div id="positions" style="top: 118px;left: 200px;position: absolute;width: 210px;height: 120px;"><div style="position: absolute;width: 210px;height: 120px;background-image: url('shiseqi.png');background-repeat: no-repeat;cursor: pointer;float: left;"></din></div></body></html>
0 0
- 给定RGB值计算色谱上相应的坐标
- Datatable 增加一列并为该列赋上相应的值
- Datatable 增加一列并为该列赋上相应的值
- 如何在任意的控件上相应回车键消息
- RGB色谱1
- RGB色谱2
- Android给定坐标计算距离
- 【数学】给定两个点线性求解给定x坐标对应的y坐标值
- 计算两点的坐标值
- 通过gps给定的两个经纬度坐标,计算两点之间的距离
- 计算给定算术表达式的值
- 计算特征点通过单应矩阵后的坐标的小函数
- 一个色谱的实现
- 根据给定的像素点的RGB值写bmp位图
- 旋转坐标的计算
- 色谱
- 数据结构_写程序计算给定多项式在给定点处的值
- 计算给定多项式 在给定点 x = 1.1 处的值 f(1.1)
- TensorFlow 博文转载
- ConcurrentModificationException
- ubuntu删除特定用户的进程
- itext将html转pdf中文支持
- Ubuntu14.04安装jdk1.7.0_71
- 给定RGB值计算色谱上相应的坐标
- android资源的热更新(替换 AssetManager+LoadedApk中的资源路径)
- Java Web开发--------监听器
- ubuntu实现无密码登陆
- ubuntu14.04的hadoop环境搭建(全分布模式)
- CentOS 6.5下NFS安装配置
- 如何判断一个vtkActor的类型
- Win7上的Eclipse3.3远程连接ubuntu14.04中的hadoop0.20.2
- HDFS可靠性措施