<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://wbex.ru/index.php?action=history&amp;feed=atom&amp;title=JavaScript_Tutorial%2FDevelopment%2FColor</id>
		<title>JavaScript Tutorial/Development/Color - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://wbex.ru/index.php?action=history&amp;feed=atom&amp;title=JavaScript_Tutorial%2FDevelopment%2FColor"/>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_Tutorial/Development/Color&amp;action=history"/>
		<updated>2026-04-04T11:33:08Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://wbex.ru/index.php?title=JavaScript_Tutorial/Development/Color&amp;diff=8459&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_Tutorial/Development/Color&amp;diff=8459&amp;oldid=prev"/>
				<updated>2010-05-26T08:24:18Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 08:24, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://wbex.ru/index.php?title=JavaScript_Tutorial/Development/Color&amp;diff=8458&amp;oldid=prev</id>
		<title> в 18:52, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_Tutorial/Development/Color&amp;diff=8458&amp;oldid=prev"/>
				<updated>2010-05-25T18:52:56Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Using zColor Library==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE HTML PUBLIC &amp;quot;-//W3C//DTD HTML 4.0 Transitional//EN&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;zColor Example&amp;lt;/title&amp;gt;&lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
/*------------------------------------------------------------------------------&lt;br /&gt;
 * JavaScript zColor Library&lt;br /&gt;
 * Version 0.1&lt;br /&gt;
 * by Nicholas C. Zakas, http://www.nczonline.net/&lt;br /&gt;
 * Copyright (c) 2004-2005 Nicholas C. Zakas. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is free software; you can redistribute it and/or modify&lt;br /&gt;
 * it under the terms of the GNU Lesser General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2.1 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
 * GNU Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public License&lt;br /&gt;
 * along with this program; if not, write to the Free Software&lt;br /&gt;
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA&lt;br /&gt;
 *------------------------------------------------------------------------------&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
/**&lt;br /&gt;
 * Represents an RGB color.&lt;br /&gt;
 * @class&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @constructor&lt;br /&gt;
 * @param iRed The red value for the color (0-255)&lt;br /&gt;
 * @param iGreen The green value for the color (0-255)&lt;br /&gt;
 * @param iBlue The blue value for the color (0-255)&lt;br /&gt;
 */&lt;br /&gt;
function zRGB(iRed, iGreen, iBlue) {&lt;br /&gt;
    /**&lt;br /&gt;
     * The red value for the color.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.r /*:int */ = parseInt(iRed,10);&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * The green value for the color.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */    &lt;br /&gt;
    this.g /*:int */ = parseInt(iGreen,10);&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * The blue value for the color.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */    &lt;br /&gt;
    this.b /*:int */= parseInt(iBlue,10);&lt;br /&gt;
}&lt;br /&gt;
/**&lt;br /&gt;
 * Creates an RGB color from a hex string.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @param sHex The hex string.&lt;br /&gt;
 * @return The RGB object for the hex string.&lt;br /&gt;
 */&lt;br /&gt;
zRGB.fromHexString = function (sHex /*: String */) /*:zRGB */ {&lt;br /&gt;
    //eliminate the pound sign&lt;br /&gt;
    if (sHex.charAt(0) == &amp;quot;#&amp;quot;) {&lt;br /&gt;
        sHex = sHex.substring(1);&lt;br /&gt;
    } //ENd: if (sHex.charAt(0) == &amp;quot;#&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    //extract and convert the red, green, and blue values&lt;br /&gt;
    var iRed = parseInt(sHex.substring(0,2),16);&lt;br /&gt;
    var iGreen = parseInt(sHex.substring(2,4),16);&lt;br /&gt;
    var iBlue = parseInt(sHex.substring(4,6),16);&lt;br /&gt;
    &lt;br /&gt;
    //return an array&lt;br /&gt;
    return new zRGB(iRed,iGreen,iBlue);&lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Returns a hex representation of the color.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @return A hex representation of the color.&lt;br /&gt;
 */&lt;br /&gt;
zRGB.prototype.toHexString = function () /*:String */ {&lt;br /&gt;
    //extract and convert the red, green, and blue values&lt;br /&gt;
    var sRed = this.r.toString(16).toUpperCase();&lt;br /&gt;
    var sGreen = this.g.toString(16).toUpperCase();&lt;br /&gt;
    var sBlue = this.b.toString(16).toUpperCase();&lt;br /&gt;
    &lt;br /&gt;
    //make sure there are two digits in each code&lt;br /&gt;
    if (sRed.length == 1) {&lt;br /&gt;
            sRed = &amp;quot;0&amp;quot; + sRed;&lt;br /&gt;
    } //End: if (sRed.length == 1)    &lt;br /&gt;
    if (sGreen.length == 1) {&lt;br /&gt;
            sGreen = &amp;quot;0&amp;quot; + sGreen;&lt;br /&gt;
    } //End: if (sGreen.length == 1)    &lt;br /&gt;
    if (sBlue.length == 1) {&lt;br /&gt;
            sBlue = &amp;quot;0&amp;quot; + sBlue;&lt;br /&gt;
    } //End: if (sBlue.length == 1)    &lt;br /&gt;
    &lt;br /&gt;
    //return the hex code&lt;br /&gt;
    return &amp;quot;#&amp;quot; + sRed + sGreen + sBlue;&lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Returns an HSL representation of the color.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @return An HSL representation of the color.&lt;br /&gt;
 */&lt;br /&gt;
zRGB.prototype.toHSL = function () /*:zHSL */ {&lt;br /&gt;
    &lt;br /&gt;
    var iMax = Math.max(this.r, this.g, this.b);&lt;br /&gt;
    var iMin = Math.min(this.r, this.g, this.b);&lt;br /&gt;
    var iDelta = iMax-iMin;&lt;br /&gt;
    var iLum = Math.round((iMax+iMin)/2);&lt;br /&gt;
    var iHue = 0;&lt;br /&gt;
    var iSat = 0;&lt;br /&gt;
    &lt;br /&gt;
    if (iDelta &amp;gt; 0) {&lt;br /&gt;
        iSat = Math.ceil(((iLum &amp;lt; (0.5*255)) ? iDelta/(iMax + iMin) : iDelta/((2*255)-iMax-iMin))*255);&lt;br /&gt;
        var iRedC = (iMax-this.r)/iDelta;&lt;br /&gt;
        var iGreenC = (iMax-this.g)/iDelta;&lt;br /&gt;
        var iBlueC = (iMax-this.b)/iDelta;&lt;br /&gt;
        &lt;br /&gt;
        if (this.r == iMax) {&lt;br /&gt;
            iHue = iBlueC - iGreenC;                &lt;br /&gt;
        } else if (this.g == iMax) {&lt;br /&gt;
            iHue = 2.0 + iRedC - iBlueC;&lt;br /&gt;
        } else {&lt;br /&gt;
            iHue = 4.0 + iGreenC - iRedC;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        iHue /= 6.0;&lt;br /&gt;
        &lt;br /&gt;
        if (iHue &amp;lt; 0) {&lt;br /&gt;
            iHue += 1.0;&lt;br /&gt;
        }&lt;br /&gt;
        iHue = Math.round(iHue * 255);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    return new zHSL(iHue,iSat,iLum);&lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Returns the color in a string form.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @return The color in a string form.&lt;br /&gt;
 */&lt;br /&gt;
zRGB.prototype.toString = function () /*:String */ {&lt;br /&gt;
    return &amp;quot;rgb(&amp;quot; + this.r + &amp;quot;,&amp;quot; + this.g + &amp;quot;,&amp;quot; + this.b + &amp;quot;)&amp;quot;;&lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Represents an HSL color.&lt;br /&gt;
 * @class&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @constructor&lt;br /&gt;
 * @param iHue The hue value for the color (0-255)&lt;br /&gt;
 * @param iSat The saturation value for the color (0-255)&lt;br /&gt;
 * @param iLum The luminosity value for the color (0-255)&lt;br /&gt;
 */&lt;br /&gt;
function zHSL(iHue, iSat, iLum) {&lt;br /&gt;
    /**&lt;br /&gt;
     * The hue value for the color.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */&lt;br /&gt;
    this.h /*:int */ = parseInt(iHue,10);&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * The saturation value for the color.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */    &lt;br /&gt;
    this.s /*:int */ = parseInt(iSat,10);&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * The luminosity value for the color.&lt;br /&gt;
     * @scope public&lt;br /&gt;
     */    &lt;br /&gt;
    this.l /*:int */= parseInt(iLum,10);&lt;br /&gt;
}&lt;br /&gt;
/**&lt;br /&gt;
 * Converts the color into RGB form.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @return An RGB version of the color.&lt;br /&gt;
 */&lt;br /&gt;
zHSL.prototype.toRGB = function () /*:zRGB */ {&lt;br /&gt;
    iHue = this.h/255;&lt;br /&gt;
    iSat = this.s/255;&lt;br /&gt;
    iLum = this.l/255;&lt;br /&gt;
    var iRed, iGreen, iBlue;&lt;br /&gt;
    &lt;br /&gt;
    if (iSat == 0) {&lt;br /&gt;
        iRed = iGreen = iBlue = iLum;        &lt;br /&gt;
    } else {&lt;br /&gt;
        var m1, m2;&lt;br /&gt;
        &lt;br /&gt;
        if (iLum &amp;lt;= 0.5) {&lt;br /&gt;
            m2 = iLum * (1+iSat);&lt;br /&gt;
        } else {&lt;br /&gt;
            m2 = iLum + iSat - (iLum * iSat);&lt;br /&gt;
        }&lt;br /&gt;
            &lt;br /&gt;
        m1 = 2.0 * iLum - m2;&lt;br /&gt;
        &lt;br /&gt;
        hf2 = iHue + 1/3;&lt;br /&gt;
        if (hf2 &amp;lt; 0) hf2 = hf2 + 1;&lt;br /&gt;
        if (hf2 &amp;gt; 1) hf2 = hf2 - 1;&lt;br /&gt;
        if (6 * hf2 &amp;lt; 1) {&lt;br /&gt;
            iRed = (m1+(m2-m1)*hf2*6);&lt;br /&gt;
        } else {&lt;br /&gt;
            if (2 * hf2 &amp;lt; 1) {&lt;br /&gt;
                iRed = m2;&lt;br /&gt;
            } else {&lt;br /&gt;
                if (3.0*hf2 &amp;lt; 2.0) {&lt;br /&gt;
                    iRed = (m1+(m2-m1)*((2.0/3.0)-hf2)*6.0);&lt;br /&gt;
                } else {&lt;br /&gt;
                    iRed = m1;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        //Calculate Green                    &lt;br /&gt;
        if (iHue &amp;lt; 0) {iHue = iHue + 1.0;}&lt;br /&gt;
        if (iHue &amp;gt; 1) {iHue = iHue - 1.0;}&lt;br /&gt;
        if (6.0 * iHue &amp;lt; 1){&lt;br /&gt;
            iGreen = (m1+(m2-m1)*iHue*6.0);}&lt;br /&gt;
        else {&lt;br /&gt;
            if (2.0 * iHue &amp;lt; 1){&lt;br /&gt;
                iGreen = m2;&lt;br /&gt;
            } else {&lt;br /&gt;
                if (3.0*iHue &amp;lt; 2.0) {&lt;br /&gt;
                    iGreen = (m1+(m2-m1)*((2.0/3.0)-iHue)*6.0);&lt;br /&gt;
                } else {&lt;br /&gt;
                    iGreen = m1;&lt;br /&gt;
                }&lt;br /&gt;
            } &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        //Calculate Blue&lt;br /&gt;
        hf2=iHue-1.0/3.0;                    &lt;br /&gt;
        if (hf2 &amp;lt; 0) {hf2 = hf2 + 1.0;}&lt;br /&gt;
        if (hf2 &amp;gt; 1) {hf2 = hf2 - 1.0;}&lt;br /&gt;
        if (6.0 * hf2 &amp;lt; 1) {&lt;br /&gt;
             iBlue = (m1+(m2-m1)*hf2*6.0);&lt;br /&gt;
        } else {&lt;br /&gt;
             if (2.0 * hf2 &amp;lt; 1){&lt;br /&gt;
                 iBlue = m2;&lt;br /&gt;
             } else {&lt;br /&gt;
                 if (3.0*hf2 &amp;lt; 2.0) {&lt;br /&gt;
                     iBlue = (m1+(m2-m1)*((2.0/3.0)-hf2)*6.0);&lt;br /&gt;
                 } else {&lt;br /&gt;
                     iBlue = m1;&lt;br /&gt;
                 }&lt;br /&gt;
             } &lt;br /&gt;
        }&lt;br /&gt;
    &lt;br /&gt;
    }    &lt;br /&gt;
    return new zRGB(Math.round(iRed*255),Math.round(iGreen*255),Math.round(iBlue*255));&lt;br /&gt;
};&lt;br /&gt;
/**&lt;br /&gt;
 * Returns the color in a string form.&lt;br /&gt;
 * @scope public&lt;br /&gt;
 * @return The color in a string form.&lt;br /&gt;
 */&lt;br /&gt;
zHSL.prototype.toString = function () /*:String */ {&lt;br /&gt;
    return &amp;quot;hsl(&amp;quot; + this.h + &amp;quot;,&amp;quot; + this.s + &amp;quot;,&amp;quot; + this.l + &amp;quot;)&amp;quot;;&lt;br /&gt;
};&lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
            function convertToHSL() {&lt;br /&gt;
                var iRed = parseInt(document.getElementById(&amp;quot;txtRed&amp;quot;).value);&lt;br /&gt;
                var iBlue = parseInt(document.getElementById(&amp;quot;txtBlue&amp;quot;).value);&lt;br /&gt;
                var iGreen = parseInt(document.getElementById(&amp;quot;txtGreen&amp;quot;).value);&lt;br /&gt;
                &lt;br /&gt;
                var oRGB = new zRGB(iRed, iGreen, iBlue);&lt;br /&gt;
                var oHSL = oRGB.toHSL();&lt;br /&gt;
                document.getElementById(&amp;quot;txtHue&amp;quot;).value = oHSL.h;&lt;br /&gt;
                document.getElementById(&amp;quot;txtSat&amp;quot;).value = oHSL.s;&lt;br /&gt;
                document.getElementById(&amp;quot;txtLum&amp;quot;).value = oHSL.l;&lt;br /&gt;
                &lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            function convertToRGB() {&lt;br /&gt;
                var iHue = parseInt(document.getElementById(&amp;quot;txtHue&amp;quot;).value);&lt;br /&gt;
                var iSat = parseInt(document.getElementById(&amp;quot;txtSat&amp;quot;).value);&lt;br /&gt;
                var iLum = parseInt(document.getElementById(&amp;quot;txtLum&amp;quot;).value);&lt;br /&gt;
                &lt;br /&gt;
                var oHSL = new zHSL(iHue, iSat, iLum);&lt;br /&gt;
                var oRGB = oHSL.toRGB();&lt;br /&gt;
                &lt;br /&gt;
                document.getElementById(&amp;quot;txtRed&amp;quot;).value = oRGB.r;&lt;br /&gt;
                document.getElementById(&amp;quot;txtGreen&amp;quot;).value = oRGB.g;&lt;br /&gt;
                document.getElementById(&amp;quot;txtBlue&amp;quot;).value = oRGB.b;&lt;br /&gt;
                &lt;br /&gt;
            }&lt;br /&gt;
                     &lt;br /&gt;
        &amp;lt;/script&amp;gt;&lt;br /&gt;
    &amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
        &amp;lt;form&amp;gt;&lt;br /&gt;
            &amp;lt;table border=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;tr&amp;gt;&lt;br /&gt;
                &amp;lt;td&amp;gt;&lt;br /&gt;
                    R: &amp;lt;input type=&amp;quot;text&amp;quot; id=&amp;quot;txtRed&amp;quot; /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
                    G: &amp;lt;input type=&amp;quot;text&amp;quot; id=&amp;quot;txtGreen&amp;quot; /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
                    B: &amp;lt;input type=&amp;quot;text&amp;quot; id=&amp;quot;txtBlue&amp;quot; /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
                    &amp;lt;input type=&amp;quot;button&amp;quot; value=&amp;quot;to HSL -&amp;amp;gt;&amp;quot; onclick=&amp;quot;convertToHSL()&amp;quot;/&amp;gt;&lt;br /&gt;
                &amp;lt;/td&amp;gt;&lt;br /&gt;
                &amp;lt;td&amp;gt;&lt;br /&gt;
                    H: &amp;lt;input type=&amp;quot;text&amp;quot; id=&amp;quot;txtHue&amp;quot; /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
                    S: &amp;lt;input type=&amp;quot;text&amp;quot; id=&amp;quot;txtSat&amp;quot; /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
                    L: &amp;lt;input type=&amp;quot;text&amp;quot; id=&amp;quot;txtLum&amp;quot; /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
                    &amp;lt;input type=&amp;quot;button&amp;quot; value=&amp;quot;&amp;amp;lt;- to RGB&amp;quot; onclick=&amp;quot;convertToRGB()&amp;quot;/&amp;gt;&lt;br /&gt;
                &amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;/tr&amp;gt;&lt;br /&gt;
            &amp;lt;/table&amp;gt;&lt;br /&gt;
        &amp;lt;/form&amp;gt;&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>