[色空間] - 今日も適当ダイアリーãªã©ã§ãè²ç©ºéã®å¤æã«ã¤ãã¦ã®è¨äºãæ¸ãã¾ããããããããç°¡åã«ä½¿ããããã«ãjQueryãã©ã°ã¤ã³ã¨ãã¦æ¸ãç´ãã¾ããã
ã¾ã ãã¢ã«ãã¡çãªã®ã§ãããåãæ¥ãå ¬éãã¦ããã¾ãã
ãã¡ã¤ã«ã¯ãã¡ã
http://jquery-icolor.googlecode.com/svn/tags/
http://code.google.com/p/jquery-icolor/downloads/list (å§ç¸®ãã¡ã¤ã«)
http://www.weekendphp.com/jQuery/jquery.color.js
http://www.weekendphp.com/jQuery/jquery.color-min.js
ç°¡åãªèª¬æ
ãã®ãã©ã°ã¤ã³ã§ã¯ãjQueyrã«ä¸è¨3ã¤ãæ¡å¼µããã¾ãã
- animateã®æ¡å¼µï¼è²ã®ã¢ãã¡ã¼ã·ã§ã³ãè¡ãã¾ãï¼
- getColorã¡ã½ããã®è¿½å ï¼iColorãªãã¸ã§ã¯ããè¿ãã¾ãï¼
- iColorãªãã¸ã§ã¯ã($.iColor)ã®è¿½å
animateãæ¡å¼µ
jQueryåä½ã§ã¯animateã«ã¦è²ã®ã¢ãã¡ã¼ã·ã§ã³ãè¡ããªãã®ã§ãããè¡ããããã«æ¡å¼µãè¡ãã¾ããã
ã¾ããæè»ãªæå®ã«å¯¾å¿ãã¾ããã
対å¿ããããããã£åã¯ä¸è¨ã®éãã§ãã
- color
- backgroundColor
- borderTopColor
- borderRightColor
- borderBottomColor
- borderLeftColor
- outlineColor
å¤ã¯ä¸è¨2éãã®æ¹æ³ã§æå®åºæ¥ã¾ãã
- CSSè²æå® (â»rgbaãhslaå½¢å¼ã対å¿ãã¦ãã¾ãããIEã§ã¯alphaå¤ã¯ç¡è¦ããã¾ã)
- ãªãã¸ã§ã¯ãæå®
ãµã³ãã«ãè¦ãæ¹ãããããããã¨æãã¾ãã
$("#test1").animate({ backgroundColor: 'yellow' }, 2000); $("#test2").animate({ backgroundColor: // ãªãã¸ã§ã¯ãã¨ãã¦ãä¸é¨ã®å¤ã渡ããã¨ãåºæ¥ã¾ãã { 'h': '+=1080', 's': '-=0.3', 'mode': 'HSV' } }, 3000); $("#test3").animate({ backgroundColor: 'rgba(255,255,0,0)', borderTopColor: 'lightblue', borderBottomColor: 'lightblue', borderLeftColor: 'lightblue', borderRightColor: 'lightblue' }, 2000); $("#test4").animate({ backgroundColor: { 'r': '-=100', 'b': 200, 'a': '+=0.5', 'mode': 'RGB' } }, 2000);
getColorã¡ã½ããã®è¿½å
iColor function getColor(attr)
attr ã«ã¯CSSããããã£åãæå®ãã¾ãã
è¿ãå¤ã¯iColorãªãã¸ã§ã¯ãã¨ãªãã¾ãã
// iColor ãªãã¸ã§ã¯ããè¿ãã¾ãã color = $('div#test1').getColor('background-color'); // ãããªä½¿ãæ¹ãã§ãã¾ã $('#getColorTest2').text( $('div#test1').getColor('background-color') // div#test1ã®èæ¯è²ãåå¾ .change('h', '+=30') // hue (è²ç¸) ã +30度 å¤ãã .getStr() // è²è¡¨ç¾æååãåå¾ );
iColorãªãã¸ã§ã¯ãã®è¿½å
iColorãªãã¸ã§ã¯ãã¯ä¸è¨ã®ããããã«ããçæããã¾ãã
// A) getColorã¡ã½ãã color = $('div#test1').getColor('background-color'); // B) iColorã³ã³ã¹ãã©ã¯ã¿ // B-1. å¼æ°æå® color = jQuery.iColor(color1, color2, color3, [type = 'RGB']); color = jQuery.iColor(color1 color2, color3, [alpha], [type = 'RGBA']); // color1ã3ã¯æ°å¤ã§ãããtypeã«ããåãå¾ãç¯å²ãç°ãªãã¾ãã // R, G, B: 0 ã 255 ã¾ã㯠0% ã 100% // H: 0ã360 (è§åº¦ãªã®ã§ 0 㨠360 ã¯åå¤) // S, V, L: 0 ã 1 ã¾ã㯠0% ã 100% // alpha å¤ã¯ 0ã1ã®æ°å¤ã§ãã // type ã¯è²ç©ºéã表ã次ã®ãããããåãã¾ãã // 'RGB', 'RGBA', 'HSV', 'HSVA', 'HLS', 'HLSA', 'HSL', 'HSLA' // B-2. é åæå® color = jQuery.iColor(colorArray, [type = 'RGB'||'RGBA']); // colorArray 㯠[color1, color2, color3] // ã¾ã㯠[color1, color2, color3, alpha] ã¨ãªãã¾ãã // B-3. ãªãã¸ã§ã¯ãæå® color = jQuery.iColor(colorArray, [type = 'RGB'||'RGBA']); // ä¾ï¼ jQuery.iColor({r: 255, g: 255, b: 255}, 'RGB'); // jQuery.iColor({r: 255, g: 255, b: 255, type: 'RGB'}); // B-4. CSSè²è¡¨ç¾æå® color = jQuery.iColor(colorStr); // colorStr ã¯ã blue ã #rrggbbãrgb(255,255,0)ãhsla(300,10%,50%,1) ãªã©
iColorãªãã¸ã§ã¯ãã®ããããã£
iColorãªãã¸ã§ã¯ãã¯ä¸è¨ã®ããããã£ãæã¡ã¾ãã
typeããããã£
type ããããã£ã¯è²ç©ºéã表ã次ã®ãããããåãã¾ãã
'RGB', 'RGBA', 'HSV', 'HSVA', 'HLS', 'HLSA', 'HSL', 'HSLA'
è²è¦ç´ ããããã£
typeããããã£ã«å¿ãã¦ãããããã®è²è¦ç´ ããããã£ãæã¡ã¾ãã
ãã¨ãã°ãtypeãRGBã ã£ãå ´åãrãgãbã¨ãã3ã¤ã®è²è¦ç´ ããããã£ãæã¤ãã¨ã«ãªãã¾ãã
iColorãªãã¸ã§ã¯ãã®ã¡ã½ãã
iColorãªãã¸ã§ã¯ãã¯ä¸è¨ã®ã¡ã½ãããæã¡ã¾ãã
string function getStr([format = '#xxx'])
iColorãªãã¸ã§ã¯ãã®CSSè²è¡¨ç¾æååãè¿ãã¾ãã
format ã¯ä¸è¨ã®ãããããåãã¾ã
- #xxx
- #fffã®ãããª(å¯è½ã§ããã°ãçã)16é²è¡¨ç¾ã§ããã¹ããè¿ãã¾ãã
- #xxxxxx
- #ffffffã®ãããª6æ¡ã®6é²è¡¨ç¾ã§ããã¹ããè¿ãã¾ãã
- rgb
- rgb(255, 255, 255) ã¾ãã¯ãrgba(255, 255, 255, 1)å½¢å¼ã§è¿ãã¾ãã
- rgb%
- rgb(100%, 100%, 100%) ã¾ãã¯ãrgba(100%, 100%, 100%, 1)å½¢å¼ã§è¿ãã¾ãã
- hsl
- hsl(350, 0.5, 1) ã¾ãã¯ãhsla(350, 0.5, 1, 1)å½¢å¼ã§è¿ãã¾ãã
iColor function to(type)
iColor function toRGB()
iColor function toRGBA()
iColor function toHSV()
iColor function toHSVA()
iColor function toHSL()
iColor function toHSLA()
iColor function toHLS()
iColor function toHLSA()
iColorãªãã¸ã§ã¯ãã®è²ç©ºéå¤æããæ°ããiColorãªãã¸ã§ã¯ããè¿ãã¾ãã
toXXX å½¢å¼ã¯ãto('XXX')ã®ã·ã§ã¼ãã«ããã§ãããåä¸ã®æåããã¾ãã
iColor function change(target, val, mode)
iColorãªãã¸ã§ã¯ãã®ç¹å®ã®è²è¦ç´ ãå¤æ´ããæ°ããiColorãªãã¸ã§ã¯ããè¿ãã¾ãã
target ã«ã¯å¤æ´ãããè²è¦ç´ åï¼1æåã®æååï¼ãæå®ãã¾ãã
val ã«ã¯ãå¤æ´ãããå¤(1 ã '255' ãªã©)ããããã¯å¤åããããé('+=0.1' ã '-=30' ãªã©)ãæå®åºæ¥ã¾ãã
詳細ã¯ãã¢ã§ç¢ºèªãã¦ãã ããã
ãã¡ã¤ã«ã¯ãã¡ã
http://jquery-icolor.googlecode.com/svn/tags/
http://code.google.com/p/jquery-icolor/downloads/list (å§ç¸®ãã¡ã¤ã«)
http://www.weekendphp.com/jQuery/jquery.color.js
http://www.weekendphp.com/jQuery/jquery.color-min.js
ãã¢ã¯ãã¡ã
jQuery.iColor - jQueryPlugin DEMO
jQuery.iColor - jQueryPlugin DEMO