Skip to content

Instantly share code, notes, and snippets.

@SamyBencherif
Last active February 25, 2019 23:36
Show Gist options
  • Select an option

  • Save SamyBencherif/1e5ba023171116de13da109cd13f3d6b to your computer and use it in GitHub Desktop.

Select an option

Save SamyBencherif/1e5ba023171116de13da109cd13f3d6b to your computer and use it in GitHub Desktop.
SCRIPT-8
/*
In case you were wondering what a cube would look like on this screen.
Not very appealing.. maybe it's not worth the effort to write a renderer.
Luckily I just made a bitmap drawer.
But also I just realized this program has an "ART" tab.
ehh3ihihef whatever.
*/
function StoInt(s)
{
if (s==' ') return 7
return s.charCodeAt(0)-48;
}
function fdiv(a,b)
{
return Math.floor(a/b)
}
function drawBmp(bmp,s)
{
var arr = [];
for (var r of bmp.split('\n'))
{
if (r=='') continue
var row = [];
for (var x of r.split(''))
{
row.push(StoInt(x))
}
arr.push(row)
}
for (var x=0; x<arr[0].length*s; x++)
{
for (var y=0; y<arr.length*s; y++)
{
setPixel(x,y,arr[fdiv(y,s)][fdiv(x,s)])
}
}
}
const bmp = `
1222222222222222
1222222222222222
12222222222222222
11222222222222222
112222222222222222
112222222222222222
111222222222222222
111222222222222222
1112222222222222222
1111222222222222222
1111333333333333333
1111333333333333333
1111333333333333333
1111333333333333333
1111333333333333333
111333333333333333
111333333333333333
111333333333333333
111333333333333333
11333333333333333
11333333333333333
1333333333333333
1333333333333333
1333333333333333
333333333333333
`
draw = () => {
clear()
drawBmp(bmp,4)
}
{
"lines": [
86,
0,
0,
0,
0,
0,
0,
0
]
}
{
"0": [
"22222 ",
"222222 ",
"322222 ",
"3300000 ",
"3300000 ",
"3300000 ",
" 300000 ",
" ",
0
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment