function render(svg, size, Agents, combinations, influenceRadius, options) {
const nodes = getNodes(size),
dots = Agents.position.concat(nodes),
times = timeNodes(Agents, dots),
weightedDots = conflictZone(times, options.includes('relation'), Agents.relation, area);
zoneInflu(Agents, influenceRadius, 1);
const delaunay = d3.Delaunay.from(dots);
const path = d3.geoPath();
const contours1 = d3.tricontour().thresholds(300)(
weightedDots.map((d, i) => [d.pos[0], d.pos[1], d.weight]).filter(d => isFinite(d[2]))
);
const delaunayG = svg.append("g");
if (options.includes('colorMap')){
delaunayG.selectAll("path1").data(contours1)
.enter()
.append("path")
.attr('d', path)
.style('fill', d => { let c = color(d.value)
if (options.includes('brighter')) c = d3.color(c).brighter(0.6)
return c
})
.style('stroke', 'blue');*/
}
if (options.includes('contours')){
let Zones = multipleZones2(combinations, times, Agents, options);
drawZone(svg, size, path, Zones, Agents, combinations, 0.5, options);
}
const agentsG = svg.append('g');
if (!options.includes('noPos')) {
agentsG.selectAll('agentPos').data(Agents.position)
.enter()
.append('circle')
.attr('class', 'agentPos')
.attr('cx', agent => agent[0])
.attr('cy', agent => agent[1])
.attr('r', agentRadius)
.style('fill', (_, i) => Agents.color ? Agents.color[i] : 'red')
.style('stroke', Agents.color ? 'red' : 'none')
agentsG.selectAll('agentPos').data(Agents.position)
.enter()
.append('text')
.attr('x', agent => agent[0])
.attr('y', agent => agent[1])
.attr('text-anchor', 'middle')
.attr('dy', 20)
.text((agent, i) => `Agent ${i}`)
.style('font-size', textSize);
}
if (!options.includes('noSpeed')) {
agentsG.selectAll('agentSpeed').data(Agents.position)
.enter()
.append('line')
.attr('x1', d => d[0])
.attr('y1', d => d[1])
.attr('x2', (d, i) => d[0] + 10*Agents.speed[i][0])
.attr('y2', (d, i) => d[1] + 10*Agents.speed[i][1])
.attr("stroke", "black")
.attr("stroke-width", 2);
}
if (options.includes('ZI')) {
const ZIG = svg.append('g');
ZIG.selectAll('ZI').data(Agents.ZI)
.enter()
.append('path')
.attr('d', (d, i) => influencePaths(d3.path(), Agents, i, d))
.style('fill', 'none')
.style('stroke-dasharray', 4)
.style('stroke-width', 2)
.style('stroke', '#757574');
}
//show nodes
if (options.includes('RI')) {
svg.selectAll("RI").data(Agents.position)
.enter()
.append("circle")
.attr('class', 'RI')
.attr('cx', agent => agent[0])
.attr('cy', agent => agent[1])
.attr('r', RI)
.style('fill', 'none')
.style('stroke-dasharray', 6)
.style('stroke-width', 2)
.style('stroke', 'black')//'#757574');
}
//show nodes
//show grid
if (options.includes('grid')) {
delaunayG.append("path")
.attr('d', delaunay.render())
.style('fill', 'none')
.style('stroke', '#7d7d7d')
}
if (options.includes('dots')) {
delaunayG.selectAll("circle").data(weightedDots)
.enter()
.append("circle")
.attr('cx', point => point.pos[0])
.attr('cy', point => point.pos[1])
.attr('r', 2)
//.style('stroke', '#afb0b3')
.style('fill', point => options.includes('weight') ? color(point.weight) : '#7d7d7d');
}
return svg.node()
}