Git Product home page Git Product logo

thedonutproject's Introduction

The Donut Project Banner

What is The Donut Project?

Watch the introduction video on YouTube.

This all started with donut.c, the classic C code that looks like, and generates a 3D spinning donut when run. Out of sheer curiosity, I searched up this code in different languages, and noticed that many people have created 3D spinning donuts in those languages... but their code mostly didn't look like a donut.

My goal at the start was to bring this classic piece of code (and its donut shape) to different languages. I started with a JavaScript rendition of donut.c. Then, after much struggle, I created a Python version.

Because I thought it would be fun, I posted both of these projects on YouTube, and to my surprise, it caught on quickly, getting around 90k views in 2 weeks—and counting. People started asking me to make this in different languages. And now I'm asking you.

The Donut Project seeks to replicate donut.c in as many languages as possible, and it's really quite easy to join...

How do I contribute?

You can either...

Contribute Your own Donut

Do so in 2 easy steps:

Step 1: Bake Your Donut

First, find a language that someone hasn't done yet (you can see the finished languages in the donuts folder or info.json) and recreate donut.c!

Helpful resources:
Alternate-Implementation Donuts

If you would like to contribute a donut in a language someone has already done with your own spin to it, write the file like this: donut.[TYPE].[EXTENSION] with a JSON key in info.json of [TYPE].[EXTENSION]. For example, if you were to make a JS donut only using fixed-point arithmetic (so-called being "pure"), you may call it donut.pure.js with a JSON key of pure.js. Ensure you place in the PR why you believe this donut is unique enough to be its own separate file. Additionally, please include a short summary in the description of why this donut is special.

Basic Rules
  • Make sure that the output is similar to the original donut.c.
  • Also, importantly, make sure that the code looks like a donut. To make this easier you can use donutGenerator.
Recommendations

Additionally, here are some (decently strong) recommendations about how you should make your donut:

  • Make sure the donut is mostly code. It's alright if there are a few lines/places with comments, however.

Step 2: Submit Your Donut

Now, fork this repo with the following command.

git clone https://github.com/EvanZhouDev/TheDonutProject.git

Add your donut to the donuts folder. Ensure it is named donut, with the proper extension at the end. For example, I may have the file donut.py, donut.js, or donut.pure.js (as mentioned above).

Then, add an entry into info.json. The key should be whatever file extension (and potentially additional suffixes) you are using (make sure it matches with your file—it should be everything that follows donut.), and the value should look like this:

Key Description Required?
name Your name, or name you would like to associate your donut with Required
github Your GitHub account Optional
repo Full link to your GitHub repository where you have your donut Optional
run Command to run your donut with; refer to the file simply as donut.* Required if special action needed (i.e. compiler flags, etc.)
description Describe your donut. Required for alternate-implementation donuts.

For example, my donut.js would look something like this:

Please use 4 space indentation in info.json.

"js": {
    "name": "Evan Zhou",
    "github": "EvanZhouDev",
    "repo": "https://github.com/EvanZhouDev/donut-js"
}

Finally, simply submit a PR (with the language you are contributing in the title), and go through the checklist to complete your submission.

Contribute Someone Else's Donut

Alternatively, you can also submit donuts that you have found floating around the community already. Ensure that it still follows the basic rules and recommendations.

Submit it just the same as above, but make sure you put their name and their GitHub and repo if applicable in the info.json.

See Also

Thank you to @Rudxain for the suggestion.

thedonutproject's People

Contributors

abdallahmehiz avatar chaosisframecode avatar dragonxdev avatar drakeerv avatar erikschreiner-deprecated avatar evanzhoudev avatar ex-opera avatar iokg04 avatar joeskeen avatar kaceyxam avatar namegoesthere avatar sirraide avatar sullyvian avatar thecolorblocks avatar tj-moody avatar virviil 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

thedonutproject's Issues

Smaller output size

I am currently working on an asciidots implementation of donut.c, but (at least as far as I can see) the performance of the asciidots interpreter scales with file size.
I currently have a demo with 1760 cells that can hold one value each (comparable to z in donut.c), and it already only runs with a couple ticks per second (each frame will probably take around a couple thousand to ten thousand ticks to render, so I think you can see the problem).

Besides further optimizing my code of course, one of my ideas to get it running a little smoother would be to scale down the output resolution by 2 (thus only needing 440 storage cells, greatly improving performance). Would that be okay or is that too far from the original donut.c?

Alternative implementations?

What if there are multiple valid implementations in the same lang?

Examples:

  • JS can use console.log & console.clear in a browser environment to emulate donut.c
  • JS can assume stdout is connected to a Unix-like terminal (as is the case in most Node-like envs). This allows JS to perfectly replicate donut.c
  • PyGame and Turtle are libraries that allow Python scripts to render graphics on-screen, using wildly-different APIs.
  • JS can use textarea to emulate a terminal within a browser window (no console required)
  • RR can either call Py libs (such as math), or be "pure" by using fixed-point arithmetic (#20)

I ask this because the file-name rules are so strict that alt-impls would collide

Any ideas for how I can make assembly code donut shaped?

I translated donut.c into assembly (nasm syntax to be specific) over the last day, but only now noticed nasm doesnt support putting multiple instructions on one line (and that is also the case with most assemblers, or at least all I could find)
I wondered if anyone here knew of an assembler that could do that.

If not my two main ideas are either to fork nasm and try to build in that functionality myself, though it'd mean that anyone who wants to verify my code also needs to have my specific version of nasm, or to make it be a c file (though with a different extension) and use inline asm there.

If anyone here got a better idea, please tell me, thanks :)

Small issue in `donutGenerator.py`

To keep the actual amount of characters donutGenerator.py gives when given a single argument, either the .84 in line 34 has to be changed into a .8775 or the .35 in the following line needs to become a .4 (like in the original).

Please note when choosing one of those options, that a lower value in line 35 (aka a higher value in line 34) leads to a donut with relatively speaking less center.

It's less of an issue that needs fixing right now, but the math nerd on me just wanted to point that out. (I can give mathematical proof of why the values should be like I described if requested)

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.