Code Monkey home page Code Monkey logo

manim.js's Introduction

Screenshot

This repo contains the source code for all animations of my YouTube channel, Jazon Jiao (Subscribe!): https://www.youtube.com/channel/UC8bvGUlaTahF0lHhMsZFhfw

Manim.js is a project that aims to emulate 3b1b-style math animations using JavaScript (p5.js). The library is currently focused on visualizing linear algebra concepts and graph algorithms. All util classes are located in /src, with detailed documentation. Feel free to use my tools to make your own visualizations of math or CS concepts!

As an example, here's how you could create an simple graph. Include this code and other necessary source files in an html file (see, for example, Graph Algorithms/graph.html), and then open the browser.

let G = {
    V: [[100, 200],  // vertex 0 coordinates on canvas
        [260, 100],  // vertex 1
        [260, 300],  // vertex 2
        [420, 200],  // vertex 3
    ],
    E: [[0, 1], [0, 2], [1, 2], [1, 3], [2, 3]]  // edges
};

const GraphExample = function(s) {
    let tnr;
    s.preload = function() {
        tnr = s.loadFont('../lib/font/times.ttf');    // loads font (Times new roman)
    };
    s.setup = function () {
        // this sets frameRate to be 30, and creates a canvas of 1200 by 675 (you can adjust these in globals.js)
        setup2D(s); 
        
        // creates an undirected graph
        s.g = new Graph_U(s, {  // parameters are passed in via an object
            V: G.V, 
            E: G.E, 
            font: tnr,
            start: 40,   // the time to start the animation in frames
            color_e: [7, 97, 7],   // color of edges in RGB
            color_v: Yellow,   // set color of nodes, using the global Yellow variable
        });
    };
    s.draw = function () {
        s.background(0);
        s.g.show();  // Manim.js classes usually define a show() function to be called in draw()
    };
};

let p = new p5(GraphExample);   // creates the p5 object to render the animation

manim.js's People

Contributors

jazonjiao avatar matmercer 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

manim.js's Issues

How to show the frame timer (and go to next chapter)? How to determine the recent scene?

I am trying the "demo" of Linear Regression/part_1.html which runs the first animation with the graph and then gets stuck.

While waiting x seconds, it continued as it seems.

So the developer is kind of lost here.

Maybe show the timer() in the console while running?

Furthermore, I do not understand where the scn variable in chapter_1.js is increased. I expected somewhere a scn++; but cannot find it.


It would be great to have a key listener and then manually jump to the next scene/chapter. With cursor to the right, for instance. Or per mouse click.


For usability, a notification with "scene ended" would be very helpful.


It also seems that Chap1Credits is never called/played.

Need for a tutorial

Hi, this software really works great and smoothly, but there does not seem to be a tutorial on really how to use it, except for the examples, which are too complex for beginners imho.

Would it be possible to write such an introductory text for beginners? It would really be helpful.

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.