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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abbb43a365628a35b51e78c233b2354231188fe1
4
- data.tar.gz: b3355e2945584261e6dca04228e5f71f0d26f7b0
3
+ metadata.gz: 2596e30fe64cd106c95bde71f34cc5720811c526
4
+ data.tar.gz: c73c688591c7331fced0a56d343b94c30297c3b1
5
5
  SHA512:
6
- metadata.gz: 5bf10fd1e103e03674ab7f8b0ccd1f1e8ab819bbb1d1c80c0b2231e4745bac7d7e34a546ea42e63c03f1cbfb6aa2015169a90776f701a7992eb631f59775ac7a
7
- data.tar.gz: 4dbaabd690111d18495f48513e70517b236dce8bee795f9760363905b52b4a150c77212e5ab4eb0ef8d56fbb45e0fbcdd916ca692b32dc63e976c6b5732fbc4a
6
+ metadata.gz: dd545c4fd43a29cb1318464e9754bd8123112eb4769286a60e58bc7e0d9e743f406aea692f387f73c14dc8f0c288ad05a8107d86ee9a296cf518875438eceba5
7
+ data.tar.gz: b41b9944ee1b8a765386cfe314f47850b2276786650e1eed7fb827f2c13c08fd53093e5ca80f1f83027f7198ce77483a52ee3b0256f64d91154b79da19a20ddd
@@ -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
- x = (background.columns / 2) - (frame.columns / 2)
14
- y = (background.rows / 2) - (frame.rows / 2)
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!(frame, x, y, Magick::OverCompositeOp)
18
-
19
- # Text with grime
20
- text = Magick::Draw.new
21
- text.annotate(result, 768, 824, x, 406, location.upcase) do
22
- self.gravity = Magick::CenterGravity
23
- self.pointsize = 255
24
- self.font = "#{resource_path}/fonts/champion-htf-featherweight.ttf"
25
- self.font_weight = Magick::NormalWeight
26
- self.tile = grime
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
- result.crop!(x, y, 768, 824)
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
@@ -1,3 +1,3 @@
1
1
  module StraightOutta
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  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.1
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-23 00:00:00.000000000 Z
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler