Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vislib #16

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

vislib #16

wants to merge 8 commits into from

Conversation

blairfrandeen
Copy link
Collaborator

  • move visualizer to library (WIP)
  • Finish visualizer library conversion

Basic library functionality for visualizer achieved! Currently only
builds a static hologram. Lots of code clean-up needing to be taken
care of, and re-implementation of animations is still work to go.
Fix all warnings. Re-implement single animated SVGs. Fix and/or rewrite
unit tests, integration tests and benchmarks. Clean up comments and add
some documentation for the public functions.

Did not re-implement the multi-svg animations; I do not know that there
is a good use case for this. Nonetheless, the code remains commented
out, although maybe better to delete if we aren't going to use it.

The main.rs file is now more of a demo than anything, but still works
with command line arguments:
```
Usage: holoviz [OPTIONS] <INPUT_SVG> <OUTPUT_SVG> [DURATION]

Arguments:
  <INPUT_SVG>   Input file: expects a .svg with circles
  <OUTPUT_SVG>  Output file: expects .svg
  [DURATION]    Animation duration in seconds [default: 2]

Options:
  -a, --animate  Animate the output
  -h, --help     Print help
  -V, --version  Print version
```
I had issues getting the visualizer to import properly into the web
framework, so I had to go back and make this a full library. I did the
following to make this happen:

- Rename _visualizer.rs_ to _lib.rs_
- Move the `#![feature(test)]` flag to the top of _lib.rs_
- Move _src/main.rs_ to _src/bin/vis_cli.rs
- Move everything from _src/cli.rs_ to _src/bin/vis_cli.rs_
- Delete _src/cli.rs_
- Fix imports & warnings
- Fix doctests now that they are actually being compiled (currently
        these are not running)

The CLI can still be run:
```
cargo run --bin vis_cli -- --help
```
Fixed animated arcs so they stay along a circular path. The SVG below
demonstrates the before (red) and after (green) effect of this. This was
accomplished by interpolating a variable number of points between
animation frames. The interpolation is done by angle to create a smooth
effect.

Some refactoring was done in the process. The long-term path should be
to replace the `Point` struct with a `glam::Vec2` for better
interoperability.

Fixed stylesheet to always have black background while I was at it.

```svg
<svg height="500" width="500" xmlns="http://www.w3.org/2000/svg">
<style>
svg {
    background-color: black;
}
circle.inputCircle {
    stroke: white;
    fill-opacity: 0;
}

path.outputArc {
    stroke: green;
    fill-opacity: 0;
}

</style>
<svg viewBox="0 0 300 200" xmlns="http://www.w3.org/2000/svg" x="-200" y="-150" width="100%">
<circle class="inputCircle" cx="120" cy="100" r="80" stroke-width="0.3"/>
<path class="outputArc" stroke-width="2">
<animate attributeName="d" dur="4" repeatCount="indefinite" values="M175.30815 157.80145 A80 80 0 0 1 171.67628 161.07013;M179.01257 154.01404 A80 80 0 0 1 175.60501 157.51593;M182.45819 149.98975 A80 80 0 0 1 179.28989 153.70947;M185.62991 145.7462 A80 80 0 0 1 182.71475 149.66748;M188.5138 141.30205 A80 80 0 0 1 185.86456 145.40768;M191.09723 136.67676 A80 80 0 0 1 188.72556 140.94873;M193.36884 131.89063 A80 80 0 0 1 191.28513 136.31021;M195.31871 126.964645 A80 80 0 0 1 193.53207 131.51245;M193.36884 131.89063 A80 80 0 0 1 191.28513 136.31021;M191.09723 136.67676 A80 80 0 0 1 188.72556 140.94873;M188.5138 141.30205 A80 80 0 0 1 185.86456 145.40768;M185.62991 145.7462 A80 80 0 0 1 182.71475 149.66748;M182.45819 149.98975 A80 80 0 0 1 179.28989 153.70947;M179.01257 154.01404 A80 80 0 0 1 175.60501 157.51593;M175.30815 157.80145 A80 80 0 0 1 171.67628 161.07013"/>
</path>
<path stroke-width="2" stroke="red">
<animate attributeName="d" dur="4" repeatCount="indefinite" values="M175.30815 157.80145 A80 80 0 0 1 171.67628 161.07013; M195.31871 126.964645 A80 80 0 0 1 193.53207 131.51245; M175.30815 157.80145 A80 80 0 0 1 171.67628 161.07013"/>
</path>
</svg>
</svg>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant