cahdmaker 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30f67fef384dee6694cf49ea9398844fba5447fa
4
- data.tar.gz: b62963cadf21282d2dfc170b732e286d64afc233
3
+ metadata.gz: c903bd8df0db8f3a4587d0111abb6b43dc5b625f
4
+ data.tar.gz: 7e2c23c86faf29b4149f97513041deb4af723ad9
5
5
  SHA512:
6
- metadata.gz: de4d4fc30d9541b1221b278921b1808d97f7b57e2e29a47555032356d527fad742744f7373680f51eece8bf00bf52e797a8380ba511aa0153934cc17a51e56ab
7
- data.tar.gz: be5e8ff5be76ff21c05bea465727a93b8cbb854f5f1b94e6ebc48d22d84d9edebb362155d112a27262cc71443031c0fa18efcc3dd7d50e72894d253b0a93654f
6
+ metadata.gz: bcb72bf5ab7ce2dbeb7c27dd999de19d3595634cc5ea033e9ab9d72bfb57f8e49b11ef61a38321a52c855016792f7e373c5549dddea76e13f80939a8d6363622
7
+ data.tar.gz: 6f21f322242f360739005f7422db9df3e4540c1f4899dee76f83936558666529266f416457a101e17cbb7fb5ac1758282048473baa51529711099df2086ff037
@@ -7,11 +7,11 @@ module Cahdmaker
7
7
  attr_reader :opts
8
8
 
9
9
  def initialize(opts={})
10
- @opts = { text_size: 60, blank_size: 10, font: 'Helvetica-Bold' }.merge(opts)
10
+ @opts = { text_size: 60, blank_size: 10, bleed: 0, resolution: 300, font: 'Helvetica-Bold' }.merge(opts)
11
11
  end
12
12
 
13
13
  def black(text, pick=1, &block)
14
- make_card(text, "Black#{pick}", &block)
14
+ make_card(text, "black#{pick}".to_sym, &block)
15
15
  end
16
16
 
17
17
  def black2(text, &block)
@@ -23,27 +23,71 @@ module Cahdmaker
23
23
  end
24
24
 
25
25
  def white(text, &block)
26
- make_card(text, "White", &block)
26
+ make_card(text, :white, &block)
27
+ end
28
+
29
+ def px(ins, bleed=nil)
30
+ bleed ||= opts[:bleed]/2
31
+ (ins * opts[:resolution]) + bleed
32
+ end
33
+
34
+ def logo(black_card)
35
+ logo = Magick::Draw.new
36
+ logo.stroke_color('black')
37
+ logo.stroke_opacity(0.8)
38
+ logo.stroke_linecap('round')
39
+ logo.stroke_linejoin('round')
40
+ logo.stroke_width((0.75/72)*opts[:resolution])
41
+
42
+ fan_x = px(0.03,0)
43
+ fan_y = px(0.01,0)
44
+
45
+ logo.translate(px(0.40),px(3.20))
46
+
47
+ logo.translate(-fan_x,fan_y)
48
+ logo.rotate(-15)
49
+ logo.fill(black_card ? 'grey49' : 'black')
50
+ logo.rectangle(px(-0.075,0), px(-0.150,0), px(0.075,0), 0)
51
+
52
+ logo.rotate(15)
53
+ logo.translate(fan_x,-fan_y)
54
+ logo.fill(black_card ? 'grey69' : 'grey49')
55
+ logo.rectangle(px(-0.075,0), px(-0.150,0), px(0.075,0), 0)
56
+
57
+ logo.translate(fan_x,fan_y)
58
+ logo.rotate(15)
59
+ logo.fill('white')
60
+ logo.rectangle(px(-0.075,0), px(-0.150,0), px(0.075,0), 0)
27
61
  end
28
62
 
29
63
  def make_card(text, source_card)
64
+ bleed = opts[:bleed].to_i
65
+ resolution = opts[:resolution].to_i
30
66
  text_size = opts[:text_size].to_i
31
- color = source_card =~ /White/i ? 'black' : 'white'
67
+ black_card = source_card == :white ? false : true
68
+ background_color = black_card ? 'black' : 'white'
69
+ color = black_card ? 'white' : 'black'
32
70
  font = opts[:font]
33
71
  text.gsub! /\b_+\b/, ('_' * opts[:blank_size])
34
-
72
+ card_width = px(2.0, bleed);
73
+ multiplier = resolution / 300
74
+
35
75
  cap = Magick::Image.read(%{caption:#{text}}) do
36
- self.size = '600x'
76
+ self.size = "#{card_width}x"
37
77
  self.background_color = 'transparent'
38
- self.pointsize = text_size.to_f
39
- self['interline-spacing'] = (text_size/3).to_f
78
+ self.pointsize = text_size.to_f * multiplier
79
+ self['interline-spacing'] = (text_size/3).to_f * multiplier
40
80
  self.font = font
41
81
  self.fill = color
42
82
  end.first
83
+ cap.x_resolution = cap.y_resolution = resolution
43
84
 
44
- img = Magick::Image.read(File.expand_path("../../cards/CAH_#{source_card}.png",__FILE__)).first
45
- img.x_resolution = img.y_resolution = 300
46
- img.composite!(cap, 75, 75, Magick::OverCompositeOp)
85
+ img = Magick::Image.new(px(2.5,bleed),px(3.5,bleed)) do
86
+ self.background_color = background_color
87
+ end
88
+ img.x_resolution = img.y_resolution = resolution
89
+ logo(black_card).draw(img)
90
+ img.composite!(cap, px(0.25), px(0.25), Magick::OverCompositeOp)
47
91
  if block_given?
48
92
  yield(img)
49
93
  else
@@ -1,3 +1,3 @@
1
1
  module Cahdmaker
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: cahdmaker
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
  - Michael Klein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-08 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick
@@ -67,10 +67,6 @@ files:
67
67
  - Rakefile
68
68
  - bin/cahdmaker
69
69
  - cahdmaker.gemspec
70
- - cards/CAH_Black1.png
71
- - cards/CAH_Black2.png
72
- - cards/CAH_Black3.png
73
- - cards/CAH_White.png
74
70
  - lib/cahdmaker.rb
75
71
  - lib/cahdmaker/version.rb
76
72
  homepage: ''
Binary file
Binary file
Binary file
Binary file