🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@harmonograph/xy

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harmonograph/xy

Generate a harmonographs X and Y coordinates

latest
Source
npmnpm
Version
0.0.0
Version published
Maintainers
1
Created
Source

@harmonograph/xy

👩‍🎨 Generate a harmonographs X and Y coordinates

Install

npm install @harmonograph/xy

Get started

The harmonograph is a mechanical apparatus that uses pendulums to create a geometric image. This function uses the drawing time, size and pendulums to create X and Y coordinates for a harmonograph.

If you wish to draw the harmonograph for use on a website you can use @harmonograph/svg or @harmonograph/canvas.

Create harmonograph XY coordinates

const generateHarmonographXY = require('@harmonograph/xy');

const harmonograph = generateHarmonographXY(
  150,
  700,
  [{
    amplitude: 200, frequency: 2.985, phase: 2.054, damping: 0.001
  },
  {
    amplitude: 200, frequency: 3.006, phase: 1.820, damping: 0.008
  },
  {
    amplitude: 200, frequency: 3.003, phase: 2.283, damping: 0.001
  },
  {
    amplitude: 200, frequency: 1.994, phase: 1.155, damping: 0.001
  }]
);

This returns an object containing an array of X and Y coordinates. When drawn these points create a harmonograph.

{
  x: [1, 2, 3],
  y: [1, 3, 9]
}

Create randomised harmonograph XY coordinates

const generateHarmonographXY = require('@harmonograph/xy');
const {randomPendulums} = require('@harmonograph/xy');

const harmonograph = generateHarmonographXY(150, 700, randomPendulums());

Options

OptionDescriptionDefault valueType
drawingTimeHow long the pendulum swings in seconds150number
sizeThe size of the svg700number
pendulumsTwo pendulums require four items ( x, y and x, y ). Each X and Y value is an object that contains amplitude, frequency, phase, and damping ( see pendulum options below )random valuesarray

Pendulums object

ParameterDescriptionDefault valueType
pendulum.amplitudeHow far a pendulum swings back and forth, must be from 0 - 360 degreesrandom numbernumber
pendulum.frequencyHow fast a pendulum swings back and forth, for best results use decimal values around 2 and 3random numbernumber
pendulum.phaseThe rate that a pendulum loses its energy, or slows down, must be from 0 to πrandom numbernumber
pendulum.dampingThe offset from the normal starting position of a pendulum, must be from 0 to 0.01random numbernumber

Release History

  • v0.0.0 - đź’Ą Initial version

Keywords

harmonograph

FAQs

Package last updated on 02 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts