Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Pentagram/Sidef/pentagram.sidef
Normal file
29
Task/Pentagram/Sidef/pentagram.sidef
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
func pentagram(dim=200, sides=5) {
|
||||
var pentagram = <<-EOT
|
||||
<?xml version="1.0" standalone="no" ?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
|
||||
"http://www.w3.org/TR/2001/PR-SVG-20010719/DTD/svg10.dtd">
|
||||
<svg height="#{dim*2}" width="#{dim*2}" style="" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect height="100%" width="100%" style="fill:black;" />
|
||||
EOT
|
||||
|
||||
func cis(x) {
|
||||
cos(x) + sin(x).i
|
||||
}
|
||||
|
||||
func pline(q) {
|
||||
<<-EOT
|
||||
<polyline points="#{[q..., q[0], q[1]].map{|n| '%0.3f' % n }.join(' ')}"
|
||||
style="fill:blue; stroke:white; stroke-width:3;"
|
||||
transform="translate(#{dim}, #{dim}) rotate(-18)" />
|
||||
EOT
|
||||
}
|
||||
|
||||
var v = sides.range.map {|k| 0.9 * dim * cis(k * Num.tau / sides) }
|
||||
pentagram += pline([v[range(0, v.end, 2)], v[range(1, v.end, 2)]].map{.reals})
|
||||
pentagram += '</svg>'
|
||||
|
||||
return pentagram
|
||||
}
|
||||
|
||||
say pentagram()
|
||||
Loading…
Add table
Add a link
Reference in a new issue