Git Product home page Git Product logo

wavedrom's Introduction

YoWASP WaveDrom package

This package provides a self-contained WaveDrom renderer for JavaScript and Python applications. See the overview of the YoWASP project for details.

Command-line tool

This package installs a command-line tool yowasp-wavedrom.

Usage: yowasp-wavedrom [<input.json>] [<output.svg>]

API reference (JavaScript)

The @yowasp/wavedrom package has one entry point, render(source): string. It accepts a JavaScript object in the WaveJSON format and returns an SVG image serialized as a string:

import { render } from '@yowasp/wavedrom';

console.log(render({signal: [{ name: "clk", wave: "p..." }, { name: "data", wave: "01.0" }]}));
// => <svg.../svg>

API reference (Python)

The yowasp-wavedrom package has one entry point, render(source) -> str. It accepts a Python dictionary in the WaveJSON format and returns an SVG image serialized as a string:

from yowasp_wavedrom import render

print(render({"signal": [{ "name": "clk", "wave": "p..." }, { "name": "data", "wave": "01.0" }]}))
# => <svg.../svg>

Implementation notes

This package embeds the upstream WaveDrom library bundled with the minimal amount of dependencies necessary to produce a serialized SVG, and, for the Python package, with a JavaScript runtime. In addition, the output is post-processed compared to the upstream library as follows:

  • The id attribute of the root <svg> element is removed.
  • The stylesheets are altered to take into account dark color scheme preference via media queries. If the user agent reports dark color scheme preference, the colors in the diagram are inverted.
    • In case of the dark waveform diagram skin, this will cause it to use light colors.
    • When the SVG image is embedded in an HTML document using the <img> tag, the color scheme preference can be set per-image using a CSS rule such as img { color-scheme: light; }. This can be used to make the images responsive to dynamic theming, or simply to override the default behavior.
  • Several otherwise blocking bugs are worked around.

Updates

Unlike most YoWASP packages, this package does not automatically track upstream releases. Please open a pull request bumping the version of wavedrom in package-in.json if you need a feature from a newer version of WaveDrom.

License

This package is covered by the MIT license.

wavedrom's People

Contributors

whitequark avatar

Stargazers

Jevin Sweval avatar  avatar Kayla Firestack avatar  avatar Seonghyun Park avatar

Watchers

 avatar Jevin Sweval 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.