Published
Edited
Oct 10, 2021
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
barnsleyIFS = {
let IFS = new IteratedFunctionSystem([
[
[
[0.85, 0.04],
[-0.04, 0.85]
],
[0, 1.6]
],
[
[
[-0.15, 0.28],
[0.26, 0.24]
],
[0, 0.44]
],
[
[
[0.2, -0.26],
[0.23, 0.22]
],
[0, 1.6]
],
[
[
[0, 0],
[0, 0.16]
],
[0, 0]
]
]);

return IFS;
}
Insert cell
Insert cell
barnsleyIFS.render_deterministic({
init: outline,
image_width: width,
image_height: 800,
extent: [[-2.2, 2.7], [0, 9.6]],
tolerance: tolerance,
max_depth: Infinity,
fill_colors: ["#008800", "#00aa00", "#00aa00", "#000000"],
stroke_colors: ["#002200", "#004400", "#004400", "#000000"]
//axes: { origin: [-2.5, -0.2], font: "16px Times" }
})
Insert cell
{
let canvas = barnsleyIFS.render_deterministic({
init: outline,
image_width: width,
image_height: 800,
tolerance: 0,
max_depth: 1,
fill_colors: ["#008800", "#00aa00", "#00aa00", "#000000"],
stroke_colors: ["#002200", "#004400", "#004400", "#000000"],
axes: { origin: [-2.5, -0.2], font: "16px Times" }
});

let x = barnsleyIFS.xScale;
let y = barnsleyIFS.yScale;

let ctx = canvas.getContext("2d");

ctx.beginPath();
ctx.moveTo(x(outline[0][0]), y(outline[0][1]));
ctx.strokeStyle = "black"; // 'rgba(0,0,0,0.5)';
ctx.lineWidth = 3;
for (let j = 0; j < outline.length; j++) {
ctx.lineTo(x(outline[j][0]), y(outline[j][1]));
}
ctx.lineTo(x(outline[0][0]), y(outline[0][1]));
ctx.stroke();
ctx.closePath();

return canvas;
}
Insert cell
outline = {
let [f1, f2, f3, f4] = barnsleyIFS.function_list;
let tip = [0, 0];
for (let i = 0; i < 100; i++) {
tip = f1(tip);
}
let xy = f2(tip);
let left_side = [xy].concat(d3.range(32).map(() => (xy = f1(xy))));
left_side.reverse();
xy = f3(tip);
let right_side = [xy].concat(d3.range(32).map(() => (xy = f1(xy))));

let outline = [[0, 0]].concat(right_side).concat([tip]).concat(left_side);
return outline;
}
Insert cell
import { IteratedFunctionSystem } from "@mcmcclur/iteratedfunctionsystem-class"
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