clumsy-math: math library for generating art


tl;dr a novel open-source typescript math library for generating art :slightly_smiling_face:

clumsy-math is a little library of fun math functions and types that have been slowly iterated on in one form or another during my free time for the past decade

the stuff on rhythm is the most fleshed out at the moment and should be documented enough for others to dive into. there are also some rough utilities for playing with prime numbers which can be helpful when composing rhythms

the next step for this library is to implement functions and types dealing with the concept of a loop which is a generalization of a circle, ellipse, and egg plus additional features!! this abstraction is what im most excited about right now but the current implementation is rather slow for professional use when dealing with audio/signals

the majority of the code presented here was developed in the context of me playing with simple 2d graphics and animations and thus may hinder more serious use from others. nonetheless i felt like it was time to share

if you want to play around with the code yourself i recommend using a tool which ive developed called clumsy-graphics! it enables rapid development of animations where frames are described using svg elements ⓐ la react. it has turned out to be rather useful for picking up and learning new math for those with an ability to do some basic programming

i invite/beg for others to poke around and pick apart the code, especially the documentation


over a decade ago i stumbled upon this wonderful community through artist such as flying lotus, pretty lights, and daedalus. this was my first introduction to a whole new world of tooling for artist. the world of internet forums and open collaboration was completely foreign to me. i was hooked!

once i had a enough money saved up from slingin pitas i purchased a monome of my own and countless other gear. for a year or so i dived into making music of my own and began exploring basic music theory and composition. the most impactful resource i came across was a simple academic paper by Godfried Touissant titled The Euclidean Algorithm Generates Traditional Musical Rhythms. this was life altering!

i quickly became obsessed, this was not the math i was taught in school. this was cool! from there i dove into atonal music theory and though most of the stuff was way over my head it led me to the conclusion that math, code, and people can come together to make all sorts of new and wonderful music.

now 10+ years later, countless hours of learning how to program, and a number of jobs developing software alongside some of the most amazing people/engineers, ive hopefully begun to share code and concepts that others can leverage in their own art and even beyond


  • a javascript runtime that typescript can target like nodejs or the browser

  • or an ability to read high-level code and port to a language of your choosing




yarn add clumsy-math



Very cool!! Thanks for sharing, will definitely look into it more when I get some time

much appreciation :slight_smile:

i would recommend checking out the concept of recursive euclidean rhythms!! it opens up an entire new space/possibilities for mathematically generated rhythms

1 Like