Jump to content

Pentagram: Difference between revisions

Haskell version.
mNo edit summary
(Haskell version.)
Line 17:
See also
* [http://proofsfromthebook.com/2013/08/04/angle-sum-of-a-pentagram/ Angle sum of a pentagram]
 
=={{header|Haskell}}==
This uses the [http://projects.haskell.org/diagrams/ Diagrams] library to create an SVG drawing. Compiling, then running it like:
<pre>
pentagram -w 400 -o pentagram_hs.svg
</pre>
creates a 400x400 SVG file.
<lang haskell>-- Extract the vertices of a pentagon, re-ordering them so that drawing lines
-- from one to the next forms a pentagram. Set the line's thickness and its
-- colour, as well as the fill and background colours. Make the background a
-- bit larger than the pentagram.
 
import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine
 
pentagram = let [a, b, c, d, e] = trailVertices $ pentagon 1
in [a, c, e, b, d]
# fromVertices
# closeTrail
# strokeTrail
# lw ultraThick
# fc springgreen
# lc blue
# bgFrame 0.2 bisque
 
main = mainWith (pentagram :: Diagram B)</lang>
 
=={{header|J}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.