comparison nodejs/svg.js @ 810:84853c8559cf

Support opacity on coords
author Thinker K.F. Li <thinker@codemud.net>
date Thu, 02 Sep 2010 10:59:02 +0800
parents 9b6c26cf9102
children 2a73ff24c141
comparison
equal deleted inserted replaced
809:e21ccbc4afb1 810:84853c8559cf
489 // matrix so that each group can get their origin correctly. 489 // matrix so that each group can get their origin correctly.
490 // 490 //
491 // Each element must be responsible to calculate its absolute origin 491 // Each element must be responsible to calculate its absolute origin
492 // point and update the origin of its parent. 492 // point and update the origin of its parent.
493 493
494 function parseGroupStyle(style,n)
495 {
496 var attr;
497 if (n) {
498 attr = n.attr('style');
499 } else {
500 attr = null;
501 }
502 if (attr == null) {
503 return;
504 }
505 var f = attr.value().split(';');
506
507 for(i in f) {
508 var kv = f[i].split(':');
509 if (kv[0] == 'opacity') {
510 style.opacity = parseFloat(kv[1]);
511 } else {
512 sys.puts("Unknown style: "+kv[0]);
513 }
514 }
515 }
516
494 loadSVG.prototype.parseGroup=function(accu_matrix,root, group_id, n) { 517 loadSVG.prototype.parseGroup=function(accu_matrix,root, group_id, n) {
495 var k; 518 var k;
496 var nodes = n.childNodes(); 519 var nodes = n.childNodes();
497 var coord = this.mb_rt.coord_new(root); 520 var coord = this.mb_rt.coord_new(root);
498 // Parse the transform and style here 521 // Parse the transform and style here
499 var trans = n.attr('transform'); 522 var trans = n.attr('transform');
500 var accu=[1,0,0,0,1,0]; 523 var accu=[1,0,0,0,1,0];
524 var style;
525
501 coord.center= new Object(); 526 coord.center= new Object();
502 coord.center.x = 10000; 527 coord.center.x = 10000;
503 coord.center.y = 10000; 528 coord.center.y = 10000;
504 if (trans!=null) { 529 if (trans!=null) {
505 parseTransform(coord, trans.value()); 530 parseTransform(coord, trans.value());
506 } 531 }
507 multiply(accu,accu_matrix); 532 multiply(accu,accu_matrix);
508 multiply(accu,coord); 533 multiply(accu,coord);
534
535 style = {};
536 parseGroupStyle(style, n);
537 if(style.opacity) {
538 sys.puts(style.opacity);
539 coord.set_opacity(style.opacity);
540 }
509 541
510 for(k in nodes) { 542 for(k in nodes) {
511 var c = nodes[k].name(); 543 var c = nodes[k].name();
512 var attr = nodes[k].attr('id'); 544 var attr = nodes[k].attr('id');
513 var id; 545 var id;