Skip to content

Instantly share code, notes, and snippets.

@matt-daniel-brown
Created November 28, 2018 01:41
Show Gist options
  • Save matt-daniel-brown/7f3429a0ac2a91856959bcb468d948fc to your computer and use it in GitHub Desktop.
Save matt-daniel-brown/7f3429a0ac2a91856959bcb468d948fc to your computer and use it in GitHub Desktop.
only after
<canvas></canvas>
<!-- Click to generate a new image -->
"use strict";
{
const code = {
setup() {
this.render({
startShape: 'start',
transform: {s: 4, b: 1},
background: '#111',
minSize: 1,
minComplexity: 1000,
fov: 60,
camDist: 300,
lightPosition: [0.0, 5.0, -200.0],
ambientColor: [0.1, 0.1, 0.1],
diffuseColor: [0.2, 0.5, 0.8],
specularColor: [1, 0.7, 0.2],
shininess: 0.25
});
},
rules() {
return {
start: s => {
this.element(s, {b: 1});
this.element(s, {x: -1, ry: 180, b: 1});
},
element: [
1, s => {
this.PLANE(s, {s:[1, 1, 2]});
this.element(s, {x: 0.9, s: 0.99, hue: 1});
},
0.02, s => {
this.PLANE(s, {s:[1, 1, 2]});
this.element(s, {x: 1, s: 0.99, ry: 90});
this.element(s, {x: 1, s: 0.99, ry: -90});
},
0.01, s => {
this.PLANE(s, {s:[1, 1, 2]});
this.element(s, {x: 0.6, y: 0.15, s: 0.99, ry: 30 });
},
0.01, s => {
this.PLANE(s, {s:[1, 1, 2]});
this.element(s, {x: 0.6, y: -0.15, s: 0.99, ry: -30 });
},
0.005, s => {
this.CUBE(s, {y:25, s: [10, 50, 10], b: -0.2});
},
]
};
}
};
// import cfdg library
cfdg.apply(code);
// run code
code.setup();
// Click canvas to generate a new image
["click", "touchdown"].forEach(event => {
document.addEventListener(event, e => code.setup(), false);
});
}
<script src="https://codepen.io/ge1doot/pen/rdwPLr/"></script>
html, body {
overflow: hidden;
touch-action: none;
position: absolute;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background: #000;
}
canvas {
position: absolute;
width: 100%;
height: 100%;
user-select: none;
cursor: pointer;
background: #000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment