Published
Edited
Nov 2, 2021
Fork of Simple D3
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
grid2 = {
var x = 1
var y = 1
var w = 200
var id = 1
function testPath(x,y) {
var lineGenerator = d3.line();
var pathData = lineGenerator(cShape(x,y))
return pathData+"Z"
}
// reset;
const s = DOM.svg(500, 500);
s.setAttributeNS(null, 'width', 500);
s.setAttributeNS(null, 'height', 500);
// This is the group in which we will append each pattern
const g = svg`<g />`;
// g.appendChild(svg`<rect x="0" y="0" width="${500}" height="${500}" fill="none"/>`)

//The Frame
const frame = svg`<rect x="${x}" y="${y}" width="${w}" height="${w}" fill="none"/>`
frame.setAttributeNS(null, "stroke", "#000000");
frame.setAttributeNS(null, "stroke-width", .2);
// frame.setAttributeNS(null, "transform", "rotate("+(-rot)+","+(x+w/2)+","+(y+w/2)+")");
//The Clipping Path
const clip = svg`<clipPath id="myclip1"><rect x="${x}" y="${y}" width="${w}" height="${w}"/></clipPath>`
clip.setAttributeNS(null, "transform", "rotate("+(-45)+","+(x+w/4)+","+(y+w/2)+")");
// clip.setAttributeNS(null, "transform"+", "+(x+w/2)+","+(y+w/2)+")");

//First C
const c1 = svg`<path d="${
testPath(x+w,y+w/2)
}" clip-path="url(#myclip1)" style="fill: rgb(100, 0, 0)"></path>`
c1.setAttributeNS(null, "transform", "rotate("+(45)+","+(x+w/4)+","+(y+w/2)+")");
//Second C
// const c2 = svg`<path d="${
// testPath(x,y)
// }" clip-path="url(#myclip_${id})" style="fill: rgb(0, 0, 0)"></path>`

s.appendChild(g);
g.appendChild(clip);
g.appendChild(frame);
g.appendChild(c1);
// g.appendChild(c2);
return s;
}
Insert cell
Insert cell
height = 1200
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