straight_outta 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/straight_outta.rb +30 -13
- data/lib/straight_outta/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2596e30fe64cd106c95bde71f34cc5720811c526
|
|
4
|
+
data.tar.gz: c73c688591c7331fced0a56d343b94c30297c3b1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dd545c4fd43a29cb1318464e9754bd8123112eb4769286a60e58bc7e0d9e743f406aea692f387f73c14dc8f0c288ad05a8107d86ee9a296cf518875438eceba5
|
|
7
|
+
data.tar.gz: b41b9944ee1b8a765386cfe314f47850b2276786650e1eed7fb827f2c13c08fd53093e5ca80f1f83027f7198ce77483a52ee3b0256f64d91154b79da19a20ddd
|
data/lib/straight_outta.rb
CHANGED
|
@@ -3,6 +3,8 @@ require "rmagick"
|
|
|
3
3
|
|
|
4
4
|
module StraightOutta
|
|
5
5
|
def self.somewhere(location, file_path)
|
|
6
|
+
location = location.upcase
|
|
7
|
+
|
|
6
8
|
spec = Gem::Specification.find_by_name('straight_outta')
|
|
7
9
|
resource_path = "#{spec.gem_dir}/resources"
|
|
8
10
|
|
|
@@ -10,24 +12,39 @@ module StraightOutta
|
|
|
10
12
|
frame = Magick::Image.read("#{resource_path}/images/logo-frame-2x.png").first
|
|
11
13
|
grime = Magick::Image.read("#{resource_path}/images/pattern-grime.jpg").first
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
crop_x = (background.columns / 2) - (frame.columns / 2)
|
|
16
|
+
crop_y = (background.rows / 2) - (frame.rows / 2)
|
|
17
|
+
|
|
18
|
+
# Crop background to the frame
|
|
19
|
+
background.crop!(crop_x, crop_y, frame.columns, frame.rows)
|
|
15
20
|
|
|
16
21
|
# Composite background and frame
|
|
17
|
-
result = background.composite
|
|
18
|
-
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
result = background.composite(frame, 0, 0, Magick::OverCompositeOp)
|
|
23
|
+
|
|
24
|
+
# User-specified location text
|
|
25
|
+
gc = Magick::Draw.new
|
|
26
|
+
gc.gravity = Magick::CenterGravity
|
|
27
|
+
gc.font = "#{resource_path}/fonts/champion-htf-featherweight.ttf"
|
|
28
|
+
gc.font_weight = Magick::NormalWeight
|
|
29
|
+
pointsize = 250
|
|
30
|
+
gc.pointsize = pointsize
|
|
31
|
+
|
|
32
|
+
# Calculate pointsize down if text width is wider than the frame
|
|
33
|
+
metrics = gc.get_type_metrics(location)
|
|
34
|
+
while metrics[:width] > result.columns - 20
|
|
35
|
+
pointsize = pointsize - 1
|
|
36
|
+
gc.pointsize = pointsize
|
|
37
|
+
metrics = gc.get_type_metrics(location)
|
|
27
38
|
end
|
|
28
39
|
|
|
29
|
-
|
|
40
|
+
gc.tile = grime
|
|
41
|
+
gc_width = 0
|
|
42
|
+
gc_height = 0
|
|
43
|
+
gc_pos_x = 0
|
|
44
|
+
gc_pos_y = 318
|
|
45
|
+
gc.annotate(result, gc_width, gc_height, gc_pos_x, gc_pos_y, location)
|
|
30
46
|
|
|
47
|
+
result.format = 'png'
|
|
31
48
|
result.write(file_path)
|
|
32
49
|
end
|
|
33
50
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: straight_outta
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Moore
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-10-
|
|
11
|
+
date: 2016-10-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|