Published
Edited
Dec 23, 2019
6 forks
39 stars
Insert cell
Insert cell
Insert cell
Insert cell
im = d3
.image(await FileAttachment("rosa.jpg").url(), { crossOrigin: "anonymous" })
.then(d => ((d.style = "max-width: 100px"), d))
Insert cell
// this object shows the structure needed by Jochen’s implementation
grid = {
const context = DOM.context2d(w, h, 1);
context.drawImage(im, 0, 0, w, h);
const data = context.getImageData(0, 0, w, h);
return {
width: w,
height: h,
pos_at_index: function(idx) {
return [idx % w, Math.floor(idx / w)];
},
values: data.data
.filter((_, i) => i % 4 === 1) // note: we're using the green canal of (r,g,b,a)
.map(d => (!inverse ? 255 - d : d))
};
}
Insert cell
import { stipples_new } with { grid as himmelblau_grid } from "b333da9462d0762b" // a variant of "@grtlr/stippling-of-2d-scalar-fields" using d3-delaunay instead of d3-voronoi
Insert cell
w = Math.min(width)
Insert cell
h = ((im.height / im.width) * w) | 0
Insert cell
d3 = require("d3@5")
Insert cell
import { checkbox } from "@jashkenas/inputs"
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