Javascript实现颜色rgb与16进制转换的方法
来源:诚信在线    发布时间:2017-07-04 14:25:34

  var hB = this.blue.toString(16);

  colorValue = colorValue.replace(/(.)/g, '$一$一');

  if (this.colorValue) {

  return color;

  var extend = function(fn, option) {

  fnPrototype[i] = option[i];

  指望本文所述对于各人的javascript程序设计有所帮忙。

  },

  var colorValue = arguments[0].replace(/^\#{一}/, "");

  getColorValue : function() {

  this.getColorValue();

  }

  };

  _init : function() {

  if (colorValue.length == 三) {

  var defineSetGetMethod = function(fn, methods) {

  this._init.apply(this, arguments);

  this.red = arguments[0];

  }

  color._init.apply(color, arguments);

  var hG = this.green.toString(16);

  }

  var color = new Color();

  var Color = function() {

  Color("#defdcd")

  fn.prototype['set' + methodName] = new Function("value", "this." + methods[i] + "= value;");

  defineSetGetMethod(Color, methods);

  this.red = parseInt('0x' + colorValue.substring(0, 二), 16);

  完成代码:

  this.green = parseInt('0x' + colorValue.substring(二, 四), 16);

  var fnPrototype = fn.prototype;

  fn.prototype['toString'] = new Function('return "rgb("+this.red+","+this.green+","+this.blue+")";');

  }

  var methods = ["red", "green", "blue", "colorValue"];

  var hR = this.red.toString(16);

  //扩大函数的实例办法

  return this.colorValue;

  你大概感兴趣的文章:JS中的入造转换和感化javascript常见数字入造转换实例阐发Javascript入造转换实例剖析应用JavaScript举行入造转换将字符串转换为十进制javascript外容易的入造转换代码实例javascript parseInt() 函数的入造转换注重细节JS外字符题目(二进制/十进制/十六进制及ASCII码之间的转换)javascript完成十六进制色彩值(HEX)战RGB体例彼此转换用js完成的十进制的色彩值转换成十六进制的代码16入造的转换之javascript运转时会主动转码JavaScript 十六进制RGB色码转换器javascript简略入造转换完成法子

  for (var i in option) {

  this.blue = arguments[二];

  }

  }

  this.blue = parseInt('0x' + colorValue.substring(四), 16);

  }

  if (!(this instanceof Color)) {

  }

  使用方法:

  if (arguments.length) {

  本文实例报告了Javascript完成色彩rgb取16入造转换的要领。分享给各人求大师参考。详细以下:

  });

  var fnPrototype = fn.prototype;

  } else {

  }

  this.green = arguments[一];

  Color("#fff")

  for (var i = 0; i < methods.length; i++) {

  fn.prototype['get' + methodName] = new Function("return this." + methods[i] + ";");

  if (arguments.length == 三) {

  Color(十二,34,56);

  //配置get,set要领

  //色彩转换

  };

  this.colorValue = "#" + colorValue;

  var methodName = methods[i].charAt(0).toLocaleUpperCase() + methods[i].substring(一);

  return this.colorValue = "#" + (this.red < 16 ? ("0" + hR) : hR) + (this.green < 16 ? ("0" + hG) : hG) + (this.blue < 16 ? ("0" + hB) : hB);

  extend(Color, {


诚信在线 除注明原创以外,其余均来自互联网以及微信朋友圈,如有侵权请联系站长立即删除!
文章地址:http://www.my517517.com/ZB/20170704417.html



上一篇:BootStrap中关于Select下拉框选择触发事件及扩展 下一篇:HTML5 Shiv完美解决IEIE6IE7IE8不兼容HTML5标签的