mosaiq 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +15 -5
- data/documentation/example_black_and_white.svg +1 -0
- data/documentation/example_grays.svg +1 -0
- data/documentation/example_random_colors_8.svg +1 -0
- data/documentation/{example.svg → example_red_green_blue.svg} +0 -0
- data/lib/mosaiq/image.rb +1 -1
- data/lib/mosaiq/palette.rb +22 -0
- data/lib/mosaiq/version.rb +1 -1
- data/lib/mosaiq.rb +1 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9467adff2eb89abcec732cf6182e1a6c660c82ad7f4d6d854753f7ad3c2d5664
|
4
|
+
data.tar.gz: 7dd7ce113284a6ef78d0051994c14a460264d9154819a0f30ee0de0281e32299
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60968a2d1b740d6a8856d2da4f387cc10bdc47e4e1553e8e1299ea12e5d5b09ca3d49f5d289b3a59e8457104ae7929b17ec6c048afd52a689b6a82d3dc8143a9
|
7
|
+
data.tar.gz: 487ccf1b840cd9a7d501fd64261cc0e5560c085dd97cfb22f1c05322c6b0a9fee2c2ac174681a3e889f9b31d3f01ea8adb4fd57a291db7d285591a1589466a39
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -27,20 +27,30 @@ Currently only SVG is supported.
|
|
27
27
|
### SVG
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
mosaiq = Mosaiq::Image.new(3, 4, %w[red blue
|
30
|
+
mosaiq = Mosaiq::Image.new(3, 4, %w[red green blue])
|
31
31
|
puts mosaiq.svg
|
32
32
|
# => <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" viewBox="0 0 4 3" version="1.1" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="0" width="1" height="1" style="fill: blue;"/><rect x="0" y="1" width="1" height="1" style="fill: green;"/><rect x="0" y="2" width="1" height="1" style="fill: red;"/><rect x="1" y="0" width="1" height="1" style="fill: red;"/><rect x="1" y="1" width="1" height="1" style="fill: red;"/><rect x="1" y="2" width="1" height="1" style="fill: red;"/><rect x="2" y="0" width="1" height="1" style="fill: blue;"/><rect x="2" y="1" width="1" height="1" style="fill: blue;"/><rect x="2" y="2" width="1" height="1" style="fill: red;"/><rect x="3" y="0" width="1" height="1" style="fill: red;"/><rect x="3" y="1" width="1" height="1" style="fill: blue;"/><rect x="3" y="2" width="1" height="1" style="fill: red;"/></svg>
|
33
33
|
```
|
34
34
|
|
35
35
|
which looks like this when saved to a file
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
| Result |
|
38
|
+
|---------------------------------------------------------------|
|
39
|
+
| ![Example mosaiq](./documentation/example_red_green_blue.svg) |
|
40
40
|
|
41
41
|
* The first argument is the `width` of the image.
|
42
42
|
* The second argument is the `height` of the image.
|
43
|
-
* The third argument is an array of color names. Any HTML
|
43
|
+
* The third argument is an array of color names. Any valid HTML color names will do.
|
44
|
+
|
45
|
+
## Palette
|
46
|
+
|
47
|
+
There are three predefined "Palettes" of colors:
|
48
|
+
|
49
|
+
| Palette | Example | Result |
|
50
|
+
|--------------------|---------------------------------------------------------------|-------------------------------------------------------------------------|
|
51
|
+
| `black_and_white` | `Mosaiq::Image.new(10, 5, Mosaiq::Palette::black_and_white)` | ![Example black_and_white](./documentation/example_black_and_white.svg) |
|
52
|
+
| `grays` | `Mosaiq::Image.new(10, 5, Mosaiq::Palette::grays)` | ![Example grays](./documentation/example_grays.svg) |
|
53
|
+
| `random_colors(n)` | `Mosaiq::Image.new(10, 5, Mosaiq::Palette::random_colors(8))` | ![Example random_colors](./documentation/example_random_colors_8.svg) |
|
44
54
|
|
45
55
|
|
46
56
|
## Development
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" viewBox="0 0 10 5" version="1.1" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="0" width="1" height="1" style="fill: #ffffff;"/><rect x="1" y="0" width="1" height="1" style="fill: #000000;"/><rect x="2" y="0" width="1" height="1" style="fill: #000000;"/><rect x="3" y="0" width="1" height="1" style="fill: #ffffff;"/><rect x="4" y="0" width="1" height="1" style="fill: #000000;"/><rect x="5" y="0" width="1" height="1" style="fill: #ffffff;"/><rect x="6" y="0" width="1" height="1" style="fill: #000000;"/><rect x="7" y="0" width="1" height="1" style="fill: #000000;"/><rect x="8" y="0" width="1" height="1" style="fill: #000000;"/><rect x="9" y="0" width="1" height="1" style="fill: #000000;"/><rect x="0" y="1" width="1" height="1" style="fill: #ffffff;"/><rect x="1" y="1" width="1" height="1" style="fill: #ffffff;"/><rect x="2" y="1" width="1" height="1" style="fill: #000000;"/><rect x="3" y="1" width="1" height="1" style="fill: #ffffff;"/><rect x="4" y="1" width="1" height="1" style="fill: #000000;"/><rect x="5" y="1" width="1" height="1" style="fill: #ffffff;"/><rect x="6" y="1" width="1" height="1" style="fill: #000000;"/><rect x="7" y="1" width="1" height="1" style="fill: #ffffff;"/><rect x="8" y="1" width="1" height="1" style="fill: #000000;"/><rect x="9" y="1" width="1" height="1" style="fill: #000000;"/><rect x="0" y="2" width="1" height="1" style="fill: #ffffff;"/><rect x="1" y="2" width="1" height="1" style="fill: #ffffff;"/><rect x="2" y="2" width="1" height="1" style="fill: #000000;"/><rect x="3" y="2" width="1" height="1" style="fill: #000000;"/><rect x="4" y="2" width="1" height="1" style="fill: #ffffff;"/><rect x="5" y="2" width="1" height="1" style="fill: #000000;"/><rect x="6" y="2" width="1" height="1" style="fill: #000000;"/><rect x="7" y="2" width="1" height="1" style="fill: #ffffff;"/><rect x="8" y="2" width="1" height="1" style="fill: #000000;"/><rect x="9" y="2" width="1" height="1" style="fill: #ffffff;"/><rect x="0" y="3" width="1" height="1" style="fill: #000000;"/><rect x="1" y="3" width="1" height="1" style="fill: #ffffff;"/><rect x="2" y="3" width="1" height="1" style="fill: #000000;"/><rect x="3" y="3" width="1" height="1" style="fill: #000000;"/><rect x="4" y="3" width="1" height="1" style="fill: #ffffff;"/><rect x="5" y="3" width="1" height="1" style="fill: #000000;"/><rect x="6" y="3" width="1" height="1" style="fill: #ffffff;"/><rect x="7" y="3" width="1" height="1" style="fill: #ffffff;"/><rect x="8" y="3" width="1" height="1" style="fill: #000000;"/><rect x="9" y="3" width="1" height="1" style="fill: #ffffff;"/><rect x="0" y="4" width="1" height="1" style="fill: #ffffff;"/><rect x="1" y="4" width="1" height="1" style="fill: #ffffff;"/><rect x="2" y="4" width="1" height="1" style="fill: #ffffff;"/><rect x="3" y="4" width="1" height="1" style="fill: #000000;"/><rect x="4" y="4" width="1" height="1" style="fill: #ffffff;"/><rect x="5" y="4" width="1" height="1" style="fill: #ffffff;"/><rect x="6" y="4" width="1" height="1" style="fill: #000000;"/><rect x="7" y="4" width="1" height="1" style="fill: #000000;"/><rect x="8" y="4" width="1" height="1" style="fill: #000000;"/><rect x="9" y="4" width="1" height="1" style="fill: #000000;"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" viewBox="0 0 10 5" version="1.1" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="0" width="1" height="1" style="fill: rgb(2, 2, 2);"/><rect x="1" y="0" width="1" height="1" style="fill: rgb(39, 39, 39);"/><rect x="2" y="0" width="1" height="1" style="fill: rgb(74, 74, 74);"/><rect x="3" y="0" width="1" height="1" style="fill: rgb(177, 177, 177);"/><rect x="4" y="0" width="1" height="1" style="fill: rgb(189, 189, 189);"/><rect x="5" y="0" width="1" height="1" style="fill: rgb(134, 134, 134);"/><rect x="6" y="0" width="1" height="1" style="fill: rgb(34, 34, 34);"/><rect x="7" y="0" width="1" height="1" style="fill: rgb(35, 35, 35);"/><rect x="8" y="0" width="1" height="1" style="fill: rgb(49, 49, 49);"/><rect x="9" y="0" width="1" height="1" style="fill: rgb(212, 212, 212);"/><rect x="0" y="1" width="1" height="1" style="fill: rgb(240, 240, 240);"/><rect x="1" y="1" width="1" height="1" style="fill: rgb(96, 96, 96);"/><rect x="2" y="1" width="1" height="1" style="fill: rgb(6, 6, 6);"/><rect x="3" y="1" width="1" height="1" style="fill: rgb(107, 107, 107);"/><rect x="4" y="1" width="1" height="1" style="fill: rgb(20, 20, 20);"/><rect x="5" y="1" width="1" height="1" style="fill: rgb(197, 197, 197);"/><rect x="6" y="1" width="1" height="1" style="fill: rgb(195, 195, 195);"/><rect x="7" y="1" width="1" height="1" style="fill: rgb(139, 139, 139);"/><rect x="8" y="1" width="1" height="1" style="fill: rgb(181, 181, 181);"/><rect x="9" y="1" width="1" height="1" style="fill: rgb(22, 22, 22);"/><rect x="0" y="2" width="1" height="1" style="fill: rgb(140, 140, 140);"/><rect x="1" y="2" width="1" height="1" style="fill: rgb(107, 107, 107);"/><rect x="2" y="2" width="1" height="1" style="fill: rgb(51, 51, 51);"/><rect x="3" y="2" width="1" height="1" style="fill: rgb(184, 184, 184);"/><rect x="4" y="2" width="1" height="1" style="fill: rgb(164, 164, 164);"/><rect x="5" y="2" width="1" height="1" style="fill: rgb(64, 64, 64);"/><rect x="6" y="2" width="1" height="1" style="fill: rgb(66, 66, 66);"/><rect x="7" y="2" width="1" height="1" style="fill: rgb(142, 142, 142);"/><rect x="8" y="2" width="1" height="1" style="fill: rgb(48, 48, 48);"/><rect x="9" y="2" width="1" height="1" style="fill: rgb(12, 12, 12);"/><rect x="0" y="3" width="1" height="1" style="fill: rgb(60, 60, 60);"/><rect x="1" y="3" width="1" height="1" style="fill: rgb(39, 39, 39);"/><rect x="2" y="3" width="1" height="1" style="fill: rgb(102, 102, 102);"/><rect x="3" y="3" width="1" height="1" style="fill: rgb(131, 131, 131);"/><rect x="4" y="3" width="1" height="1" style="fill: rgb(186, 186, 186);"/><rect x="5" y="3" width="1" height="1" style="fill: rgb(153, 153, 153);"/><rect x="6" y="3" width="1" height="1" style="fill: rgb(180, 180, 180);"/><rect x="7" y="3" width="1" height="1" style="fill: rgb(177, 177, 177);"/><rect x="8" y="3" width="1" height="1" style="fill: rgb(175, 175, 175);"/><rect x="9" y="3" width="1" height="1" style="fill: rgb(75, 75, 75);"/><rect x="0" y="4" width="1" height="1" style="fill: rgb(108, 108, 108);"/><rect x="1" y="4" width="1" height="1" style="fill: rgb(80, 80, 80);"/><rect x="2" y="4" width="1" height="1" style="fill: rgb(250, 250, 250);"/><rect x="3" y="4" width="1" height="1" style="fill: rgb(222, 222, 222);"/><rect x="4" y="4" width="1" height="1" style="fill: rgb(118, 118, 118);"/><rect x="5" y="4" width="1" height="1" style="fill: rgb(195, 195, 195);"/><rect x="6" y="4" width="1" height="1" style="fill: rgb(148, 148, 148);"/><rect x="7" y="4" width="1" height="1" style="fill: rgb(165, 165, 165);"/><rect x="8" y="4" width="1" height="1" style="fill: rgb(220, 220, 220);"/><rect x="9" y="4" width="1" height="1" style="fill: rgb(96, 96, 96);"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" viewBox="0 0 10 5" version="1.1" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="0" width="1" height="1" style="fill: rgb(169, 132, 43);"/><rect x="1" y="0" width="1" height="1" style="fill: rgb(203, 134, 156);"/><rect x="2" y="0" width="1" height="1" style="fill: rgb(27, 222, 251);"/><rect x="3" y="0" width="1" height="1" style="fill: rgb(27, 222, 251);"/><rect x="4" y="0" width="1" height="1" style="fill: rgb(252, 95, 17);"/><rect x="5" y="0" width="1" height="1" style="fill: rgb(244, 144, 19);"/><rect x="6" y="0" width="1" height="1" style="fill: rgb(203, 134, 156);"/><rect x="7" y="0" width="1" height="1" style="fill: rgb(167, 99, 62);"/><rect x="8" y="0" width="1" height="1" style="fill: rgb(27, 222, 251);"/><rect x="9" y="0" width="1" height="1" style="fill: rgb(252, 95, 17);"/><rect x="0" y="1" width="1" height="1" style="fill: rgb(124, 130, 220);"/><rect x="1" y="1" width="1" height="1" style="fill: rgb(244, 144, 19);"/><rect x="2" y="1" width="1" height="1" style="fill: rgb(128, 45, 115);"/><rect x="3" y="1" width="1" height="1" style="fill: rgb(124, 130, 220);"/><rect x="4" y="1" width="1" height="1" style="fill: rgb(244, 144, 19);"/><rect x="5" y="1" width="1" height="1" style="fill: rgb(203, 134, 156);"/><rect x="6" y="1" width="1" height="1" style="fill: rgb(203, 134, 156);"/><rect x="7" y="1" width="1" height="1" style="fill: rgb(124, 130, 220);"/><rect x="8" y="1" width="1" height="1" style="fill: rgb(167, 99, 62);"/><rect x="9" y="1" width="1" height="1" style="fill: rgb(128, 45, 115);"/><rect x="0" y="2" width="1" height="1" style="fill: rgb(203, 134, 156);"/><rect x="1" y="2" width="1" height="1" style="fill: rgb(244, 144, 19);"/><rect x="2" y="2" width="1" height="1" style="fill: rgb(252, 95, 17);"/><rect x="3" y="2" width="1" height="1" style="fill: rgb(169, 132, 43);"/><rect x="4" y="2" width="1" height="1" style="fill: rgb(128, 45, 115);"/><rect x="5" y="2" width="1" height="1" style="fill: rgb(203, 134, 156);"/><rect x="6" y="2" width="1" height="1" style="fill: rgb(27, 222, 251);"/><rect x="7" y="2" width="1" height="1" style="fill: rgb(167, 99, 62);"/><rect x="8" y="2" width="1" height="1" style="fill: rgb(203, 134, 156);"/><rect x="9" y="2" width="1" height="1" style="fill: rgb(169, 132, 43);"/><rect x="0" y="3" width="1" height="1" style="fill: rgb(169, 132, 43);"/><rect x="1" y="3" width="1" height="1" style="fill: rgb(252, 95, 17);"/><rect x="2" y="3" width="1" height="1" style="fill: rgb(252, 95, 17);"/><rect x="3" y="3" width="1" height="1" style="fill: rgb(124, 130, 220);"/><rect x="4" y="3" width="1" height="1" style="fill: rgb(124, 130, 220);"/><rect x="5" y="3" width="1" height="1" style="fill: rgb(203, 134, 156);"/><rect x="6" y="3" width="1" height="1" style="fill: rgb(27, 222, 251);"/><rect x="7" y="3" width="1" height="1" style="fill: rgb(244, 144, 19);"/><rect x="8" y="3" width="1" height="1" style="fill: rgb(124, 130, 220);"/><rect x="9" y="3" width="1" height="1" style="fill: rgb(124, 130, 220);"/><rect x="0" y="4" width="1" height="1" style="fill: rgb(252, 95, 17);"/><rect x="1" y="4" width="1" height="1" style="fill: rgb(128, 45, 115);"/><rect x="2" y="4" width="1" height="1" style="fill: rgb(167, 99, 62);"/><rect x="3" y="4" width="1" height="1" style="fill: rgb(244, 144, 19);"/><rect x="4" y="4" width="1" height="1" style="fill: rgb(252, 95, 17);"/><rect x="5" y="4" width="1" height="1" style="fill: rgb(252, 95, 17);"/><rect x="6" y="4" width="1" height="1" style="fill: rgb(124, 130, 220);"/><rect x="7" y="4" width="1" height="1" style="fill: rgb(128, 45, 115);"/><rect x="8" y="4" width="1" height="1" style="fill: rgb(252, 95, 17);"/><rect x="9" y="4" width="1" height="1" style="fill: rgb(124, 130, 220);"/></svg>
|
File without changes
|
data/lib/mosaiq/image.rb
CHANGED
@@ -5,7 +5,7 @@ require 'mosaiq/svg'
|
|
5
5
|
module Mosaiq
|
6
6
|
# Main class to create a Mosaiq Image
|
7
7
|
class Image
|
8
|
-
def initialize(width, height, colors =
|
8
|
+
def initialize(width, height, colors = Palette.black_and_white)
|
9
9
|
@width = read_positive_integer(width: width)
|
10
10
|
@height = read_positive_integer(height: height)
|
11
11
|
@colors = read_colors(colors)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mosaiq
|
4
|
+
# Palette defines various arrays of colors
|
5
|
+
module Palette
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def black_and_white
|
9
|
+
%w[#ffffff #000000]
|
10
|
+
end
|
11
|
+
|
12
|
+
def grays
|
13
|
+
0.upto(255).map { |n| "rgb(#{n}, #{n}, #{n})" }
|
14
|
+
end
|
15
|
+
|
16
|
+
def random_colors(number)
|
17
|
+
number.times.map do
|
18
|
+
"rgb(#{rand(256)}, #{rand(256)}, #{rand(256)})"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/mosaiq/version.rb
CHANGED
data/lib/mosaiq.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mosaiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lxxxvi
|
@@ -113,10 +113,14 @@ files:
|
|
113
113
|
- bin/console
|
114
114
|
- bin/setup
|
115
115
|
- bin/test
|
116
|
-
- documentation/
|
116
|
+
- documentation/example_black_and_white.svg
|
117
|
+
- documentation/example_grays.svg
|
118
|
+
- documentation/example_random_colors_8.svg
|
119
|
+
- documentation/example_red_green_blue.svg
|
117
120
|
- lib/mosaiq.rb
|
118
121
|
- lib/mosaiq/errors.rb
|
119
122
|
- lib/mosaiq/image.rb
|
123
|
+
- lib/mosaiq/palette.rb
|
120
124
|
- lib/mosaiq/svg.rb
|
121
125
|
- lib/mosaiq/version.rb
|
122
126
|
- mosaiq.gemspec
|