Built with blockbuilder.org
forked from sxywu's block: DS July: Code 1
forked from sxywu's block: Film Flowers Petal Starter Code
xxxxxxxxxx
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
svg {
width: 900px;
height: 900px;
}
</style>
</head>
<body>
<svg></svg>
<script>
// draw petal
var petals = [
[
'M500,500',
'C350,350 350,200 500,200',
'C650,200 650,350 500,500',
],
[
'M500,500',
'C575,375 575,258 500,250',
'C450,240 445,207 500,200',
'C650,190 650,350 500,500',
]
];
d3.select('svg').selectAll('path')
.data(petals).enter().append('path')
.attr('stroke', '#000')
.attr('stroke-width', 2)
.attr('fill', 'none')
.attr('d', function(d) {return d.join(' ')})
.attr('transform', function(d, i) {
var x = (i % 3 + 0.5) * 150;
var y = (Math.floor(i / 3) + 0.5) * 150;
return `translate(${x}, ${y})`;
})
</script>
</body>
https://d3js.org/d3.v4.min.js