Published
Edited
Jan 20, 2020
Fork of Pigs
4 stars
Insert cell
Insert cell
Insert cell
camera = {
var camera = createReglCamera(regl, {
phi: 90,
// theta: 1,
distance:10,
center: [0.5, 0.5, 0],
rotationCenter: [0.5, 0.5, 0],
});
createInteractions(camera);
return camera;
}
Insert cell
model = mat4create();
Insert cell
Insert cell
Insert cell
drawings = chosen.map((d) => {
return process(d, {x: Math.random(), y: Math.random(), z: Math.random()})
})
Insert cell
Insert cell
Insert cell
{
tick;
camera((state) => {
// regl.poll();
if(!state.dirty) return;
regl.clear({color: [0.05, .05, 0.05, 1]});

drawings.slice(0,50).forEach((d) => {
draw3d(d, state)
})
})
yield;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// viewof bigindex = html`<input type=range min=0 max=${chosen.length-1} step=1 value=17>`
Insert cell
// md`Rendering drawing #${bigindex}. Some of my favorites are 17, 53, 64, 74, 76, 77`
Insert cell
//md`Thickness of the line used to draw the large pig: ${thickness}px`
Insert cell
// viewof thickness = html`<input type=range min=1 max=50 step=1>`
Insert cell
/*
viewof colored = {
var w = width
var h = height
var el = DOM.canvas(w,h)
var ctx = el.getContext("2d")
var line = d3.line()
.x(function(d) { return d.x * 2 })
.y(function(d) { return d.y * 2 })
.curve(d3.curveBasis)
.context(ctx) // <-- so convenient!

// render the large pig
ctx.lineCap = "round"
big.strokes.forEach(function(s) {
// ctx.strokeStyle = "#ccc"
ctx.strokeStyle = "rgba(200,200,200,0.75)"
ctx.lineWidth = thickness
ctx.beginPath()
line(s)
ctx.stroke()
})

return el
}
*/
Insert cell
// big = {
// let w = width/2
// let h = height/2
// let stroked = strokifyDrawing(chosen[bigindex])
// stroked.strokes = center(stroked.strokes, w,h,h/300)
// stroked.points = stroked.strokes.map(function(stroke) {
// return stroke.map(function(d) { return [d.x/300, 0, d.y/300] })
// })
// return stroked
// }
Insert cell
// rounded = interleavedStripRoundCapJoin(regl, 10)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more