0.1.1 • Published 5 years ago

charade v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

charade

Plot signals on a canvas.

The default, and only, behaviour is to plot a sinusoidal signal, but more features may be implemented in the future. Optionally, arbitrary harmonics can be applied to the signal to be plotted.

A live demo is available here.

Usage

First select/create an HTMLCanvasElement, which must have non-zero width and height attributes, e.g.:

const canvas = document.querySelector("canvas#foo");

Then pass the HTMLCanvasElement to the constructor and run render():

const charade = require("charade");
const options = {};
charade(canvas, options).render();

A signal based on the options will be plotted to the canvas.

Options

harmonics: Number

An array of numbers representing the harmonics to include in the signal.

Each number, n, represents the n-th order harmonic of the signal.

For example, the first five harmonics:

{ harmonics: [1, 2, 3, 4, 5] }

The first-order harmonic f_1 is the fundamental frequency, the second-order harmonic f_2 is f_1 / 2, etc. Numbering starts at one, so f_0 does not correspond to a harmonic, i.e. it corresponds to 0 Hz.

scale: Number

A decimal value that represents scale factor of signal.

For example, scaling the signal to 50%:

{ scale: 0.5 }

cycles: Number

A decimal value that represents the number of cycles plotted.

For example, to show three complete cycles:

{ cycles: 3 }

Or to show a quarter-cycle:

{ cycles: 0.25 }

Copyright and License

Copyright 2019-2020 Owen Allsopp

This package is free software; you can redistribute it and/or modify it under the terms of the MIT License.

0.1.1

5 years ago

0.1.0

5 years ago

0.1.0-alpha.4

6 years ago

0.1.0-alpha.3

6 years ago

0.1.0-alpha.2

6 years ago

0.1.0-alpha.1

6 years ago