ruby_randimage 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDEzOGQwNjVkN2IwYzkwZjIyNzM1MjhjMzMxZDVmOGE2NGJjZWE4NQ==
4
+ ZGQ0OWM3NmE3NjdlZThiNmNkYmY2ZTlhNjE3YmI4YWM4ZDA5ZjQzOA==
5
5
  data.tar.gz: !binary |-
6
- NTQ0ZmU4OWU5ZjQ3MmY4NGYyMjYxYjAxNTRlMWVjODBlMTNmY2Y5Yw==
6
+ MWFlMTQ0ODJkNjY4Y2JmYzk4NWRiM2EwYmVjNWEyZWVkZWE2NWE3Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzVmMzQ2NjllZDA5MDNjNzdmZmU2ZDEwMjJmZTM4ZTc1YmMxZDRhYzM4MTFi
10
- ZmQzZjEyOTE4YjE5YTMyZTg2YWRhNjEwNTYyOGYwMTE5ZDk0ZDQyMWU4NzVl
11
- OGZhNWI2ZDkwY2UzYjIxZGNjNDA4ZmEwMGYxMzQ2Zjc2N2E4NGY=
9
+ YjkwNjljYWYyMTRhYjYwZTkzYmE3Mzc5NWRjNmVjYWE1YjY2YjliYjQ0ODRl
10
+ Y2MyNmExOTgwNzQyYTExNmY1ODllMzM2NzExM2IwZDQ3MTg4NGUzYjZmMDQ0
11
+ M2Q2NjY4MDc4MzJkMjVjMTY4YjI3MmViMmYxMmMzNGNlZDAyYmE=
12
12
  data.tar.gz: !binary |-
13
- MjBjM2NmYmYzMjU3N2NjMmIzYjBiZjAwYTg2Mjg5NjMyNGRkMjdiYjJiZGRi
14
- MjViZTk2NDFmYzczYTcxMWExZjc1MWZiM2UyM2RiMjJhZWZlNWNmNzI2MmU3
15
- ZDJiNmY4ZWQ1MjEwODAwM2IxYjZkZmVmODkzM2I5MGUyNmY1NDc=
13
+ MzcyOGExNWIxNDdjYjRiMzNjYzE4YTgyYzY4MWI1MmYxYzMxM2E5NjRhZTE2
14
+ NTllNDg3NGY5NWMyYTNiYmM4NmQ0ZGExY2U2NGVhYTk3MjhmZjhjMGY4ZmQ5
15
+ MzA4MDFmMDZlNzNlMjRlMGNiYjNkNzZmNzljNDcyMDExOTkwNGE=
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # RubyRandimage
2
2
 
3
+ <img src="http://ruby_randimage.monkeykoders.net/example1.svg" border="1" width="120">
4
+ <img src="http://ruby_randimage.monkeykoders.net/example2.svg" border="1" width="120">
5
+ <img src="http://ruby_randimage.monkeykoders.net/example3.svg" border="1" width="120">
6
+
3
7
  [![Build Status](https://travis-ci.org/santiriera626/ruby_randimage.svg?branch=master)](https://travis-ci.org/santiriera626/ruby_randimage)
4
8
  [![Coverage Status](https://coveralls.io/repos/github/santiriera626/ruby_randimage/badge.svg?branch=master)](https://coveralls.io/github/santiriera626/ruby_randimage?branch=master)
5
9
  [![Code Climate](https://codeclimate.com/github/santiriera626/ruby_randimage/badges/gpa.svg)](https://codeclimate.com/github/santiriera626/ruby_randimage)
@@ -12,6 +16,11 @@ A powerful, customizable and sophisticated awesome SVG avatars generator from se
12
16
 
13
17
  RubyRandimage is a pure Ruby library without any dependencies.
14
18
 
19
+ ## Demo App
20
+
21
+ We have implemented a demo app for you to try out: [Demo App](http://ruby_randimage.monkeykoders.net)
22
+
23
+ Here is the repository: [https://github.com/camumino/ruby_randimage_demoapp](https://github.com/camumino/ruby_randimage_demoapp)
15
24
 
16
25
  ## Installation
17
26
 
@@ -1,5 +1,5 @@
1
1
  require "ruby_randimage/version"
2
-
2
+ require "ruby_matrix_to_svg"
3
3
 
4
4
  # RubyRandimage creates a random image with the input values.
5
5
  # The image created has a width = num_cells and all the internal squares have a width of 1px
@@ -57,7 +57,7 @@ module RubyRandimage
57
57
  matrix = generate_matrix options[:num_cells], options[:colors], options[:symmetry_axes], options[:seed]
58
58
 
59
59
  # generate and return the svg string with matrix values
60
- return generate_svg options[:title], matrix
60
+ return RubyMatrixToSvg.matrix_to_svg options[:title], matrix
61
61
  end
62
62
 
63
63
  private
@@ -97,21 +97,21 @@ module RubyRandimage
97
97
  color = colors[rand(colors.length)]
98
98
 
99
99
  # fill cell
100
- cells[cell_x][cell_y] = color
100
+ cells[cell_y][cell_x] = color
101
101
 
102
102
  # mirror cell x_axis
103
103
  if symmetry_axes[0] && num_cells - 1 != 2*cell_x
104
- cells[num_cells - cell_x - 1][cell_y] = color
104
+ cells[cell_y][num_cells - cell_x - 1] = color
105
105
 
106
106
  # mirror cell x_axis and y_axis
107
107
  if symmetry_axes[1] && num_cells -1 != 2*cell_y
108
- cells[num_cells - cell_x - 1][num_cells - cell_y - 1] = color
108
+ cells[num_cells - cell_y - 1][num_cells - cell_x - 1] = color
109
109
  end
110
110
  end
111
111
 
112
112
  #mirror cell y_axis
113
113
  if symmetry_axes[1] && num_cells -1 != 2*cell_y
114
- cells[cell_x][ num_cells - cell_y-1 ] = color
114
+ cells[ num_cells - cell_y-1 ][cell_x] = color
115
115
  end
116
116
  end
117
117
 
@@ -119,36 +119,4 @@ module RubyRandimage
119
119
  return cells
120
120
  end
121
121
 
122
- # generate the svg string
123
- #
124
- # Example:
125
- # >> generate_svg("svg_title" , matrix)
126
- # => (String)
127
- #
128
- # @param title (String) the title of the svg image
129
- # @param matrix (Array[Array[(String)]]) the colors matrix
130
-
131
- def self.generate_svg title, matrix
132
-
133
- # open svg tag
134
- size = matrix.length
135
- svg = "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='#{size}' height='#{size}'>"
136
-
137
- # set title
138
- svg << "<title>#{title}</title>"
139
-
140
- # background with first color
141
- svg << "<rect width='100%' height='100%' x='0' y='0' fill='#{matrix[0][0]}' stroke='none' shape-rendering='crispEdges'/>"
142
-
143
- size.times do |col|
144
- size.times do |row|
145
- # draw rect if its color its different than background color
146
- svg << "<rect fill='#{matrix[col][row]}' stroke='none' fill-rule='nonzero' x='#{col}' y='#{row}' width='1' height='1' shape-rendering='crispEdges' />" if matrix[col][row] != matrix[0][0]
147
- end
148
- end
149
-
150
- # close svg tag
151
- svg << "</svg>"
152
-
153
- end
154
122
  end
@@ -1,3 +1,3 @@
1
1
  module RubyRandimage
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -32,5 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "bundler", "~> 1.5"
33
33
  spec.add_development_dependency "rake", "~> 10.0"
34
34
  spec.add_development_dependency 'rspec', "~> 3.4.0"
35
+
36
+ spec.add_dependency "ruby_matrix_to_svg", "~> 0.0.1"
35
37
 
36
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_randimage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - santiriera626
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2016-03-18 00:00:00.000000000 Z
13
+ date: 2016-03-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -54,6 +54,20 @@ dependencies:
54
54
  - - ~>
55
55
  - !ruby/object:Gem::Version
56
56
  version: 3.4.0
57
+ - !ruby/object:Gem::Dependency
58
+ name: ruby_matrix_to_svg
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: 0.0.1
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: 0.0.1
57
71
  description: ! ' A powerful, customizable and sophisticated awesome SVG avatars
58
72
  generator from several options such as symmetries, size, color palette and color
59
73
  densities.