Skip to content

Fourier Transform Files are files that aim to encode simple vector image data

License

Notifications You must be signed in to change notification settings

Maxty99/FTFiles

Repository files navigation

FTFiles

Npm Downloads


Fourier Transform Files are files that aim to encode simple vector image data. The goal of this library is to provide a way to take a svg file with a single svg path. Then it will calculate and re-encode it into a set of coefficients that apply to a complex fourier series.

Usage

This can be done client side the following way:

import { FTProcessor } from 'ftfiles';

// Create a SVGProcessor instance
const ftProc = new FTProcessor(path); // Path must be an SVGPathElement

ftProc.processPoints(numberOfPoints); // Doing discrete integration basically, you have to do this before transforming
ftProc.dft(); // Does the transformation

ftProc.getCoefficients(); // used to retreive the coefficients of the series

Then the coefficients can be read in order to draw it with the drawing module

import { FTDrawer } from 'ftfiles';

// Say we already have coefficents (be it serialized and sent from backend, calculated client side)
const coefficients = ftProc.getCoefficients();

const drawer = new FTDrawer(coefficients);
drawer.setCanvas(canvas); // Set the canvas to which to draw (Param must be Canvas element)
drawer.setScale(1); // Set the scale at which to draw
drawer.draw(); // Draws

Heres a sample repo using this library: https://github.com/Maxty99/FTFileWeb

Thanks

About

Fourier Transform Files are files that aim to encode simple vector image data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published