Skip to content

Commit

Permalink
Merge pull request #13 from aafaq-hassan/master
Browse files Browse the repository at this point in the history
letter_count and pointsize configurations added
  • Loading branch information
ksz2k authored May 12, 2017
2 parents 8c5f326 + e8c90d7 commit 3ae1ad9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.3.6
-----

- added `LetterAvatar.letters_count` config option.
- added `LetterAvatar.pointsize` config option.

0.3.5
-----

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ LetterAvatar.setup do |config|
config.colors_palette = :iwanthue # default is :google
config.weight = 500 # default is 300
config.annotate_position = '-0+10' # default is -0+5
 config.letters_count = 2 # default is 1
config.pointsize = 70 # default is 140
end
```

Expand Down
5 changes: 3 additions & 2 deletions lib/letter_avatar/avatar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Identity
def self.from_username(username)
identity = new
identity.color = LetterAvatar::Colors.for(username)
identity.letter = username[0].upcase
letters = username.split(/\s+/).map {|word| word[0]}.join('')[0..LetterAvatar.letters_count - 1]
identity.letter = letters.upcase

identity
end
Expand Down Expand Up @@ -65,7 +66,7 @@ def generate_fullsize(identity)
convert
-size #{FULLSIZE}x#{FULLSIZE}
xc:#{to_rgb(identity.color)}
-pointsize 140
-pointsize #{LetterAvatar.pointsize}
-font #{FONT_FILENAME}
-weight #{LetterAvatar.weight}
-fill '#{LetterAvatar.fill_color}'
Expand Down
16 changes: 16 additions & 0 deletions lib/letter_avatar/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,21 @@ def annotate_position
def annotate_position=(v)
@annotate_position = v
end

def letters_count
@letters_count ||= 1
end

def letters_count=(v)
@letters_count = v
end

def pointsize
@pointsize ||= 140
end

def pointsize=(v)
@pointsize = v
end
end
end
2 changes: 1 addition & 1 deletion lib/letter_avatar/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module LetterAvatar
VERSION = '0.3.5'
VERSION = '0.3.6'
end

0 comments on commit 3ae1ad9

Please sign in to comment.