Crates.io | svg-diff |
lib.rs | svg-diff |
version | 0.0.6 |
source | src |
created_at | 2022-10-04 15:01:09.910858 |
updated_at | 2022-10-22 13:57:25.364735 |
description | Find the diff between 2 SVGs in the form of a list of operations to get transform from one SVG to the other |
homepage | https://github.com/RudolfVonKrugstein/svg-diff |
repository | https://github.com/RudolfVonKrugstein/svg-diff |
max_upload_size | |
id | 679884 |
size | 162,974 |
The purpose of this library is to find the "diff" between 2 SVGs in the form of simple operations that have to be executed to get from one SVG to the other.
The original goal is to generate animations (using some animation library like d3.js) which transition from one SVG to the other. This can be useful i.E. when making presentation with revealjs and generating diagrams with plantUML. One can generate "intermediate" Diagrams and transition between using the diffs genrate by this tool.
Of course other usages are possible, but do not have been considered by the author of this library.
For the diff between 2 SVGs the following is generated:
[{
"action": "add",
"id": "sjffk-5",
"svg": "<circle id\"sjffk-1\" ...></circle>",
"parent_id": "sjffk-3",
"prev_child_id": "sjffk-1",
"next_child_id": "sjffk-8"
},{
"action": "remove",
"id": "sjffk-2"
},
{
"action": "change",
"changes": {
"removes": ["opacity"],
"adds": [{"prop": "fill", "value": "#FF0000"}],
"changes": [{"prop": "stroke", "value": "#000000"}]
}
}]
In the examples folder there are 2 examples that demonstrate how to make SVG animations with this.
Start the examples with:
cargo run --example <exmaple-name>
and than open http://localhost:8080 in your web browser.
https://rustwasm.github.io/wasm-pack/installer/
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh