Published
Edited
Mar 5, 2021
Insert cell
md`# Clifford Attractors`
Insert cell
{
var ITERATIONS = 10000000;
var PER_FRAME = 10000;
var width = 900
var height = 900
var _a = [1.7, 1.7, 1.2, 0.6]
var A = _a[0], B = _a[1], C = _a[2], D = _a[3];
var _b = [450, 450, 155], LEFT = _b[0], TOP = _b[1], SCALE = _b[2];
var _c = [0, 0], x = _c[0], y = _c[1];
let context = DOM.context2d(width, height)
context.fillStyle = "rgba(255,0,100,0.008)";
var getPixel = function (a, b, c, d, ox, oy) {
x = Math.sin(a * oy) + c * Math.cos(a * ox);
y = Math.sin(b * ox) + d * Math.cos(b * oy);
return { x: x, y: y };
};
var drawPixel = function (_a) {
var x = _a.x, y = _a.y;
context.fillRect(LEFT + (SCALE * x), TOP + (SCALE * y), 1, 1);
};
var count = 0;
var doDrawing = function () {
var p = (count / ITERATIONS);
for (var i = 0; i < PER_FRAME; i++) {
count++;
drawPixel(getPixel(A, B, C, D, x, y));
}
console.log(p);
if (count < ITERATIONS)
requestAnimationFrame(doDrawing);
};
doDrawing();
return context.canvas
}
Insert cell
{
var ITERATIONS = 10000000;
var PER_FRAME = 10000;
var width = 900
var height = 900
// a: -1.4, b: -1.3, c: -1.8, d: -1.9
// var _a = [-1.4, -1.3, -1.8, -1.9]
var _a = [-1.4, -1.9, -1.8, -1.3]
var A = _a[0], B = _a[1], C = _a[2], D = _a[3];
var _b = [450, 450, 155], LEFT = _b[0], TOP = _b[1], SCALE = _b[2];
var _c = [0, 0], x = _c[0], y = _c[1];
let context = DOM.context2d(width, height)
// context.fillStyle = "rgba(255,0,100,0.008)";
context.fillStyle = "rgba(255,0,100,0.008)";
var getPixel = function (a, b, c, d, ox, oy) {
x = Math.sin(a * oy) + c * Math.cos(a * ox);
y = Math.sin(b * ox) + d * Math.cos(b * oy);
return { x: x, y: y };
};
var drawPixel = function (_a) {
var x = _a.x, y = _a.y;
context.fillRect(LEFT + (SCALE * x), TOP + (SCALE * y), 1, 1);
};
var count = 0;
var doDrawing = function () {
var p = (count / ITERATIONS);
for (var i = 0; i < PER_FRAME; i++) {
count++;
drawPixel(getPixel(A, B, C, D, x, y));
}
console.log(p);
if (count < ITERATIONS)
requestAnimationFrame(doDrawing);
};
doDrawing();
return context.canvas
}
Insert cell
// a = -1.4, b = 1.6, c = 1.0, d = 0.7
{
var ITERATIONS = 10000000;
var PER_FRAME = 10000;
var width = 900
var height = 900
// var _a = [-1.4, 1.6, 1.0, 0.7]
var _a = [-1.4, 1.6, 0.7, 1.0]

var A = _a[0], B = _a[1], C = _a[2], D = _a[3];
var _b = [450, 450, 205], LEFT = _b[0], TOP = _b[1], SCALE = _b[2];
var _c = [0, 0], x = _c[0], y = _c[1];
let context = DOM.context2d(width, height)
context.fillStyle = "rgba(42, 42, 42, 0.008)";
var getPixel = function (a, b, c, d, ox, oy) {
x = Math.sin(a * oy) + c * Math.cos(a * ox);
y = Math.sin(b * ox) + d * Math.cos(b * oy);
return { x: x, y: y };
};
var drawPixel = function (_a) {
var x = _a.x, y = _a.y;
context.fillRect(LEFT + (SCALE * x), TOP + (SCALE * y), 1, 1);
};
var count = 0;
var doDrawing = function () {
var p = (count / ITERATIONS);
for (var i = 0; i < PER_FRAME; i++) {
count++;
drawPixel(getPixel(A, B, C, D, x, y));
}
console.log(p);
if (count < ITERATIONS)
requestAnimationFrame(doDrawing);
};
doDrawing();
return context.canvas
}
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