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
|
# File 'lib/straight_outta.rb', line 5
def self.somewhere(location, file_path)
location = location.upcase
spec = Gem::Specification.find_by_name('straight_outta')
resource_path = "#{spec.gem_dir}/resources"
background = Magick::Image.read("#{resource_path}/images/bg-black4.jpg").first
frame = Magick::Image.read("#{resource_path}/images/logo-frame-2x.png").first
grime = Magick::Image.read("#{resource_path}/images/pattern-grime.jpg").first
crop_x = (background.columns / 2) - (frame.columns / 2)
crop_y = (background.rows / 2) - (frame.rows / 2)
background.crop!(crop_x, crop_y, frame.columns, frame.rows)
result = background.composite(frame, 0, 0, Magick::OverCompositeOp)
gc = Magick::Draw.new
gc.gravity = Magick::CenterGravity
gc.font = "#{resource_path}/fonts/champion-htf-featherweight.ttf"
gc.font_weight = Magick::NormalWeight
pointsize = 250
gc.pointsize = pointsize
metrics = gc.get_type_metrics(location)
while metrics[:width] > result.columns - 20
pointsize = pointsize - 1
gc.pointsize = pointsize
metrics = gc.get_type_metrics(location)
end
gc.tile = grime
gc_width = 0
gc_height = 0
gc_pos_x = 0
gc_pos_y = 318
gc.annotate(result, gc_width, gc_height, gc_pos_x, gc_pos_y, location)
result.format = 'png'
result.write(file_path)
end
|