in reply to optical encoder
use v6; use SVG; my $r = 150 / 2; my @parts = :circle[ cx => $r, cy => $r, r => $r, stlye => 'fill:none; stroke: black; stroke-width: 1', ]; for 0, 2 ...^ 360 -> $degrees { my $rad = $degrees / 360 * 2 * pi; @parts.push: 'line' => [ x1 => $r, y1 => $r, x2 => $r + $r * cos($rad), y2 => $r + $r * sin($rad), ]; } say SVG.serialize: 'svg' => [ width => 2 * $r, height => 2 * $r, @parts, ];
Run it as
perl6 circle.pl > circle.svg
and scale to your desired size.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: optical encoder
by jffry (Hermit) on Mar 16, 2012 at 17:07 UTC | |
by moritz (Cardinal) on Mar 16, 2012 at 17:23 UTC |