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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more