Skip to content
Proyek

Tentang

:cake: bit field diagram renderer

Desain dan media

Cara angka ini diukur

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
0
dalam 15 hari
+1
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

NPM version Linux MacOS Windows Coverage Status

Install

npm i bit-field

Library usage

const render = require('bit-field/lib/render');
const onml = require('onml');

const reg = [
  {bits: 8, name: 'data'}
];

const options = {
  hspace: 888
};

const jsonml = render(reg, options);
const html = onml.stringify(jsonml);
// <svg...>

JSON Schema

lib/schema.js is the JSON Schema (draft-07) of the {reg: [...], config: {...}} input. It is part of the WaveDrom schema.

const Ajv = require('ajv');
const schema = require('bit-field/lib/schema.js'); // or require('bit-field').schema
const validate = new Ajv().compile(schema);
validate({reg: [{bits: 8, name: 'data'}]}); // true

CLI Usage

npx bit-field [options] > alpha.svg

options

Options:
      --version     Show version number                                [boolean]
  -i, --input       path to the source                                [required]
      --vspace      vertical space                        [number] [default: 80]
      --hspace      horizontal space                     [number] [default: 640]
      --lanes       rectangle lanes                        [number] [default: 2]
      --bits        overall bitwidth                      [number] [default: 32]
      --fontsize    font size                             [number] [default: 14]
      --fontfamily  font family                          [default: "sans-serif"]
      --fontweight  font weight                              [default: "normal"]
      --compact     compact format                    [boolean] [default: false]
      --hflip       horizontal flip                   [boolean] [default: false]
      --vflip       vertical flip                     [boolean] [default: false]
      --trim        trim long names                                     [number]
      --offset      offset the index lanes                              [number]
      --help        Show help                                          [boolean]

alpha.json

[
    { "name": "IPO",   "bits": 8, "attr": "RO" },
    {                  "bits": 7 },
    { "name": "BRK",   "bits": 5, "attr": "RW", "type": 4 },
    { "name": "CPK",   "bits": 1 },
    { "name": "Clear", "bits": 3 },
    { "bits": 8 }
]

alpha.svg

Heat Sink

Online Examples

https://observablehq.com/collection/@drom/bitfield

Jelajahi proyek terkait

Memuat…