quilt 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +6 -2
  2. data/examples/gen.rb +26 -0
  3. data/lib/quilt.rb +9 -8
  4. metadata +4 -3
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ DESCRIPTION = "a library for generating identicon."
18
18
  RUBYFORGE_PROJECT = "quilt"
19
19
  HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
20
20
  BIN_FILES = %w( )
21
- VERS = "0.0.2"
21
+ VERS = "0.0.3"
22
22
 
23
23
  REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
24
24
  CLEAN.include ['**/.*.sw?', '*.gem', '.config']
@@ -132,7 +132,11 @@ task :release => [:clean, :package] do |t|
132
132
  end
133
133
 
134
134
  desc 'Show information about the gem.'
135
- task :debug_gem do
135
+ task :debug_gemspec do
136
136
  puts spec.to_ruby
137
137
  end
138
138
 
139
+ desc 'Update information about the gem.'
140
+ task :update_gemspec do
141
+ open("#{NAME}.gemspec", 'w') { |f| f.puts spec.to_ruby }
142
+ end
data/examples/gen.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+
3
+ #require 'quilt'
4
+ require '../lib/quilt'
5
+
6
+
7
+ # 15.times do |i|
8
+ # icon = Quilt::Identicon.new rand(10000).to_s, :size => 100
9
+ # icon.write "file/#{i}.png"
10
+ # end
11
+
12
+ icon = Quilt::Identicon.new 'motemen'
13
+ icon.write "file/motemen.png"
14
+
15
+ icon = Quilt::Identicon.new 'motemen', :size => 30
16
+ icon.write "file/motemen30.png"
17
+
18
+ icon = Quilt::Identicon.new 'motemen', :size => 40
19
+ icon.write "file/motemen40.png"
20
+
21
+ icon = Quilt::Identicon.new 'motemen', :size => 100
22
+ icon.write "file/motemen100.png"
23
+
24
+ icon = Quilt::Identicon.new 'motemen', :size => 150
25
+ icon.write "file/motemen150.png"
26
+
data/lib/quilt.rb CHANGED
@@ -128,13 +128,13 @@ module Quilt
128
128
  @decode = decode @code
129
129
 
130
130
  if opt[:size]
131
- @scale = (((opt[:size] / 3) - 1) / (PATCH_SIZE - 1)) + 1
131
+ @scale = (opt[:size].to_f / (PATCH_SIZE * 3)).ceil
132
132
  @resize_to = opt[:size]
133
133
  else
134
134
  @scale = opt[:scale] || 1
135
135
  end
136
136
 
137
- @patch_width = (PATCH_SIZE - 1) * @scale + 1
137
+ @patch_width = PATCH_SIZE * @scale
138
138
  @image = @@image_lib.new @patch_width * 3, @patch_width * 3
139
139
  @back_color = @image.color 255, 255, 255
140
140
  @fore_color = @image.color @decode[:red], @decode[:green], @decode[:blue]
@@ -194,22 +194,23 @@ module Quilt
194
194
  else
195
195
  fore, back = @fore_color, @back_color
196
196
  end
197
- @image.fill_rect(x, y, x + @patch_width, y + @patch_width, back)
197
+ @image.fill_rect(x, y, x + @patch_width - 1, y + @patch_width - 1, back)
198
198
 
199
199
  points = []
200
200
  PATCHES[patch].each do |pt|
201
201
  dx = pt % PATCH_SIZE
202
202
  dy = pt / PATCH_SIZE
203
- px = dx.to_f / (PATCH_SIZE - 1) * @patch_width
204
- py = dy.to_f / (PATCH_SIZE - 1) * @patch_width
203
+ len = @patch_width - 1
204
+ px = dx.to_f / (PATCH_SIZE - 1) * len
205
+ py = dy.to_f / (PATCH_SIZE - 1) * len
205
206
 
206
207
  case turn
207
208
  when 1
208
- px, py = @patch_width - py, px
209
+ px, py = len - py, px
209
210
  when 2
210
- px, py = @patch_width - px, @patch_width - py
211
+ px, py = len - px, len - py
211
212
  when 3
212
- px, py = py, @patch_width - px
213
+ px, py = py, len - px
213
214
  end
214
215
  points << [x + px, y + py]
215
216
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - swdyh
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-19 00:00:00 +09:00
12
+ date: 2008-09-19 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,6 +30,7 @@ files:
30
30
  - test/quilt_test.rb
31
31
  - test/test_helper.rb
32
32
  - lib/quilt.rb
33
+ - examples/gen.rb
33
34
  - MIT-LICENSE
34
35
  has_rdoc: true
35
36
  homepage: http://quilt.rubyforge.org
@@ -64,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
65
  requirements: []
65
66
 
66
67
  rubyforge_project: quilt
67
- rubygems_version: 1.1.1
68
+ rubygems_version: 1.2.0
68
69
  signing_key:
69
70
  specification_version: 2
70
71
  summary: a library for generating identicon.