Skip to content

Instantly share code, notes, and snippets.

@zef
Created July 17, 2012 23:13
Show Gist options
  • Save zef/3132767 to your computer and use it in GitHub Desktop.
Save zef/3132767 to your computer and use it in GitHub Desktop.
class CellView < UIView
SIZE = 20
def initWithCell(cell)
if init
self.backgroundColor = UIColor.blackColor
# self.layer.cornerRadius = 4.0
# self.layer.cornerRadius = SIZE/2
self.frame = [[cell.x * SIZE, cell.y * SIZE], [SIZE, SIZE]]
emojify!
end
self
end
def emojify!
label = UILabel.alloc.init
label.text = emoji(:faces)
label.size = frame.size
label.adjustsFontSizeToFitWidth = true
label.textAlignment = UITextAlignmentCenter
self.addSubview(label)
end
private
def emoji(set = :faces)
size = EMOJI[set].size
EMOJI[set][rand(size)]
end
# Blank-looking spots also contain emoji
EMOJI = {
faces: %w[
๐Ÿ˜„ ๐Ÿ˜ƒ ๐Ÿ˜€ ๐Ÿ˜Š ๐Ÿ˜‰ ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿ˜š ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜œ ๐Ÿ˜ ๐Ÿ˜› ๐Ÿ˜ณ ๐Ÿ˜
๐Ÿ˜” ๐Ÿ˜Œ ๐Ÿ˜’ ๐Ÿ˜ž ๐Ÿ˜ฃ ๐Ÿ˜ข ๐Ÿ˜‚ ๐Ÿ˜ญ ๐Ÿ˜ช ๐Ÿ˜ฅ ๐Ÿ˜ฐ ๐Ÿ˜… ๐Ÿ˜“ ๐Ÿ˜ฉ ๐Ÿ˜ซ
๐Ÿ˜จ ๐Ÿ˜ฑ ๐Ÿ˜  ๐Ÿ˜ก ๐Ÿ˜ค ๐Ÿ˜– ๐Ÿ˜† ๐Ÿ˜‹ ๐Ÿ˜ท ๐Ÿ˜Ž ๐Ÿ˜ด ๐Ÿ˜ต ๐Ÿ˜ฒ ๐Ÿ˜Ÿ ๐Ÿ˜ฆ
๐Ÿ˜ง ๐Ÿ˜ˆ ๐Ÿ‘ฟ ๐Ÿ˜ฎ ๐Ÿ˜ฌ ๐Ÿ˜ ๐Ÿ˜• ๐Ÿ˜ฏ ๐Ÿ˜ถ ๐Ÿ˜‡ ๐Ÿ˜ ๐Ÿ˜‘ ๐Ÿ‘ฒ ๐Ÿ‘ณ ๐Ÿ‘ฎ
๐Ÿ‘ท ๐Ÿ’‚ ๐Ÿ‘ถ ๐Ÿ‘ฆ ๐Ÿ‘ง ๐Ÿ‘จ ๐Ÿ‘ฉ ๐Ÿ‘ด ๐Ÿ‘ต ๐Ÿ‘ฑ ๐Ÿ‘ผ ๐Ÿ‘ธ ๐Ÿ˜บ ๐Ÿ˜ธ ๐Ÿ˜ป
๐Ÿ˜ฝ ๐Ÿ˜ผ ๐Ÿ™€ ๐Ÿ˜ฟ ๐Ÿ˜น ๐Ÿ˜พ ๐Ÿ‘น ๐Ÿ‘บ ๐Ÿ™ˆ ๐Ÿ™‰ ๐Ÿ™Š ๐Ÿ’€ ๐Ÿ‘ฝ ๐Ÿ’ฉ
],
animals: %w[
๐Ÿถ ๐Ÿบ ๐Ÿฑ ๐Ÿญ ๐Ÿน ๐Ÿฐ ๐Ÿธ ๐Ÿฏ ๐Ÿจ ๐Ÿป ๐Ÿท ๐Ÿฝ ๐Ÿฎ ๐Ÿ— ๐Ÿต
๐Ÿ’ ๐Ÿด ๐Ÿ‘ ๐Ÿ˜ ๐Ÿผ ๐Ÿง ๐Ÿฆ ๐Ÿค ๐Ÿฅ ๐Ÿฃ ๐Ÿ” ๐Ÿ ๐Ÿข ๐Ÿ› ๐Ÿ
๐Ÿœ ๐Ÿž ๐ŸŒ ๐Ÿ™ ๐Ÿš ๐Ÿ  ๐ŸŸ ๐Ÿฌ ๐Ÿณ ๐Ÿ‹ ๐Ÿ„ ๐Ÿ ๐Ÿ€ ๐Ÿƒ ๐Ÿ…
๐Ÿ‡ ๐Ÿ‰ ๐ŸŽ ๐Ÿ ๐Ÿ“ ๐Ÿ• ๐Ÿ– ๐Ÿ ๐Ÿ‚ ๐Ÿฒ ๐Ÿก ๐ŸŠ ๐Ÿซ ๐Ÿช ๐Ÿ†
๐Ÿˆ ๐Ÿฉ
]
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment