Skip to content

Instantly share code, notes, and snippets.

@wrayal
Forked from 140bytes/LICENSE.txt
Created May 26, 2011 22:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wrayal/994257 to your computer and use it in GitHub Desktop.
Save wrayal/994257 to your computer and use it in GitHub Desktop.
140 byte wraytracer
function(
s //size of sphere, 55 works...not much else does. Maybe 54? ^_^
,i //placeholder for loop over rows
,j //placeholder for loop in rows
,k //(uninitialised *halo*) output string
){
for(i=-9;i++<(j=18)/2;k+="<br>") //outer loop including aspect fudge
for(;j-->-18;) //inner loop
k+='<font color=#00'+(j*j/4+i*i<s?(0|(i+j+80)*.1):'0')+'>#</font>';
//outputting by font-colored hashes with 'realistic' linear shading, fake hexadecimal and aspect 'correction'
return k //and return it...because 'document.write' is unfriendly to 140byte scripts ;)
}
function(s,i,j,k){for(i=-9;i++<(j=18)/2;k+="<br>")for(;j-->-18;)k+='<font color=#00'+(j*j/4+i*i<s?(0|(i+j+80)*.1):'0')+'>#</font>';return k}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "140bRt",
"description": "trace out a sphere, now with realistic shading =D.",
"keywords": [
"140bytes",
"raytrace"
]
}
<!DOCTYPE html>
<title>140b raytracing</title>
<pre>
Raytraced output: <br /><b id="ret"></b>
</pre>
<script>
function b(text)
{
document.getElementById( "ret" ).innerHTML=text
}
var myFunction=function(s,i,j,k){for(i=-9;i++<(j=18)/2;k+="<br>")for(;j-->-18;)k+='<font color=#00'+(j*j/4+i*i<s?(0|(i+j+80)*.1):'0')+'>#</font>';return k}
b(myFunction(55,i=0,j=0,""))
</script>
</html>
@wrayal
Copy link
Author

wrayal commented May 27, 2011

Tested to play well with Chrome, apparently not with IE9.

@atesgoral
Copy link

Nice one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment