stitchify 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stitchify.rb +4 -2
- data/lib/stitchify/draw_rasem.rb +14 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a69e46357be5a7471d4e299fdf2991ed93807852
|
4
|
+
data.tar.gz: 69ac7719b3df36c5fd33282fcadf62f7cfa97c37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ac0ab428ea0ae7c8ea8d72bad8cac09c21f39e013cad8995eccd9b9ba94c14d82c7eaeba1cff63d23e59968d1c8850b081d9a0032d65823bfcd1d8c9874c1d1
|
7
|
+
data.tar.gz: 4231feda99f27a2e1407eba36dccc9646d8c50d10b3883220e8895cf958ba110ab42c98875d2cf9f6901f978c6504c64bfeb3f6414f2ce854809111c0633b776
|
data/lib/stitchify.rb
CHANGED
@@ -33,6 +33,7 @@ class Stitchifier
|
|
33
33
|
:dominant_colors,
|
34
34
|
:img,
|
35
35
|
:img_path,
|
36
|
+
:file_path,
|
36
37
|
:num_of_colors,
|
37
38
|
:num_of_off_colors,
|
38
39
|
:pos_x,
|
@@ -41,7 +42,7 @@ class Stitchifier
|
|
41
42
|
:stitch_map,
|
42
43
|
:width
|
43
44
|
|
44
|
-
def initialize(img_path = '', width = 50, px=10, num_of_colors =
|
45
|
+
def initialize(img_path = '', width = 50, px=10, num_of_colors=8, file_path='stitchify.svg')
|
45
46
|
# sets variables
|
46
47
|
self.num_of_colors = num_of_colors
|
47
48
|
set_num_colors
|
@@ -52,6 +53,7 @@ class Stitchifier
|
|
52
53
|
self.stitch_map = []
|
53
54
|
self.px = px
|
54
55
|
self.color_set = nil
|
56
|
+
self.file_path = file_path
|
55
57
|
|
56
58
|
unless img_path.empty?
|
57
59
|
make_img
|
@@ -63,7 +65,7 @@ class Stitchifier
|
|
63
65
|
end
|
64
66
|
|
65
67
|
def stitch
|
66
|
-
d = DrawRasem.new(self.stitch_map, self.width, self.px, self.color_set)
|
68
|
+
d = DrawRasem.new(self.stitch_map, self.width, self.px, self.color_set, self.file_path)
|
67
69
|
d.stitch
|
68
70
|
end
|
69
71
|
|
data/lib/stitchify/draw_rasem.rb
CHANGED
@@ -1,17 +1,25 @@
|
|
1
1
|
class DrawRasem
|
2
2
|
|
3
|
-
attr_accessor
|
4
|
-
|
5
|
-
|
3
|
+
attr_accessor :color_set,
|
4
|
+
:file_path,
|
5
|
+
:height,
|
6
|
+
:pos_x,
|
7
|
+
:pos_y,
|
8
|
+
:px,
|
9
|
+
:px_arr,
|
10
|
+
:width
|
11
|
+
|
12
|
+
def initialize(px_arr, width=50, px=10, color_set=[], file_path='stitchify.svg')
|
6
13
|
self.px_arr = px_arr
|
7
14
|
self.width = width
|
8
15
|
self.px = px
|
9
16
|
self.color_set = color_set
|
17
|
+
self.file_path = file_path
|
10
18
|
clear_vars
|
11
19
|
end
|
12
20
|
|
13
21
|
def stitch
|
14
|
-
write(build_rasem_data,
|
22
|
+
write(build_rasem_data, self.file_path)
|
15
23
|
clear_vars
|
16
24
|
end
|
17
25
|
|
@@ -128,8 +136,8 @@ class DrawRasem
|
|
128
136
|
|
129
137
|
blocks = rasem_obj.width / 10
|
130
138
|
blocks.times do |i|
|
131
|
-
text((i + 1) * 10 * px + b, c, stroke_width: 1, 'font-size': '8px', class: 'grid-numbers') { raw (i + 1) *
|
132
|
-
text(1, (i + 1) * 10 * px + px + a, stroke_width: 1, 'font-size': '8px', class: 'grid-numbers') { raw (i + 1) *
|
139
|
+
text((i + 1) * 10 * px + b, c, stroke_width: 1, 'font-size': '8px', class: 'grid-numbers') { raw (i + 1) * 10 }
|
140
|
+
text(1, (i + 1) * 10 * px + px + a, stroke_width: 1, 'font-size': '8px', class: 'grid-numbers') { raw (i + 1) * 10 }
|
133
141
|
end
|
134
142
|
end
|
135
143
|
|