Git Product home page Git Product logo

fourier's Introduction

An Interactive Introduction to Fourier Transforms

This is the source code for jezzamon.com/fourier

Understanding this code

This webpage is coded in JavaScript, using Webpack, a tool that merges all the JS files into one and translates it into something compatible with older browsers. It uses npm to install dependencies and run the build scripts.

It uses some features of modern JavaScript like classes that might not be too familiar to you if you've only done intro JavaScript, but don't let that phase you too much! All the interactivity and graphics is just done with raw JS, no graphic libraries or anything like that.

Where the interesting files are

The content of the page is written in Markdown, in content/content.md. That file gets converted into HTML when the website is built in script/make-html.js). (If you would like to create a translation for a new language, there are instructions in content/)!

The code for all the interactive elements on the page is under the js/ folder. Each interactive element has a 'controller' that handles updating and rendering that element (e.g. EpicyclesController). There's something that I called a conductor that handles events and passes them on to each controller. Then they're all created and linked to elements on the page in main.js.

The actual Fourier transform is done in just-fourier-things.js, which is really a wrapper over the fft.js library. Sound synth is done in synth.js, using the Web Audio API.

To generate the images used for the JPEG section, I used Python and a Jupyter notebook. That's in python/dct.ipynb, and it's fairly readable itself.

Installing stuff

If you're curious about playing with the code yourself, you'll need to install npm. You can then run npm install to install all the dependencies. Once that's done, you can run npm run watch to start a script that will listen for file changes and rebuild everything, and npm run reload to launch a webserver that reloads the page whenever anything changes :) (warning though: I haven't tried to build things on Windows so not sure how some of the scripts will run there)

If you want to mess with the python stuff, you'll need jupyter, as well as NumPy, PIL, SciPy and Matplotlib. I recommend using Anaconda to install all that.

fourier's People

Contributors

a339388 avatar absmj avatar awillemant avatar dependabot[bot] avatar eatchangmyeong avatar jcponce avatar jezzamonn avatar jgorczynski avatar jonirousu avatar nothehi avatar omarshehata avatar re4388 avatar richoux avatar stopa avatar straaths avatar virtualwiz avatar ye11owmonster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fourier's Issues

Bug in "draw your own wave", when moving harmonic slider then redrawing wave

If you move the harmonic-count slider to the left and redraw the wave, the slider moves to the right. If you press Play right after redrawing the wave, the harmonics are there. If you keep spamming Play as the right side of the image animates into a filtered wave, the quieter (not necessarily upper) harmonics gradually fade into silence.

How to generate such kind of Fourier style GIF?

Question

  • I am deeply attracted by your profile GIF,like the one at the bottom of your post
  • Wondering how do you implement it?Could you share some ideas,or online tool to generate such sort of things

email-text causes problem in translated content

Just noticed that in both translations (german and spanish) in the second to last paragraph the span "email-text" inserts english text ("email me at ...@..., or"). Can this be fixed by special span ids for each language or by editing the inserted text to be just your email address?
Also "homepage" is capitalsed in german.

Sound stops working / AudioContext object stays open blocking resources

thanks for the very nice demo.
I ran into an audio Problem trying the different buttons:

synth.js:23 Uncaught DOMException: Failed to construct 'AudioContext': The number of hardware contexts provided (6) is greater than or equal to the maximum bound (6).
at playSoundWave (http://www.jezzamon.com/fourier/main.bundle.js:1051:24)
at HTMLButtonElement. (http://www.jezzamon.com/fourier/main.bundle.js:1442:36)
playSoundWave @ synth.js:23
(anonymous) @ main.js:59

it seems the number of open AudioContext's allowed varies. to test I used a connditional breakpoint to close them 100 ms after the decay ends:
window.setTimeout(() => audioContext.close(), decay*1000+100) && 0

Im not sure if closing the contexts or reusing one would be the better Route, its probably just a matter of style.

Feature request: pixelated images

As one who studied signal processing, I disagree with the way the JPEG wavelets and the cat image are displayed. They shouldn't be displayed resampled but pixelated because only the values at integer coordinates matter.

This can be achieved with these extra CSS rules:

        image-rendering: -moz-crisp-edges;         /* Firefox */
        image-rendering:   -o-crisp-edges;         /* Opera */
        image-rendering: -webkit-optimize-contrast;/* Webkit (non-standard naming) */
        image-rendering: crisp-edges;
        -ms-interpolation-mode: nearest-neighbor;  /* IE (non-standard property) */

Image

Crisp image

No modulenamed 'svgpathtools.svg2paths'

I've installed the dependencies from the requirements.txt but when executing svg2pasths_ext.py I get this error
Traceback (most recent call last): File "C:\Users\vcand\Desktop\FourierFromSVG-master\svg2paths_ext.py", line 9, in <module> from svgpathtools.svg2paths import polyline2pathd ModuleNotFoundError: No module named 'svgpathtools.svg2paths' PS C:\Users\vcand\Desktop\FourierFromSVG-master>

Any help?
(I have no previous knowledge of Python so help is really appreciated)

How to make fourier transform gif from svg?

Hi. One day, I saw the video of 3blue1brown and I thought I really want to make this animation. I found that, I found yours . but there was no simple svg to animation converter for the person like me. And I started to think I didn't even finished scratch guidebook. is that hard? ( https://www.youtube.com/watch?v=xXwQ0UUu-ww ) even this student doing? I searched more, And I found p5 code drawing fourier. It loads svg from gist but I have no idea to switch to my svg. I can't even upload pure svg link on web. like this ( https://gist.githubusercontent.com/mbostock/a4fd7a68925d4039c22996cc1d4862ce/raw/d813a42956d311d73fee336e1b5aac899c835883/fourier.svg ) I draw the star via inkscape, that also doesn't work. Is my svg is wrong or this isn't place for someone wants just interesting animations? Please help me

Labels in diagrams don't get translated

A few of the labels use English text in the Javascript, so these don't get translated properly in the translations. Would be good to set up something so they do get translated

Grid not HiDPI compatible

img-component-container is not HiDPI compatible.

Normally:
Imgur

HiDPI (can be emulated by scaling the browser to 200% zoom):

Imgur

The tiles get more than twice as wide. The vertical pitch gets much less than 2 times as big. Text overlaps the images.

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.