Reputation: 2794
Here's the rundown... I've got a circle, I've got some divs I want to "bend" around it. Just like a circle table with various numbers of chairs around it.
I've ran a few stuff down, my brains not hitting at this hour, would really love to knock it out so I can sleep. Anyone?
<?
$r=45; //px
for($x=0; $x<$gu; $x++){
$deg = 360/$gu*$x;
$rad = deg2rad($deg);
$xx = (cos($rad) * $r);
$yy = (sin($rad) * $r);
?>
<b style="left:<?=round($r+$xx)?>px; top:<?=round($r+$yy)?>px"></b>
<?
}
?>
Upvotes: 0
Views: 195
Reputation: 224867
sin(angle) × radius will get you the Y-coordinate of the item, and cos(angle) × radius will get you the X-coordinate of the item, both relative to the centre of the circle.
You can get the angle by dividing 360° by the number of <div>
s.
You can convert degrees to radians by multiplying by π/180.
Upvotes: 3