Mercurial > MadButterfly
changeset 713:e60ae262127b
Recognize color name
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 13 Aug 2010 20:41:00 +0800 |
parents | 54618e0cd36b |
children | f53e45d1fcd0 |
files | nodejs/svg.js |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/nodejs/svg.js Fri Aug 13 19:52:00 2010 +0800 +++ b/nodejs/svg.js Fri Aug 13 20:41:00 2010 +0800 @@ -8,6 +8,12 @@ paint.fill(background); mb_rt.root.add_shape(background); +var _std_colors = { + "white": [1, 1, 1], + "black": [0, 0, 0], + "red": [1, 0, 0] +}; + function MB_loadSVG(mb_rt,root,filename) { var doc = libxml.parseXmlFile(filename); var nodes = doc.root().childNodes(); @@ -120,6 +126,7 @@ function _prepare_paint_color(color, alpha) { var paint; + var c; if (color[0]=='#') { var r,g,b; @@ -127,6 +134,9 @@ g = parseInt(color.substring(3,5),16)/256; b = parseInt(color.substring(5,7),16)/256; paint = mb_rt.paint_color_new(r, g, b, alpha); + } else if(_std_colors[color]) { + c = _std_colors[color]; + paint = mb_rt.paint_color_new(c[0], c[1], c[2], alpha); } else { paint = mb_rt.paint_color_new(0,0,0,1); }