flurin-buttonize 0.1.4 → 0.2.0

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.
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "buttonize"
3
- s.version = "0.1.4"
4
- s.date = "2009-01-25"
3
+ s.version = "0.2.0"
4
+ s.date = "2009-05-22"
5
5
 
6
6
  s.authors = ["Flurin Egger"]
7
7
  s.email = "f.p.egger@gmail.com"
@@ -1,6 +1,8 @@
1
1
  require File.dirname(__FILE__) + "/../lib/buttonize"
2
+ require 'pathname'
3
+ base = Pathname.new(File.dirname(__FILE__))
2
4
 
3
- buttons = Buttonize::ButtonSet.define(:style_set => :default) do |set|
5
+ buttons = Buttonize::ButtonSet.define(:style_file => base + "default/styles.rb", :style_set => :default) do |set|
4
6
 
5
7
  set.button "Test", :style => :small_green
6
8
 
@@ -20,4 +22,4 @@ buttons = Buttonize::ButtonSet.define(:style_set => :default) do |set|
20
22
  end
21
23
 
22
24
  # This will not be ran if you use the buttonize commandline script
23
- buttons.generate(:target_path => "~/temp/button_out")
25
+ buttons.generate(:target_path => File.expand_path("~/temp/button_out"))
@@ -30,6 +30,13 @@ Buttonize::StyleSet.define(:template_path => File.dirname(__FILE__)) do |set|
30
30
  s.text_offset = {:x => 0, :y => 0}
31
31
 
32
32
 
33
+ # Simple text shadow.
34
+ s.text_shadow = true
35
+ # Placement of the shadow relative to the original text.
36
+ s.text_shadow_offset = {:x => 1, :y => 1}
37
+ # Color of the shadow.
38
+ s.text_shadow_color = "#000"
39
+
33
40
  # If width is set (not nil) Buttonize will try to create a button of
34
41
  # the specified width, if the text will however not fit (including paddings)
35
42
  # Buttonize falls back on rendering the text with the specified paddings (see below)
@@ -48,7 +55,7 @@ Buttonize::StyleSet.define(:template_path => File.dirname(__FILE__)) do |set|
48
55
  set.style(:big_green, :based_on => :big_blue, :template_base => "big_green")
49
56
 
50
57
  # Inline style definition with a Hash
51
- set.style(:small_blue, :font => File.join(File.dirname(__FILE__),"fonts","Vera.ttf"), :font_size => 9, :template_base => "small_blue", :width => 65)
58
+ set.style(:small_blue, :font => File.join(File.dirname(__FILE__),"fonts","Vera-Bold.ttf"), :font_size => 9, :template_base => "small_blue", :width => 65)
52
59
  set.style(:small_orange, :based_on => :small_blue, :template_base => "small_orange")
53
60
  set.style(:small_red, :based_on => :small_blue, :template_base => "small_red")
54
61
  set.style(:small_green, :based_on => :small_blue, :template_base => "small_green")
@@ -13,6 +13,9 @@ class Buttonize::Button
13
13
  :text_color => "#fff",
14
14
  :text_offset => {:x => 0, :y => 0},
15
15
  :text_align => :center,
16
+ :text_shadow => false,
17
+ :text_shadow_offset => {:x => 1, :y => 1},
18
+ :text_shadow_color => "#000",
16
19
  :padding => {:left => 10, :right => 10},
17
20
  :target_path => Dir.pwd
18
21
  }.update(options)
@@ -36,7 +39,6 @@ class Buttonize::Button
36
39
 
37
40
  draw = Draw.new
38
41
  draw.pointsize = options[:font_size]
39
- draw.fill = options[:text_color]
40
42
  draw.gravity = self.gravity_from_alignment(options[:text_align])
41
43
  draw.font = options[:font]
42
44
  draw.font_weight = Magick::AnyWeight
@@ -74,6 +76,12 @@ class Buttonize::Button
74
76
  # Draw text
75
77
  left = options[:text_offset][:x] || 0
76
78
  left += padding[:left] unless options[:text_align] == :center
79
+
80
+ if options[:text_shadow]
81
+ draw.fill = options[:text_shadow_color]
82
+ draw.annotate(dst,0,0,left+options[:text_shadow_offset][:x],options[:text_offset][:y]++options[:text_shadow_offset][:y],text)
83
+ end
84
+ draw.fill = options[:text_color]
77
85
  draw.annotate(dst,0,0,left,options[:text_offset][:y],text)
78
86
 
79
87
  # Write file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flurin-buttonize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flurin Egger
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-25 00:00:00 -08:00
12
+ date: 2009-05-22 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency