npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mesh-to-svg

v2.1.6

Published

![Example](/doc/raspi.svg)

Downloads

58

Readme

Mesh to SVG

Example

WASM Library (written in Rust 🦀) to convert meshes (optionally with supplemental wireframe mesh) into an SVG line drawing

It is recommended to use https://github.com/zakhenry/svg-from-wireframe which wraps this library in a more ergonomic interface, and provides demos for how to integrate with webworkers in Angular.

Installation

$ yarn add mesh-to-svg

Contributing

Setup

Clone this repo

$ git clone [email protected]:zakhenry/mesh-to-svg.git

Ensure you have a rust toolchain set up, if not:

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Install wasm-pack (the tooling for making WASM modules with Rust)

$ curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

Fetch deps (this can be skipped as wasm-pack will do this too)

$ cargo build

Build

$ wasm-pack build -- --features console_log

or use the handy yarn helper if you're more familiar with frontend tooling

$ yarn wasm:build:debug

To do a release build (way faster to run, but runtime errors are less helpful)

$ wasm-pack build --release -- --features console_log

or use the handy yarn helper if you're more familiar with frontend tooling

$ yarn wasm:build:release

Link package

Link npm package so other repos can use this module

$ cd pkg && yarn link

Link from your other package

$ cd path/to/your/other/repo
$ yarn link mesh-to-svg

You only have to do this once (it sets up symlinks)

Now you can just rebuild this project, and if you have a file watcher on the other project (the default for Angular for example) when you rebuild the wasm binary the webpage will automatically reload with the latest code.

Releasing a package

Package releases are all done automatically by semantic-release and TravisCI.

Please follow the semantic commit guidelines so your commit messages will automatically generate the changelog and the correct semver.

Issues & PRs

Please raise issues for features you'd like to see, issues encountered etc. PRs are always welcome, I really want to learn how to make this package better, faster, stronger!

Tips

Debug with the log!() macro. It takes the same form as print!(), i.e.

log!("Hello world, 1 + 1 is {res}", res = 1 + 1);

You will see the output in the browser console. If an object that is logged implements the Display trait, it will be logged prettily (e.g. vectors, matrices etc all look good).

Calling log!() is super slow. Any performance benchmarks you may do with logging will be seriously polluted by the calls out to JS.

As such console_log is an optional feature, which is turned off for the release build

Run a build with the feature console_log turned off:

wasm-pack build --release

or

$ yarn wasm:build:prod

Running Binary

Output svg

$ cargo run --example mesh-to-svg --release -- --file meshes/raspi.json > test.svg

Output to console

$ cargo run --example mesh-to-svg --release -- --file meshes/raspi.json term
      Finished release [optimized] target(s) in 0.06s
       Running `target/release/examples/mesh-to-svg --file meshes/raspi.json term`
                                                                   
                                                                   
                                         ⢀⡤⢤⣤⡤⣄⡀                   
                                         ⣼⡀⠑⠒⣃⣀⣹                   
                                         ⡇⣷⠒⠒⡇ ⣿⠒⠢⢤⣀               
                                         ⣇⣿  ⡇ ⠑⢲⢄⣠⡔⢳              
                                   ⢀⣀⣤⡴⠶⣛⣝⣋⣤⡤⢋⡭⡍⠛⠢⣻⢷⡉⠑⠢⣀           
                              ⣀⡠⣤⣶⣚⡫⠭⠒⠊⠉ ⡇  ⢹⣷⠿⣷⡏⠉⠉⢱⠈⠑⠤⣀⠉⠢⢄⡀       
          ⢀⣀⠤⢄⣀⡀        ⢀⣀⢤⣔⢮⡽⠖⠋⠉     ⢀⣀⠤⠧⠤⣤⠼⠃⢠⣿⣇⣀⣀⣸    ⠑⠢⡶⣚⣊⣉⣒⣤   
   ⡤⢖⣒⣒⠦⠔⠉⢁⣀⠤⠤⠔⠊⡇  ⣀⣠⣤⢶⡽⠷⠛⠉⠉⠁     ⡠⠔⠒⠉⣁⣔⡲⢮⠝⠤⡄ ⣷⡋   ⠈⠢⢄⡀⣠⢤⣯⣊⠉⠁⢠⣖⣮⢑⡆ 
   ⡗⣮⠭⢍⣀⡤⡎⠁     ⡷⡾⠿⠛⠓⠊⠁    ⢀⣀⠤⠔⠒⣉⡩⠤⢲⡞⠋⠉  ⣸⣀⣰⠁⡴⠒⡯⠭⢭⣭⠭⣭⠭⡭⣧⣼⡇⢸⢹⠉⡟⠒⠚⠉  
   ⡇⣿⣀  ⡇⡇      ⠉    ⢀⣀⠤⠤⠒⢉⣁⠤⠒⠊⢩⠴⢲⠤⠤⠭⠭⠭⠵⠿⢶⣖⠋⡀⣇⡤⢇⣀⣿⢹⠒⡬⢲⠯⠟⠒⢉⣉⢾ ⡇   ⡀ 
   ⡇⡷⣄⠉⠉⠓⢧⠔⠒⢯⡇  ⢀⣀⠤⠤⢊⣁⢤⡴⠶⠛⠋⢹⠉⡹⠂⢸⣀⣸⣀⣀⣀⡠⢄⡠⠔⠚⠉⠉⢘⢧⣤⡶⠿⠯⠼⣀⡇⠸⠤⠒⠉⠁ ⠘⠒⢳⠒⠒⡏⠁ 
   ⠙⡇⢸⠒⡎⡏⢹⣿⣻⣤⣗⣒⣫⣥⣔⠒⠉⠁⠸⠧⣀⣀⣀⣤⣚⣒⡇⢠⣻⢡⣒⡊⠉⢀⡠⠔⠚⠲⠒⠒⠊⠁⢸⢀⣀⠤⠔⠒⠉    ⣀⣠⢤  ⢸ ⢠⠇  
    ⡇⢸ ⠫⡉⠉⠓⢿⡽⡤⣇⢀⣀ ⠉⠉⠉⡏⡇⢠⠚⣹⠒⠒⠒⠒⠒⠚⢻⡇⡏⡎⠁        ⠈⠁   ⣀⡠⣤⣒⠮⣍⡀⠙⣼ ⣀⠼⠴⠋   
    ⡇⢸  ⠈⠑⠒⢄⠈⢹⠷⡋ ⠑⠲⢖⠒⡗⠓⠊⠉⠘⢤⣤⡤⢤⡶⠶⠿⠳⢇⡇        ⢀⣀⠤⠔⣶⠛⠊⠉⣀⠼⣒⠶⠕⡞⠙⠉       
    ⢧⢸      ⠉⠚ ⠈⢱⢤⣀⣀⢹⢳⢤⣛⣛⣣⠞⡗⠊⠁⣀⠤⠔⠒⠉    ⣀⠤⠔⠒⢩⠗⠒⣦ ⢙⠶⠶⠛⠊⠉   ⣇⡤        
    ⠈⠛⠢⢄        ⢸   ⢹⢸     ⡗⠊⠉   ⣀⡠⠤⢒⣊⠭⢴⠛⣲⢄⣈⠭⠝⠓⠉⠁  ⢀⣀⠤⠔⠒⠉⠁         
        ⠉⠢⢄     ⢸   ⢸⣸    ⣰⠁⢀⣤⣒⣊⠉ ⢿⣉⣁⣠⡴⠮⠋⠉⠁   ⣀⡠⠤⠒⠊⠁               
           ⠉⠒⢄⡀ ⢸    ⠈⠉⠑⠚⡏⠁ ⢸  ⠈⡏⠓⠒⠒⡏   ⢀⣀⠤⠔⠊⠉                     
              ⠈⠒⢼        ⣇⣀⠤⠼⠤⠤⠤⣇⣀ ⣀⡧⠔⠒⠉⠁                          
                 ⠉⠑⠒⠒⠒⠒⠒⠒⠁        ⠉⠁                               
                                                                   

Animate to console

cargo run --example mesh-to-svg --release -- --file meshes/raspi.json term --animate
    Finished release [optimized] target(s) in 0.05s
     Running `target/release/examples/mesh-to-svg --file meshes/raspi.json term --animate`
Rendered 13 of 50 angles (806.828564ms)

                                                                 
                                                                 
                     ⢀⣠⠤⠤⢤⣀                                      
                 ⣀⣠⠤⠤⣏⡀⠛⠛⠃⢸⡇                                     
               ⢰⠫⣄⣀⢤⠔⠃⠈⡟⠒⡜⡇⡇                                     
             ⣀⠤⣊⢵⠿ ⡸⢖⣒⡒⠧⢄⡷⡷⠷⣒⠤⡴⢖⡉⡝⢳                              
      ⢀  ⣀⠤⣒⠭⣒⠭⠒⠁⡟⠛⢲⣬⣷⣥⡖⠋⠉⢻⠑⠒⠭⠇ ⢸⣇⠼⡀ ⢀⣀⡠⠤⢄⡀                      
 ⡔⢪⣭⣭⠉⠙⠲⠿⣔⢭⠒⠉    ⣇⣀⢸⣟⡄⢏⡇⣀⣀⣸     ⠈⠙⠭⣚⣵⡏⠑⠤⣀⡀⢈⡵⠦⠒⠢⢄⣀                
 ⡏⠓⠒⠒⡖⣶⡏⢹⢸⢿⣀ ⣀⠤⠒⠉ ⠈⠉⠻⡇⢸⠉  ⠈⠒⠒⢄⡀    ⣦⠤⡁   ⠈⠙⠈⠉⠒⠤⣀⢀⡝⡆              
 ⡇   ⡇⣿⡇⢸⣼⣣⣼⣿⠶⢶⢶⠒⠒⠒⢒⡯⡥⠤⠭⠭⠭⡭⢭⠉⣩⢭⠛⠛⠛⠛⠓⠒⠚⠓⡖⣦⢄      ⣿⡇⡇              
 ⡇   ⡇⡿⣓⠒⠫⢗⣫⢾⠤⢼⢸⠉⠒⠢⠬⢗⣓⠢⢄⣀⣀⣇⣸⡇⢣⣸⣀⣀⣀⣀⣀⣀⣀⣀⣇⣿ ⣩⠖⠶⡄  ⠻⢯⠵⣢⠤⣀ ⡴⣒⠉⠉⢹⣛⡯⢙⡆ 
 ⠈⠑⠒⢲⠓⠃ ⠉⠒⠒⢄⡉⠛⠵⣫⣖⡤⣀⡀  ⠉⠒⠬⣑⠒⠛⠁⢸⡀         ⣸⡇⢇⣀⣀⡇    ⠉⠒⠭⣒⣭⡇ ⣿⠒⠒⠒⢺⡏⡇ 
  ⢠ ⢸  ⢠⣤⣀  ⠈⠑⠒⠤⣈⠙⠫⠾⣵⣒⡤⣀⡀ ⠉⠒⠢⢤⠉⠉⠉⣭⢽⠛⠛⠛⠛⢻⠳⡄⢸  ⠈⠑⠒⠤⣀  ⢀⣯⠗⢒⣤⠟⠉⠉⢉⣽⡇⡇ 
   ⠳⠼⢄⡀⡼⠚⢀⣉⣒⣢⣄⡀  ⠉⠑⠢⠤⣉⠚⠳⢮⡵⣢⠤⣀ ⠉⠉⢢⣼⠛⠒⠢⢄⣀⣸⣀⣿⠈⢓⣦⣤⣤⣤⣤⣤⣭⣒⣺⣤⠯⣅⡀⢀⡠⠔⡏⢸⠷⠃ 
      ⠈⡗⡦⢜⣤⠤⣇⡈⠙⠫⢖⠤⣀⡀  ⠉⠒⠢⢌⣉⠛⠶⣫⣕⡢⢼⠉⠑⠒⠤⡀⠈⠑⠚⠭⣀⡏⢸      ⣸⣴⣿⠤⢇⣸⠁  ⡇⢸   
       ⣇⡇  ⠉⠒⠪⢵⡤⠼⠃⢀⣈⣑⡢⠤⣀   ⠉⠒⠤⢌⡙⢻    ⣿⣀⠶⠶⢆⡠⣗⣊⠭⠛⠯⣽⠿⠛⠉⣁⠤⠤⠒⠉   ⡇⢸   
       ⠈⠉⠑⠢⠤⣀  ⠈⠑⠒⠽⢶⣖⠋⢀⣠⠭⡖⠢⢄⡀  ⠈⠉    ⡇⠈⠉⠉⠉⡇⣇⣀⣠⠤⢶⠊⡧⠒⠉        ⡇⢸   
             ⠉⠒⠢⢄⡀   ⠑⠪⠧⣄⡏⠑⠢⢌⣉⡒⠤⣀⡀   ⡇    ⡇⡇   ⢸           ⢀⠷⠁   
                 ⠈⠉⠒⠤⣀⡀  ⠉⠑⠲⣒⣚⣋⣀⡤⠬⠵⢦ ⢧⣀  ⢀⡧⡇   ⢸       ⢀⡠⠔⠊⠁     
                      ⠈⠑⠢⠤⣀ ⡇   ⡇  ⢸  ⢸⠉⠉⠁     ⢸   ⢀⡠⠔⠊⠁         
                           ⠉⠣⠤⠤⠴⠓⠋⠉⠚⠒⠤⢼        ⢸⡠⠔⠊⠁             
                                       ⠉⠑⠒⠒⠒⠒⠊⠉⠁                 
                                    

CTRL+C to exit