Skip to content

Instantly share code, notes, and snippets.

@toomasv
Created November 14, 2020 11:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toomasv/1eafae653cdaaa93df0d9a6b62f9f757 to your computer and use it in GitHub Desktop.
Save toomasv/1eafae653cdaaa93df0d9a6b62f9f757 to your computer and use it in GitHub Desktop.
Simple pie-chart
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