Git Product home page Git Product logo

doughnut's Introduction

🍩 Doughnut 🍩

Have a donut — Andy Sloane

This is a rust implementation of donut.c, the obfuscated terminal raytracer.

Now with international spelling.

                use std::io::*;
            fn main(){let mut t= 0f32
         ;while t<10.{let(us,uc)=(t*1.3
       ).sin_cos();let(ts,tc)=t.sin_cos()
      ;let(mut zb,mut b)=([1e2;1600],[ 32;
    1644]) ;b[0]=27;b[1]=91;b[2]=50;b[3]=74;
   for i in 0..40{b[4+i*41]=10 }for a in  0..
  9801{let(θ,φ)=((a% 99) as f32*0.0634,(a/99)
  as f32*0.0634);let       ((θs,θc),(φs,φc))=
 (θ .sin_cos( ),φ.           sin_cos() );let (
 mut x,mut y,mut               z)=((1.+0.6*θs)
 *φc,(1.+0.6*θs)               *φs,0.4*θc);let
(mut nx,mut ny,                 mut nz)=(θs*φc,
 θs*φs,θc);(y,z)               =(y*tc+z*ts,z *
 tc-y*ts);(ny,nz               )=(ny*tc+nz*ts,
 nz*tc-ny*ts);(x,z           )=(x*uc+z*us,3.+z
  *uc-x*us);(nx,nz)=       (nx*uc+nz*us,nz*uc
  -nx*us);let d=x*x+y*y+z*z;let(y,x)=((-y/z *
   18.+20.5) as usize,(x/z*30.+20.5)as usize
    );if d<zb[y*40+x]{zb[y*40+x]=d;b[4+y*41
      +x]=b".,-=~:;!*#$@"[(((0.4*nx+0.3 *
       ny-0.7*nz).clamp(0.,1.)*11.)+0.5)
         as usize];}}stdout().write(&b
            );t+=1e-3;}}///////////
                ///////////////

To run:

$ rustc doughnut.rs
$ ./doughnut
$ # profit

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.