Coder Social home page Coder Social logo

dmi2svg's Introduction

dmi2svg

This library uses the contour_tracing library to turn a DMI file into a set of SVGs, one for each icon state.

The purpose of this library is primarily for integration into rust_g as a way to create SVG assets for Space Station 13 clients, however it can be used with two standalone binaries in src/bin.

dmi2css allows you to invoke the library and write the output into a CSS file directly as embedded data-uris, in this format:

.spritesheet_name.state_name{background-image: url("data:image/svg+xml;base64,...")}

Parallelism

This library uses rayon to process all icon states in parallel.

Additionally, each color within an icon state is processed in parallel, which is a huge boost to performance.

To explain, the contour_tracing library requires a greyscale image in order to do it's tracing, specifically a Vec<Vec<i8>> for each pixel.

This means that to support multi-color sprites, we have to run the algorithm for each unique color present in an icon state and coalesce them into different <path> elements, with the fill attribute set to the original color.

However, this limitation actually ends up working in our benefit; because we have full control over the processing, we can use rayon again to process every path in parallel and just collect them into one string at the end. This is by far the best increase to performance, as it means that we can 'render' multiple parts of the state at once.

dmi2svg's People

Contributors

tigercat2000 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.