stitchify 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 163c7b301bb8c593d7776451c1b6301d779431b9
4
- data.tar.gz: 10c75dc399cad95003d8410e17b600dcb3d3a3bb
3
+ metadata.gz: 075c84e80386052b68c7a4ef0b4a413cca2293d6
4
+ data.tar.gz: 96ef61fa87cb55429646df1158d5581ea94e5602
5
5
  SHA512:
6
- metadata.gz: 1265812071e71ab6a4c4a91fb0b7276985114b62d79dd7e20e3e4c0a0760d0f5d6a945dcf8ba086e9842fc941e11ae12811bc8ce0c31ae2aee42216aa8092bf6
7
- data.tar.gz: 9d8431825fa940807b0b48bff170701cec914885369a858edfdc4a85546260a422bc644d06230cba02ee3001548093c073cd74dcdc0fa62a746d8f315482eaa8
6
+ metadata.gz: 7e21003a1cbec702b06388b5546a98793f51f0dc7805077edb44a10b31af168495087cab66ab5ca6316fef560782bc6cbb3d5cf572c3eab1a8bec224c4783a96
7
+ data.tar.gz: 6fb7d976aa22e136cdc200de28d6a8fecccc5c6adf36ea21a0d6e6e86e7982808c18e80b9970697e048ece0bc541c40d0bde521eaec500c5eac48be06d927db3
data/lib/stitchify.rb CHANGED
@@ -21,6 +21,8 @@ class Stitchifier
21
21
  'triangle',
22
22
  'circle',
23
23
  'diamond',
24
+ 'heart',
25
+ 'star',
24
26
  'reverse_triangle',
25
27
  'left_triangle',
26
28
  'right_triangle'
@@ -108,7 +110,7 @@ class Stitchifier
108
110
  end
109
111
 
110
112
  def black_and_white
111
- [Pixelfy.new(0, 0, 0, 'x'), Pixelfy.new(0, 0, 100, 'circle')]
113
+ [Pixelfy.new(0, 0, 0, 'circle'), Pixelfy.new(0, 0, 100, 'x')]
112
114
  end
113
115
 
114
116
  def build_pixel_array
@@ -31,42 +31,126 @@ class DrawRasem
31
31
  rasem_obj = self
32
32
 
33
33
  Rasem::SVGImage.new(width: 1000000000, height: 100000000) do
34
+ pos_x = rasem_obj.pos_x
35
+ pos_y = rasem_obj.pos_y
36
+ px = rasem_obj.px
37
+ a = px / 4
38
+ b = px / 2
39
+ c = px - a
40
+ d = a / 2
34
41
 
35
- for line_data in rasem_obj.grid
36
- line line_data[0], line_data[1], line_data[2], line_data[3], :stroke_width=>line_data[5]
37
- end
42
+ defs do
43
+ group(id: 'rectangle') do
44
+ rectangle pos_x, pos_y, px, px
45
+ end
38
46
 
39
- for pixel in rasem_obj.px_arr
40
- pos_x = rasem_obj.pos_x
41
- pos_y = rasem_obj.pos_y
42
- px = rasem_obj.px
43
-
44
- case pixel.shape
45
- when 'rectangle'
46
- rectangle pos_x, pos_y, px, px, fill: pixel.hex
47
- when 'x'
47
+ group(id: 'x') do
48
48
  line pos_x, pos_y, pos_x + px, pos_y + px
49
49
  line pos_x, pos_y + px, pos_x + px, pos_y
50
- when 'circle'
51
- circle (pos_x + px/2), (pos_y + px/2), px / 2 - 1, fill: pixel.hex
52
- when 'sm_rectangle'
53
- rectangle pos_x + 1, pos_y + 1, px - 2, px - 2, fill: pixel.hex
54
- when 'triangle'
55
- polygon [pos_x + px/2, pos_y + 1], [pos_x + 1, pos_y + px - 1], [pos_x + px - 1, pos_y + px - 1], fill: pixel.hex
56
- when 'diamond'
57
- polygon [pos_x + px/2, pos_y + 1], [pos_x + 1, pos_y + px/2], [pos_x + px/2, pos_y + px - 1], [pos_x + px - 1, pos_y + px/2], fill: pixel.hex
58
- when 'reverse_triangle'
59
- polygon [pos_x + px/2, pos_y + px - 1], [pos_x + 1, pos_y + 1], [pos_x + px - 1, pos_y + 1], fill: pixel.hex
60
- when 'left_triangle'
61
- polygon [pos_x + 1, pos_y + px/2], [pos_x + px - 1, pos_y + 1], [pos_x + px - 1, pos_y + px - 1], fill: pixel.hex
62
- when 'right_triangle'
63
- polygon [pos_x + px - 1, pos_y + px/2], [pos_x + 1, pos_y + 1], [pos_x + 1, pos_y + px - 1], fill: pixel.hex
64
- else
65
- rectangle pos_x, pos_y, px, px, fill: pixel.hex
66
50
  end
67
51
 
52
+ group(id: 'circle') do
53
+ circle (pos_x + b), (pos_y + b), a + d
54
+ end
55
+
56
+ group(id: 'sm_rectangle') do
57
+ rectangle pos_x + a + 1, pos_y + a + 1, b, b
58
+ end
59
+
60
+ group(id: 'triangle') do
61
+ polygon [pos_x + b, pos_y + a],
62
+ [pos_x + c, pos_y + c],
63
+ [pos_x + a, pos_y + c]
64
+ end
65
+
66
+ group(id: 'diamond') do
67
+ polygon [pos_x + b, pos_y + 1],
68
+ [pos_x + 1, pos_y + b],
69
+ [pos_x + b, pos_y + px - 1],
70
+ [pos_x + px - 1, pos_y + b]
71
+ end
72
+
73
+ group(id: 'reverse_triangle') do
74
+ polygon [pos_x + a, pos_y + a],
75
+ [pos_x + c, pos_y + a],
76
+ [pos_x + b, pos_y + c]
77
+ end
78
+
79
+ group(id: 'left_triangle') do
80
+ polygon [pos_x + a, pos_y + b],
81
+ [pos_x + c, pos_y + a],
82
+ [pos_x + c, pos_y + c]
83
+ end
84
+
85
+ group(id: 'right_triangle') do
86
+ polygon [pos_x + a, pos_y + a],
87
+ [pos_x + c, pos_y + b],
88
+ [pos_x + a, pos_y + c]
89
+ end
90
+
91
+ group(id: 'star') do
92
+ polygon [pos_x + a + 1, pos_y + 1],
93
+ [pos_x + b, pos_y + a + 1],
94
+ [pos_x + c - 1, pos_y + 1],
95
+ [pos_x + c - 1, pos_y + a + 1],
96
+ [pos_x + px - 1, pos_y + a + 1],
97
+ [pos_x + c - 1, pos_y + b],
98
+ [pos_x + px - 1, pos_y + c - 1],
99
+ [pos_x + c - 1, pos_y + c - 1],
100
+ [pos_x + c - 1, pos_y + px - 1],
101
+ [pos_x + b, pos_y + c - 1],
102
+ [pos_x + a + 1, pos_y + px - 1],
103
+ [pos_x + a + 1, pos_y + c - 1],
104
+ [pos_x + 1, pos_y + c - 1],
105
+ [pos_x + a + 1, pos_y + b],
106
+ [pos_x + 1, pos_y + a + 1],
107
+ [pos_x + a + 1, pos_y + a + 1],
108
+ [pos_x + a + 1, pos_y + 1]
109
+ end
110
+
111
+ group(id: 'heart') do
112
+ polygon [pos_x + a, pos_y + a],
113
+ [pos_x + b - d, pos_y + a],
114
+ [pos_x + b, pos_y + b - d],
115
+ [pos_x + b + d, pos_y + a],
116
+ [pos_x + c, pos_y + a],
117
+ [pos_x + c, pos_y + b],
118
+ [pos_x + b, pos_y + c],
119
+ [pos_x + a, pos_y + b]
120
+ end
121
+ end
122
+
123
+ # grid
124
+ group stroke: 'black' do
125
+ for line_data in rasem_obj.grid
126
+ line line_data[0], line_data[1], line_data[2], line_data[3], :stroke_width=>line_data[5]
127
+ end
128
+
129
+ blocks = rasem_obj.width / 10
130
+ blocks.times do |i|
131
+ text((i + 1) * 10 * px + b, c, stroke_width: 1, 'font-size': '8px', class: 'grid-numbers') { raw (i + 1) * 5 }
132
+ text(1, (i + 1) * 10 * px + px + a, stroke_width: 1, 'font-size': '8px', class: 'grid-numbers') { raw (i + 1) * 5 }
133
+ end
134
+ end
135
+
136
+ # content
137
+ for pixel in rasem_obj.px_arr
138
+ use(pixel.shape, x: rasem_obj.pos_x - px, y: rasem_obj.pos_y - px, fill: pixel.hex)
68
139
  rasem_obj.update_positions
69
140
  end
141
+
142
+ # legend
143
+ group stroke: 'black' do
144
+ legend_pos_x = (rasem_obj.width + 2) * px
145
+ legend_pos_y = 2 * px
146
+ legend_height = px * (rasem_obj.color_set.length * 2)
147
+ rectangle legend_pos_x, legend_pos_y, 10 * px, legend_height, fill: 'white'
148
+ rasem_obj.color_set.each_with_index do |pixel, index|
149
+ use(pixel.shape, x: legend_pos_x - b, y: legend_pos_y - b, fill: pixel.hex)
150
+ text(legend_pos_x + 2 * px, legend_pos_y + px + b) { raw pixel.hex }
151
+ legend_pos_y += 2 * px
152
+ end
153
+ end
70
154
  end
71
155
  end
72
156
 
@@ -39,6 +39,13 @@ class Pixelfy
39
39
  "#{HSL_OPEN_CONST} #{self.hue}, #{self.saturation}%, #{self.lightness}%, 1)"
40
40
  end
41
41
 
42
+ def name
43
+ n = ''
44
+ c = Chroma::Color.new(hsl).to_name
45
+ n = c unless c == "<unknown>"
46
+
47
+ end
48
+
42
49
  def colorize(map)
43
50
  deltae = 100000000000
44
51
  closest_px = map[0]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stitchify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ellen Wondra
@@ -56,58 +56,58 @@ dependencies:
56
56
  name: chroma
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.2.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.2.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rmagick
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '2.16'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '2.16'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 12.3.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 12.3.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 0.11.3
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 0.11.3
111
111
  description: ultimate goal is to input an HTML document and output an SVG cross stitching
112
112
  pattern
113
113
  email: ellenfromillinois@gmail.com