Published
Edited
May 20, 2022
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function remove_triangles(A, B, C, depth) {
if (depth == 0){
return
}
// calculate middle points
let mAB = {
x: (A.x + B.x) / 2,
y: (A.y + B.y) / 2
}
let mBC = {
x: (B.x + C.x) / 2,
y: (B.y + C.y) / 2
}
let mAC = {
x: (A.x + C.x) / 2,
y: (A.y + C.y) / 2
}
d3.select("#triangle-method-svg").
append("polygon").
attr("class", "removed_triangle").
attr("points", mAB.x + "," + mAB.y + " " + mBC.x + "," + mBC.y + " " + mAC.x + "," + mAC.y).
style("fill", "white")
remove_triangles(A, mAB, mAC, depth - 1)
remove_triangles(B, mBC, mAB, depth - 1)
remove_triangles(C, mAC, mBC, depth - 1)
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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