Published
Edited
Dec 23, 2019
20 stars
Insert cell
Insert cell
Insert cell
Insert cell
im = d3
.image(await FileAttachment("heidi-couverture-livre.jpg").url(), {
crossOrigin: "anonymous"
})
.then(d => ((d.style = "max-width: 200px"), d))
Insert cell
// this object shows the structure needed by Jochen’s implementation
grid = function(channel) {
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 === channel)
.map(d => (!inverse ? 255 - d : d))
};
}
Insert cell
r = grid(0)
Insert cell
g = grid(1)
Insert cell
b = grid(2)
Insert cell
import { stipples_new as stipples_r } with {
r as himmelblau_grid
} from "b333da9462d0762b" // a variant of "@grtlr/stippling-of-2d-scalar-fields" using d3-delaunay instead of d3-voronoi
Insert cell
import { stipples_new as stipples_g } with {
g as himmelblau_grid
} from "b333da9462d0762b" // a variant of "@grtlr/stippling-of-2d-scalar-fields" using d3-delaunay instead of d3-voronoi
Insert cell
import { stipples_new as stipples_b } with {
b 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