To determine whether two color values are similar colors _ typical effects

Source: Internet
Author: User
Tags abs
<script type= "Text/javascript" >//title: Determine whether the two color values are similar colors//author:cnlei te:http://www.cnlei.com//Real application, please comment out or remove the alert () prompt (Issimilarcolor) function (shexcolora,shexcolorb,noffset ) {this.offsetnum=math.abs (noffset); this.offsetnum>255?this.offsetnum=this.offsetnum-256: ""; var arrnuma=[parseint (shexcolora.substring (0,2), parseint (shexcolora.substring (2,4),), parseint (SHex Colora.substring (4,6), 16)]; var arrnumb=[parseint (shexcolorb.substring (0,2), parseint (shexcolorb.substring (2,4),), parseint (SHex Colorb.substring (4,6), 16)]; for (Var i=0;i<arrnuma.length;i++) {if (Math.Abs (arrnuma[i]-arrnumb[i)) >this.offsetnum) { Alert ("+i+" is not the same as the difference is: "+ (Arrnuma[i]-arrnumb[i]) +", \ n exceeded the maximum error: "+this.offsetnum); return false; }; Alert ("Similar color \ n" +shexcolora+ "\ n" +shexcolorb) return true; } issimilarcolor ("FFFFFF", "F0fffe", 10); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.