Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: optical encoder

by moritz (Cardinal)
on Mar 16, 2012 at 17:23 UTC ( #960027=note: print w/ replies, xml ) Need Help??


in reply to Re^2: optical encoder
in thread optical encoder

The misspelling is right in the code I've posted, not in the module. In fact SVG.pm doesn't handle style specially in any way (though I've pondered it should).

I've now actually tested the code, and this seems to work (the resulting SVG displays fine in firefox and inkscape).

use v6; use SVG; my $r = 150 / 2; my @parts = :circle[ cx => $r, cy => $r, r => $r, style => '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), style => 'stroke: black; stroke-width: 1', ]; } say SVG.serialize: 'svg' => [ width => 2 * $r, height => 2 * $r, @parts, ];

As for the xmlns:svg declaration, that just means that the svg XML namespace is set up as being interpreted as SVG. This allows you (in theory) to do fun stuff like embedding <svg:rect ...> elements straight into XHTML. But even for browsers that support it, it is only supported if the document is delivered as application/xml+xhtml, which is generally no fun, because most IE versions don't render such documents, but offer them for download. </rant>


Comment on Re^3: optical encoder
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://960027]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2014-07-13 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (248 votes), past polls