Mercurial > MadButterfly
changeset 810:84853c8559cf
Support opacity on coords
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 02 Sep 2010 10:59:02 +0800 |
parents | e21ccbc4afb1 |
children | 5aca6024b147 |
files | nodejs/coord.cc nodejs/coord.m4 nodejs/svg.js |
diffstat | 3 files changed, 49 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/nodejs/coord.cc Wed Sep 01 21:51:13 2010 +0800 +++ b/nodejs/coord.cc Thu Sep 02 10:59:02 2010 +0800 @@ -256,6 +256,20 @@ rdman_coord_changed(rdman, coord); } +static void +xnjsmb_coord_set_opacity(coord_t *coord, Handle<Object> self, + float opacity) { + Handle<Object> js_rt; + redraw_man_t *rdman; + + js_rt = GET(self, "mbrt")->ToObject(); + ASSERT(js_rt != NULL); + rdman = xnjsmb_rt_rdman(js_rt); + + coord_set_opacity(coord, opacity); + rdman_coord_changed(rdman, coord); +} + #include "coord-inc.h" /*! \brief This function used by \ref xnjsmb_mb_rt to wrap coord object.
--- a/nodejs/coord.m4 Wed Sep 01 21:51:13 2010 +0800 +++ b/nodejs/coord.m4 Thu Sep 02 10:59:02 2010 +0800 @@ -4,7 +4,9 @@ (SELF, OBJ([shape], [shape], [shape_t]), ERR), 1, []), METHOD([remove], [xnjsmb_coord_remove], (SELF), 0, []), METHOD([show], [xnjsmb_coord_show], (SELF), 0, []), - METHOD([hide], [xnjsmb_coord_hide], (SELF), 0, [])], + METHOD([hide], [xnjsmb_coord_hide], (SELF), 0, []), + METHOD([set_opacity], [xnjsmb_coord_set_opacity], + (SELF, NUMBER([opacity])), 1, [])], ((GET_INDEX, (coord_get_index, NUMBER)), (SET_INDEX, (coord_set_index, NUMBER)), ([STMOD], [xnjsmb_coord_mod])))
--- a/nodejs/svg.js Wed Sep 01 21:51:13 2010 +0800 +++ b/nodejs/svg.js Thu Sep 02 10:59:02 2010 +0800 @@ -491,6 +491,29 @@ // Each element must be responsible to calculate its absolute origin // point and update the origin of its parent. +function parseGroupStyle(style,n) +{ + var attr; + if (n) { + attr = n.attr('style'); + } else { + attr = null; + } + if (attr == null) { + return; + } + var f = attr.value().split(';'); + + for(i in f) { + var kv = f[i].split(':'); + if (kv[0] == 'opacity') { + style.opacity = parseFloat(kv[1]); + } else { + sys.puts("Unknown style: "+kv[0]); + } + } +} + loadSVG.prototype.parseGroup=function(accu_matrix,root, group_id, n) { var k; var nodes = n.childNodes(); @@ -498,6 +521,8 @@ // Parse the transform and style here var trans = n.attr('transform'); var accu=[1,0,0,0,1,0]; + var style; + coord.center= new Object(); coord.center.x = 10000; coord.center.y = 10000; @@ -507,6 +532,13 @@ multiply(accu,accu_matrix); multiply(accu,coord); + style = {}; + parseGroupStyle(style, n); + if(style.opacity) { + sys.puts(style.opacity); + coord.set_opacity(style.opacity); + } + for(k in nodes) { var c = nodes[k].name(); var attr = nodes[k].attr('id');