Skip to content

Instantly share code, notes, and snippets.

@chrisws
Created March 1, 2021 09:20
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 chrisws/aafffbc507ef150e73aa575c9711dbfe to your computer and use it in GitHub Desktop.
Save chrisws/aafffbc507ef150e73aa575c9711dbfe to your computer and use it in GitHub Desktop.
const a_sep = 5
const numSectors = 74
const interval = 9
const a_offs = 80
const r_offs = 1
const rings = [30, 70, 110, 150, 190]
const sectors = seq(0, 360, numSectors)
const col_off = rgb(0xf5, 0xf6, 0xbd)
const col_on = rgb(0xea, 0x9c, 0x21)
const col_stop = rgb(255, 255, 255)
const col_border = rgb(100, 100, 100)
const txt = "I wasted your time decoding this"
alphabet = {}
word_index = 0
bit_index = 0
sub init
local i = 0
for c in " abcdefghijklmnopqrstuvwxzy1234567890"
alphabet[c] = i
i++
next c
color 1, rgb(0x3d, 0x45, 0x5e)
cls
end
func pop_bit
local result = false
local w, v
if (word_index < len(txt)) then
w = mid(txt, word_index + 1, 1)
v = alphabet[w]
result = iff((v & pow(2, bit_index)) > 0, true, false)
endif
bit_index = (bit_index + 1) % 7
word_index = iff(bit_index = 0, word_index + 1, word_index)
return result
end
sub pie(r1, r2, a, value)
local x = xmax / 2
local y = ymax / 2
local ra = rad(a)
local cz = cos(ra)
local sz = sin(ra)
local x11 = x + (cz * r1)
local y11 = y + (sz * r1)
local x12 = x + (cz * r2)
local y12 = y + (sz * r2)
ra = rad(a + a_sep)
cz = cos(ra)
sz = sin(ra)
local x21 = x + (cz * r1)
local y21 = y + (sz * r1)
local x22 = x + (cz * r2)
local y22 = y + (sz * r2)
local c = iff(value == 2, col_stop, iff(value == 1, col_on, col_off))
local aa = [x11, y11, x12, y12, x22, y22, x21, y21, x11, y11]
drawpoly aa color c filled
drawpoly aa color col_border
end
sub main
local r, s, value
for r = 0 to len(rings) - 2
for s = 0 to len(sectors) - 2
if (s mod interval == 0 || s mod interval == 1) then
value = 2
else
value = pop_bit()
endif
pie(r_offs + rings[r], rings[r + 1], a_offs + sectors[s], value)
next s
next r
end
init
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment