-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbounty.rb
52 lines (42 loc) · 1.21 KB
/
bounty.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env ruby
require 'rubygems'
require 'RMagick'
class Image
attr_reader :blob
def initialize(blob)
@blob = blob
end
def to_s()
"Image (#{@blob.length} bytes)"
end
end
def bounty_image(domain, bounties, reputation)
if (bounties == 0)
return Image.new(IO.read('./resources/no-bounties.png'))
end
bg = Magick::ImageList.new('./resources/bottom.png')
fg = Magick::ImageList.new('./resources/top.png')
values = Magick::Draw.new
gravity = Magick::CenterGravity
bountyCountFont = './resources/Helvetica.ttf'
repFont = './resources/Anonymous Pro B.ttf'
# Doing the lower value first, otherwise the kerning value in the bounty
# count screws up the bounty value
values.annotate(bg, 250, 80, 204, 414, reputation.to_s) do
self.pointsize = 42
self.font = repFont
self.stroke = 'transparent'
self.fill = '#3B3B3B'
self.gravity = gravity
end
values.annotate(bg, 250, 80, 180, 200, ('%02d' % bounties.to_s)) do
self.pointsize = 184
self.font = bountyCountFont
self.font_family = 'Helvetica'
self.stroke = 'transparent'
self.fill = '#2F2F2F'
self.gravity = gravity
self.kerning = 88
end
Image.new(bg.composite_layers(fg).to_blob)
end