Created
November 14, 2020 11:00
-
-
Save toomasv/1eafae653cdaaa93df0d9a6b62f9f757 to your computer and use it in GitHub Desktop.
Simple pie-chart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Description: "Simple pie chart" | |
File: %simple-pie.red | |
Author: "Toomas Vooglaid" | |
Original: https://gitter.im/red/help?at=5b4f23adecc1f82e2fc206d6 | |
Date: 18-Jul-2020 | |
Adaptation: 14-Nov-2020 | |
] | |
start: -90 | |
tx: make-face 'text | |
lay: foreach [color angle text][ | |
61.160.255 110 "First" | |
99.212.212 70 "Second" | |
80.202.115 40 "Third" | |
250.212.57 40 "Fourth" | |
242.97.123 50 "Fifth" | |
150.90.228 50 "Sixth" | |
][ | |
append [] compose/deep [ | |
at 0x0 box 400x400 draw [ | |
fill-pen (color) pen white line-width 2 | |
arc 200x200 100x100 (start0: also start start: start + angle) (angle) closed | |
pen black | |
rotate (start0 + start / 2) 200x200 | |
text (as-pair 295 - first size-text/with tx text 190) (text) ;310x190 | |
] on-over [ | |
face/draw/9: pick [100x100 120x120] event/away? | |
;face/draw/text/x: pick [310 330] event/away? | |
face/draw/text/x: face/draw/text/x + either event/away? [-20][20] | |
] | |
] | |
] | |
view/tight append lay [ | |
box 400x400 draw [ | |
fill-pen white pen white circle 200x200 40 | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment