Commit 3ae1ad90d749b1926f4e0bf5da9ec407859a77f5

Authored by Krzysiek Szczuka
Committed by GitHub
2 parents 8c5f3261 e8c90d7a
Exists in master

Merge pull request #13 from aafaq-hassan/master

letter_count and pointsize configurations added
CHANGELOG.md
  1 +0.3.6
  2 +-----
  3 +
  4 +- added `LetterAvatar.letters_count` config option.
  5 +- added `LetterAvatar.pointsize` config option.
  6 +
1 7 0.3.5
2 8 -----
3 9  
... ...
README.md
... ... @@ -54,6 +54,8 @@ LetterAvatar.setup do |config|
54 54 config.colors_palette = :iwanthue # default is :google
55 55 config.weight = 500 # default is 300
56 56 config.annotate_position = '-0+10' # default is -0+5
  57 +  config.letters_count = 2 # default is 1
  58 + config.pointsize = 70 # default is 140
57 59 end
58 60 ```
59 61  
... ...
lib/letter_avatar/avatar.rb
... ... @@ -18,7 +18,8 @@ module LetterAvatar
18 18 def self.from_username(username)
19 19 identity = new
20 20 identity.color = LetterAvatar::Colors.for(username)
21   - identity.letter = username[0].upcase
  21 + letters = username.split(/\s+/).map {|word| word[0]}.join('')[0..LetterAvatar.letters_count - 1]
  22 + identity.letter = letters.upcase
22 23  
23 24 identity
24 25 end
... ... @@ -65,7 +66,7 @@ module LetterAvatar
65 66 convert
66 67 -size #{FULLSIZE}x#{FULLSIZE}
67 68 xc:#{to_rgb(identity.color)}
68   - -pointsize 140
  69 + -pointsize #{LetterAvatar.pointsize}
69 70 -font #{FONT_FILENAME}
70 71 -weight #{LetterAvatar.weight}
71 72 -fill '#{LetterAvatar.fill_color}'
... ...
lib/letter_avatar/configuration.rb
... ... @@ -39,5 +39,21 @@ module LetterAvatar
39 39 def annotate_position=(v)
40 40 @annotate_position = v
41 41 end
  42 +
  43 + def letters_count
  44 + @letters_count ||= 1
  45 + end
  46 +
  47 + def letters_count=(v)
  48 + @letters_count = v
  49 + end
  50 +
  51 + def pointsize
  52 + @pointsize ||= 140
  53 + end
  54 +
  55 + def pointsize=(v)
  56 + @pointsize = v
  57 + end
42 58 end
43 59 end
... ...
lib/letter_avatar/version.rb
1 1 module LetterAvatar
2   - VERSION = '0.3.5'
  2 + VERSION = '0.3.6'
3 3 end
... ...