Dart SVG Translate an object

前端 未结 1 500
刺人心
刺人心 2021-01-22 17:39

I\'m trying to translate an ellipse in SVG with Dart. I haven\'t found any explanation on how to do that, other than the SetAttribute way



        
1条回答
  •  鱼传尺愫
    2021-01-22 18:22

    I successfully tried

    ellipse.setAttribute('transform', 'translate(150, 150)');
    

    if you create the transform attribute using setAttribute then the following is working too

    ellipse.transform.baseVal.first.setTranslate(20, 100);
    

    or you can add a Transform as shown in the answer to this question Dart create and transform an SVG path

    Matrix m = new svg.SvgSvgElement().createSvgMatrix();
    Matrix m2 = m.translate(50, 50);
    Transform tr = ellipse.transform.baseVal.createSvgTransformFromMatrix(m2);
    ellipse.transform.baseVal.appendItem(tr);
    

    You can set the color with

    ellipse.style.setProperty('fill', '#07f');
    

    0 讨论(0)
提交回复
热议问题