SVG自动变换2帧之间的动画

时间:2015-07-08 16:14:50

标签: animation svg

我有2个具有不同配置(平移和旋转)的相同对象的SVG图像。简化示例:

fil1.svg:

  <svg width="800" height="800">
    <rect id="r1" fill="#11CC99" x="0" y="0" width="100" height="200" 
    transform="matrix(0.8211913,-0.570653,0.570653,0.8211913,0,100)"
    />
    <circle id="c1"  fill="#99CC11"  cx="0" cy="0" r="100" 
      transform="matrix(1,0,0,1,242,100)"
    />
  </svg>

file2.svg:

  <svg width="800" height="800">
    <rect id="r1" fill="#11CC99" x="0" y="0" width="100" height="200" 
      transform="matrix(0.8211913,-0.570653,0.570653,0.8211913,30,80)"
    />
    <circle id="c1" fill="#99CC11" cx="0" cy="0" r="100"
      transform="matrix(1,0,0,1,240,300)"
    />
  </svg>

是否有一个工具(或Python的库,JS ......)自动构建第三个svg文件,动画从第一个配置开始到第二个配置?我希望生成的svg文件包含如下脚本:

<svg>
...
    <circle id="c1" fill="#99CC11"  cx="0" cy="0" r="100" 
      transform="matrix(1,0,0,1,242,100)">
      <animateTransform attributeName="transform" attributeType="XML"
        type="translate"
        from="242 100"
        to="240 300"
        begins="0s"
        dur="1s"/>
    </circle>
</svg>

和rect的类似代码。我希望坐标变换矩阵相对于动画时间是线性的。

1 个答案:

答案 0 :(得分:0)

9VAe怎么样?请参阅Six steps to make SVG Animation from Openclipart

  1. 使用9VAe打开file1.svg。
  2. 将第一页复制到第二页。
  3. 将file2.svg导入第二页。
  4. 在第二页上将file1.svg修改为file2.svg。
  5. 删除file2.svg。
  6. 导出SVG。
  7. 输出SVG如下。 (我添加了repeatCount以显示转换。)

    &#13;
    &#13;
    SET SERVEROUTPUT ON SIZE 1000000
    DECLARE
      l_cursor  SYS_REFCURSOR;
      p_count   number;
      p_error   NVARCHAR2 (255);
    M_ID        app_recipient.id%type    ;
    l_ID        app_recipient.id%type    ;
    l_master_id        app_recipient.master_id%type    ;
    l_RECIPIENT_STATUS        V_MASTER_RECIP_W_TRXN_OP2.recipient_status%type;
    l_PARENT_OR_CHILD    V_MASTER_RECIP_W_TRXN_OP2.parent_or_child%type;
    l_CHILD_COUNT    V_MASTER_RECIP_W_TRXN_OP2.child_count%type;
    l_IS_PICKABLE    app_recipient.is_pickable%type;
    l_IS_GOLDEN    app_recipient.is_golden%type;
    l_request_wf_state    app_recipient.request_wf_state%type;
    l_record_type    app_recipient.record_type%type;
    l_first_name    app_recipient.first_name%type;
    l_last_name    app_recipient.last_name%type;
    l_p_mc    app_recipient.MC14%type;
    l_middle    app_recipient.middle%type;
    l_title    app_recipient.title%type;
    l_name_of_organization    app_recipient.name_of_organization%type;
    l_name_of_business    app_recipient.name_of_business%type;
    l_address    app_recipient.address%type;
    l_city    app_recipient.city%type;
    l_state    app_recipient.state%type;
    l_country    app_recipient.country%type;
    l_HCP_TYPE    v_master_recip_w_trxn_op.HCP_TYPE%type;
    l_HCP_SUBTYPE    V_MASTER_RECIP_W_TRXN_OP.HCP_SUBTYPE%type;
    l_is_edit_locked    V_MASTER_RECIP_W_TRXN_OP.is_edit_locked%type;
    l_rec_type    V_MASTER_RECIP_W_TRXN_OP.record_type%type;
    l_DATA_SOURCE_NAME    V_MASTER_RECIP_W_TRXN_OP.data_source_name%type;
    l_DEA_DATA    V_MASTER_RECIP_W_TRXN_OP.dea_data%type;
    l_NPI_DATA    V_MASTER_RECIP_W_TRXN_OP.npi_data%type;
    l_STATE_DATA    V_MASTER_RECIP_W_TRXN_OP.state_data%type;
    l_RPPS    V_MASTER_RECIP_W_TRXN_OP.rpps%type;
    l_finess    V_MASTER_RECIP_W_TRXN_OP.finess%type;
    l_siren_number    V_MASTER_RECIP_W_TRXN_OP.siren_number%type;
    l_FULL_NAME_LNF    V_MASTER_RECIP_W_TRXN_OP.siren_number%type;
    l_FULL_NAME_FNF    V_MASTER_RECIP_W_TRXN_OP.siren_number%type;
    
    BEGIN
      hcp_360.hcp360_application.get_recipients_for_mc(p_id    => &&var,
                    p_mc        => &&p_mc,
                  p_detail  => l_cursor,
                  p_count => p_count,
                  p_error => p_error);
    
      LOOP 
        FETCH l_cursor
        INTO  M_ID  ,
    l_RECIPIENT_STATUS  ,
    l_PARENT_OR_CHILD   ,
    l_CHILD_COUNT   ,
    l_IS_PICKABLE,
    l_IS_GOLDEN,
    l_ID,
    L_MASTER_ID,
    l_request_wf_state,
    l_title,
    l_first_name,
    l_middle,
    l_last_name,
    l_FULL_NAME_LNF,
    l_FULL_NAME_FNF,
    l_name_of_organization,
    l_address,
    l_city,
    l_state,
    l_country,
    l_HCP_TYPE,
    l_HCP_SUBTYPE,
    l_is_edit_locked,
    l_rec_type,
    l_DATA_SOURCE_NAME,
    l_DEA_DATA,
    l_NPI_DATA,
    l_STATE_DATA,
    l_RPPS,
    l_finess,
    l_siren_number;
        EXIT WHEN l_cursor%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(M_ID       ||  ' | '   ||
    l_RECIPIENT_STATUS      ||  ' | '   ||
    l_PARENT_OR_CHILD       ||  ' | '   ||
    l_CHILD_COUNT       ||  ' | '   ||
    l_IS_PICKABLE       ||  ' | '   ||
    l_IS_GOLDEN     ||  ' | '   ||
    l_ID        ||  ' | '   ||
    L_MASTER_ID     ||  ' | '   ||
    l_request_wf_state      ||  ' | '   ||
    l_title     ||  ' | '   ||
    l_first_name        ||  ' | '   ||
    l_middle        ||  ' | '   ||
    l_last_name     ||  ' | '   ||
    l_FULL_NAME_LNF     ||  ' | '   ||
    l_FULL_NAME_FNF     ||  ' | '   ||
    l_name_of_organization      ||  ' | '   ||
    l_address       ||  ' | '   ||
    l_city      ||  ' | '   ||
    l_state     ||  ' | '   ||
    l_country       ||  ' | '   ||
    l_HCP_TYPE      ||  ' | '   ||
    l_HCP_SUBTYPE       ||  ' | '   ||
    l_is_edit_locked        ||  ' | '   ||
    l_rec_type      ||  ' | '   ||
    l_DATA_SOURCE_NAME      ||  ' | '   ||
    l_DEA_DATA      ||  ' | '   ||
    l_NPI_DATA      ||  ' | '   ||
    l_STATE_DATA        ||  ' | '   ||
    l_RPPS      ||  ' | '   ||
    l_finess        ||  ' | '   ||
    l_siren_number              
    
     );
      END LOOP;
      CLOSE l_cursor;
    END;
    
    &#13;
    &#13;
    &#13;