Exemple #1
0
function depth($a, $nodes)
{
    $max = 1;
    if (array_key_exists($a, $nodes)) {
        foreach ($nodes[$a] as $b => $c) {
            $max = max(1 + depth($c, $nodes), $max);
        }
    }
    return $max;
}
Exemple #2
0
function cutoutButton($x,$y,$r)
{
	$z1 = 0.25;
	$z2 = $z1 + 0.125;
	$z3 = $z2 + 0.125;
	$a1 = 40;
	$a2 = 180 - $a1;

	circlePocket($x,$y,$r+R,depth(0.75,$z3,DM));
	cap($x,$y,$r+R,$z3,$z2,10);
	circle($x,$y,$r+R,depth($z2,$z1,DM));
	arc($x,$y,
		polarX($x,$r+R,$a2), polarY($y,$r+R,$a2),
		polarX($x,$r+R,$a1), polarY($y,$r+R,$a1),
		depth($z1,0,DM));

	arc($x,$y,
		polarX($x,$r+R,-$a1), polarY($y,$r+R,-$a1),
		polarX($x,$r+R,-$a2), polarY($y,$r+R,-$a2),
		depth($z1,0,DM));

	$y1 = $y-R-0.0625;
	$y2 = $y+R+0.0625;

	$x1 = $x+$r+R-0.0425; $x2 = $x+$r+R+0.125;
	line($x1,$y1, $x2,$y1, depth($z1,0,DM));
	line($x2,$y2, $x1,$y2, depth($z1,0,DM));

	$x1 = $x-$r-R+0.0425; $x2 = $x-$r-R-0.125;
	line($x1,$y1, $x2,$y1, depth($z1,0,DM));
	line($x2,$y2, $x1,$y2, depth($z1,0,DM));

	$x2 = $x+$r+R+0.125;
	line($x2,$y1, $x2,$y2, depth($z1,0,DM));

	$x2 = $x-$r-R-0.125;
	line($x2,$y1, $x2,$y2, depth($z1,0,DM));
}