RADIAL GRID
A simple function very much like the native Polar Grid Tool in AI, only this function actually creates individual cells rather than just some simple circles with lines in them.
center – Location of the grid origo, [point]
inner – The inner radius of the grid, [number]
outer – Radius of the grid, [number]
sectors – Sets the number of sector dividers, [array]
rings – Number of concentric dividers of the grid, [number]
“sectors” is an array carrying the number of sectors / concentric ring. This way, each ring may have a different number of sectors. For an ordinary grid just pass a one value array as “sectors” and make sure “rings” is at the right amount.
function RadialGrid(center, inner, outer, sectors, rings){
var p1, p2, p3, p4, firstArcMid, secondArcMid,
angle, angleStep, innerRadius, outerRadius,
ringRadius = (outer - inner) / rings,
sector
for(var i = 0; i < rings; i++){
sector = rings > sectors.length ? sectors[sectors.length - 1] : sectors[i]
angle = 90
angleStep = 360 / sector
innerRadius = ringRadius * i + inner
outerRadius = ringRadius * (i + 1) + inner
for(var j = 0; j < sector; j++){
p1 = center - new Point({length: innerRadius, angle: angle})
p2 = center - new Point({length: outerRadius, angle: angle})
p3 = center - new Point({length: outerRadius, angle: angle + angleStep})
p4 = center - new Point({length: innerRadius, angle: angle + angleStep})
firstArcMid = center - new Point({length: outerRadius, angle: angle + angleStep / 2})
secondArcMid = center - new Point({length: innerRadius, angle: angle + angleStep / 2})
if(sector == 1){
Pathfinder.backMinusFront([new Path.Circle(center, outerRadius), new Path.Circle(center, innerRadius)])
} else {
var path = new Path([p1, p2])
path.arcTo(firstArcMid, p3)
path.add(p4)
path.arcTo(secondArcMid, p1)
path.closePath()
}
angle += angleStep
}
}
}
Back to Scripts







