Pentagram: Difference between revisions
Content added Content deleted
(Ada version) |
(Implementation in Red programming language) |
||
Line 978: | Line 978: | ||
(star-polygon 100 5 2 "outline" (make-pen "blue" 4 "solid" "round" "round")) |
(star-polygon 100 5 2 "outline" (make-pen "blue" 4 "solid" "round" "round")) |
||
(star-polygon 100 5 2 "solid" "cyan"))</lang> |
(star-polygon 100 5 2 "solid" "cyan"))</lang> |
||
=={{header|Red}}== |
|||
<lang red>Red [need: 'view] |
|||
canvas: 500x500 |
|||
center: as-pair canvas/x / 2 canvas/y / 2 |
|||
radius: 200 |
|||
points: collect [ |
|||
repeat vertex 10 [ |
|||
angle: vertex * 36 + 18 ;-- +18 is required for pentagram rotation |
|||
either vertex // 2 = 1 [ |
|||
keep as-pair (cosine angle) * radius + center/x (sine angle) * radius + center/y |
|||
][ |
|||
keep as-pair (cosine angle) * radius * 0.382 + center/x (sine angle) * radius * 0.382 + center/y |
|||
] |
|||
] |
|||
] |
|||
view [ |
|||
title "Pentagram" |
|||
base canvas white |
|||
draw compose/deep [ |
|||
fill-pen mint |
|||
polygon (points) |
|||
line-width 3 |
|||
line (points/1) (points/5) (points/9) (points/3) (points/7) (points/1) |
|||
] |
|||
] |
|||
</lang> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |