Skip to content

Instantly share code, notes, and snippets.

@toomasv
Last active May 8, 2019 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toomasv/95a5d4631dd1bf198df60e784170918a to your computer and use it in GitHub Desktop.
Save toomasv/95a5d4631dd1bf198df60e784170918a to your computer and use it in GitHub Desktop.
Another color-picker
Red [
Description: "Another color-picker"
Date: 8-May-2019
]
context [
colors: []
i: 9
j: 256 / (i - 1)
collect/into [
repeat r i [repeat g i [repeat b i [
keep as-color
either r > 1 [r - 1 * j - 1][r - 1 * j]
either g > 1 [g - 1 * j - 1][g - 1 * j]
either b > 1 [b - 1 * j - 1][b - 1 * j]
]]]
] clear colors
colors2: collect [
forall colors [
s: as-pair (n: (index? colors) - 1 % 27) * 10 (index? colors) - 1 / 27 * 10
e: s + 9
keep reduce ['fill-pen colors/1 'box s e]
]
]
insert colors2 [pen gray]
img: draw 270x270 colors2
set 'pick-color has [color][
view/tight [
image img all-over
on-over [event/window/text: form pick img event/offset]
on-down [write-clipboard form color: pick img event/offset]
]
color
]
]()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment