fastlane-plugin-framer 0.2.0 → 0.2.1

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: ead286739a4dc5358d1ce3b78445e2be9d1b998b
4
- data.tar.gz: 52b60581ce5c3dda8011a98b38e52aaa36395558
3
+ metadata.gz: 0e9290f3e19124b67452ff24982ca4f1eff09b19
4
+ data.tar.gz: 4f5b1035d851c4c5b6dab6aca9c7f9f597faa639
5
5
  SHA512:
6
- metadata.gz: 0f04aabf6c588370a376dc7b9feb44cc8fb5d6209a63025a0958d5095893abb3b0146ed386c7c588ad6c03f6c889869287cc8eaa401192b957256226d443c8d0
7
- data.tar.gz: 163a4fe66cd172c1b9d75b71789565eb952dbe943cb657c35ac5bec196f4935283c9abf77f891fd579b18c19611718410044c5b231777e3c348db63fba0ed70f
6
+ metadata.gz: 803aa2a181b6d28ee43cfb7231308d678ae9aec6b4c82a0aa0234e572854d414da72326b396a7c019ed2bebcf900a256cbae73b20572d3ea409bc2b6ec6c8dfc
7
+ data.tar.gz: a4604d3b991a74bcbab6ea41aa5b9b959d9369ebc1c83d4e5b52c837260faf42411f3ce5432b82449a88217627c0256594f23d2c54f57b622f50e68128ace342
data/README.md CHANGED
@@ -79,7 +79,8 @@ There are keys for configuring screeshot and for the text.
79
79
  | Key | Type | Description |
80
80
  | -------------- | --------:| ------------:|
81
81
  | `offset` | String | Pixel position in the format `+[X value]+[Y value]` |
82
- | `width` | Number | space available, in pixel, for the screen |
82
+ | `width` | Number | space available, in pixel, for the screen |
83
+ | `add_below` | Boolean | add screen below the template or not |
83
84
 
84
85
  #### Text
85
86
 
@@ -8,7 +8,7 @@ module Fastlane
8
8
  attr_accessor :size
9
9
 
10
10
  attr_accessor :file
11
- attr_accessor :imageOffset, :imageWidth
11
+ attr_accessor :imageOffset, :imageWidth, :imageBelow
12
12
  attr_accessor :textOffsetX, :textOffsetY, :textWidth, :textHeight, :textPadding, :textSize, :textFont, :textColor
13
13
  end
14
14
 
@@ -90,6 +90,7 @@ module Fastlane
90
90
  # Set config
91
91
  template.imageOffset = (config_custom['image'] && config_custom['image']['offset']) || (config_default['image'] && config_default['image']['offset'])
92
92
  template.imageWidth = (config_custom['image'] && config_custom['image']['width']) || (config_default['image'] && config_default['image']['width'])
93
+ template.imageBelow = (config_custom['image'] && config_custom['image']['add_below']) || (config_default['image'] && config_default['image']['add_below']) || false
93
94
 
94
95
  template.textColor = (config_custom['text'] && config_custom['text']['color']) || (config_default['text'] && config_default['text']['color'])
95
96
  template.textFont = (config_custom['text'] && config_custom['text']['font']) || (config_default['text'] && config_default['text']['font'])
@@ -158,6 +159,7 @@ module Fastlane
158
159
  end
159
160
 
160
161
  def self.combine(screenshot_file, template, text, output_file)
162
+
161
163
  # Get template image
162
164
  template_img = MiniMagick::Image.open(template.file)
163
165
 
@@ -168,11 +170,37 @@ module Fastlane
168
170
  screenshot_img.resize "#{template.imageWidth}x"
169
171
 
170
172
  # Put screenshot over template
171
- result_img = template_img.composite(screenshot_img) do |c|
172
- c.compose "Over"
173
- c.geometry template.imageOffset.to_s
173
+ if template.imageBelow
174
+
175
+ # Create a blank image
176
+ base_1_img = MiniMagick::Image.open("#{Framer::ROOT}/assets/background.png")
177
+ base_1_img.resize "#{template.size}!" # `!` says it should ignore the ratio
178
+
179
+ # Screenshot first
180
+ base_2_img = base_1_img.composite(screenshot_img) do |c|
181
+ c.compose "Over"
182
+ c.geometry template.imageOffset.to_s
183
+ end
184
+
185
+ # Template second
186
+ result_img = base_2_img.composite(template_img) do |c|
187
+ c.compose "Over"
188
+ end
189
+
190
+ base_1_img.destroy!
191
+ base_2_img.destroy!
192
+
193
+ else
194
+
195
+ # Screenshot over template, in one shot
196
+ result_img = template_img.composite(screenshot_img) do |c|
197
+ c.compose "Over"
198
+ c.geometry template.imageOffset.to_s
199
+ end
200
+
174
201
  end
175
202
 
203
+ # Apply text, if any
176
204
  unless text.nil?
177
205
  # Clean text string before using it
178
206
  text.gsub! '\n', "\n"
@@ -227,6 +255,7 @@ module Fastlane
227
255
  result_img.destroy!
228
256
  screenshot_img.destroy!
229
257
  template_img.destroy!
258
+
230
259
  end
231
260
 
232
261
  def self.create_dir_if_not_exists(path)
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Framer
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-framer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - DrAL3X
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-10 00:00:00.000000000 Z
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick