Skip to content

Instantly share code, notes, and snippets.

@microlith57
microlith57 / Agar.py
Last active August 25, 2021 02:32
Agar
# Agar
# Made for Pythonista on iPad
from scene import *
from random import randint
from math import pi, pow
BACKGROUND_COLOR = Color(0, 0, 0) # The color of the background.
BLOB_COLOR = Color(0.5, 0.5, 1, 0.5) # The least background-like blob color possible.
TEXT_COLOR = Color(0.8, 0.8, 1, 0.8) # The color of the mass counter text.
@microlith57
microlith57 / enum_parse_with_or.cr
Last active April 23, 2019 04:58
Hack on the Enum struct to allow for `Color.parse("Red | Green")`
struct Enum
def self.parse?(string : String) : self?
parts = string.split("|")
output = new(0)
parts.each do |part|
p = previous_def(part.strip)
return nil if p.nil?
output |= p
end
output