atome 0.5.2.8 → 0.5.3.2

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -1
  3. data/app_builder_helpers/Rakefile +2 -2
  4. data/exe/atome +1 -1
  5. data/lib/atome/atome.rb +28 -26
  6. data/lib/atome/extensions/atome.rb +4 -0
  7. data/lib/atome/extensions/matrix.rb +349 -122
  8. data/lib/atome/genesis/generators/atome.rb +5 -1
  9. data/lib/atome/genesis/generators/identity.rb +43 -13
  10. data/lib/atome/genesis/generators/material.rb +20 -5
  11. data/lib/atome/genesis/generators/time.rb +1 -1
  12. data/lib/atome/genesis/generators/utility.rb +26 -2
  13. data/lib/atome/genesis/genesis.rb +12 -4
  14. data/lib/atome/genesis/sparkle.rb +35 -3
  15. data/lib/atome/helpers/essentials.rb +24 -15
  16. data/lib/atome/helpers/utilities.rb +42 -3
  17. data/lib/atome/kernel/batch.rb +48 -0
  18. data/lib/atome/presets/atome.rb +22 -6
  19. data/lib/atome/renderers/browser/atome.rb +1 -3
  20. data/lib/atome/renderers/browser/browser.rb +14 -1
  21. data/lib/atome/renderers/browser/geometry.rb +10 -2
  22. data/lib/atome/renderers/browser/helpers/video_helper.rb +1 -1
  23. data/lib/atome/renderers/browser/helpers/web_helper.rb +1 -5
  24. data/lib/atome/renderers/browser/identity.rb +7 -11
  25. data/lib/atome/renderers/browser/material.rb +10 -0
  26. data/lib/atome/renderers/html/atome.rb +2 -0
  27. data/lib/atome/renderers/renderer.rb +3 -2
  28. data/lib/atome/version.rb +1 -1
  29. data/lib/atome.rb +2 -1
  30. data/sig/atome.rbs +14 -0
  31. data/vendor/assets/Rakefile +1 -1
  32. data/vendor/assets/src/css/style.css +6 -6
  33. data/vendor/assets/src/medias/rubies/examples/_2_solve.rb +41 -27
  34. data/vendor/assets/src/medias/rubies/examples/_attach.rb +12 -0
  35. data/vendor/assets/src/medias/rubies/examples/_audio.rb +81 -28
  36. data/vendor/assets/src/medias/rubies/examples/_dataset.rb +191 -111
  37. data/vendor/assets/src/medias/rubies/examples/clone.rb +4 -4
  38. data/vendor/assets/src/medias/rubies/examples/delete.rb +2 -2
  39. data/vendor/assets/src/medias/rubies/examples/drag.rb +2 -1
  40. data/vendor/assets/src/medias/rubies/examples/table.rb +479 -0
  41. data/vendor/assets/src/medias/rubies/examples/to_px.rb +10 -0
  42. metadata +7 -4
  43. data/vendor/assets/src/medias/rubies/examples/attach.rb +0 -12
@@ -1,171 +1,398 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # powerful and simple to use table and list generator
4
- class Matrix
5
- attr_accessor :matrix
3
+ class Atome
4
+ def content(items = nil)
5
+ if items.instance_of?(Array)
6
+ items.each do |item|
7
+ content(item)
8
+ end
9
+ elsif items.instance_of?(Atome)
10
+ w_found = items.particles[:width]
11
+ h_found = items.particles[:height]
12
+ l_found = items.particles[:left]
13
+ t_found = items.particles[:top]
14
+ i_found = items.particles[:id]
15
+ current_w_found = width
16
+ current_h_found = height
17
+ current_l_found = left
18
+ current_t_found = top
19
+ @cell_content ||= {}
20
+ @cell_content[i_found] = { width_ratio: 1, height_ratio: 1, top_ratio: 1, left_ratio: 1 }
21
+ # alert @cell_content
22
+ items.parents([self.id])
23
+ else
24
+ @cell_content
25
+ end
6
26
 
7
- def create_matrix_back( id, style)
8
- @matrix = Atome.new(
9
- shape: { type: :shape, renderers: [:browser], id: id, parents: [:view], children: [:matrix_color],
10
- overflow: :auto }
11
- )
12
- @matrix.style(style)
13
27
  end
14
28
 
15
- def create_matrix_colors
16
- Atome.new({ color: { renderers: [:browser], id: :matrix_color, type: :color, parents: [], children: [],
17
- red: 0, green: 1, blue: 1, alpha: 1 } })
29
+ def cells(cell_nb)
30
+ collector_object = collector({})
31
+ collected_atomes = []
32
+ cell_nb.each do |cell_found|
33
+ atome_found = grab ("#{id}_#{cell_found}")
34
+ collected_atomes << atome_found
35
+ end
36
+ collector_object.data(collected_atomes)
37
+ collector_object
38
+ end
18
39
 
19
- Atome.new({ color: { renderers: [:browser], id: :cell_color, type: :color, parents: [], children: [],
20
- red: 1, green: 0.15, blue: 0.7, alpha: 1 } })
40
+ def cell(cell_nb)
41
+ cell_found = grab ("#{id}_#{cell_nb}")
42
+ cell_found
21
43
  end
22
44
 
23
- def create_cells(id, cell_number, number_of_cells, style)
24
- while cell_number < number_of_cells
25
- @matrix_dataset[cell_number] = []
26
- @cells << a = Atome.new(
27
- shape: { type: :shape, renderers: [:browser], id: id + "_#{cell_number}", parents: [id],
28
- children: [:cell_color] }
29
- )
30
- a.style(style)
31
- cell_number += 1
45
+ def columns(column_requested, &proc)
46
+ number_of_cells = @columns * @rows
47
+ column_content = get_column_or_row(number_of_cells, @columns, column_requested, true)
48
+ cells_found = []
49
+ column_content.each do |cell_nb|
50
+ atome_found = grab("#{id}_#{cell_nb}")
51
+ instance_exec(atome_found, &proc) if proc.is_a?(Proc)
52
+ cells_found << grab("#{id}_#{cell_nb}")
32
53
  end
54
+ element({ data: cells_found })
33
55
  end
34
56
 
35
- def initialize(params)
36
- default = { col: 4, row: 4, size: 333, margin: 12, name: :matrix, parent: :view }
37
- params = default.merge(params)
38
- nb_of_rows = params[:row]
39
- nb_of_cols = params[:col]
40
- matrix_width = params[:width]
41
- matrix_height = params[:height]
57
+ def rows(row_requested, &proc)
58
+ number_of_cells = @columns * @rows
59
+ column_content = get_column_or_row(number_of_cells, @columns, row_requested, false)
60
+ cells_found = []
61
+ column_content.each do |cell_nb|
62
+ atome_found = grab("#{id}_#{cell_nb}")
63
+ instance_exec(atome_found, &proc) if proc.is_a?(Proc)
64
+ cells_found << grab("#{id}_#{cell_nb}")
65
+ end
66
+ element({ data: cells_found })
67
+ end
42
68
 
43
- @matrix_dataset = []
44
- @matrix_margin = params[:margin]
45
- params[:id] = :matrix unless params[:id]
46
- @matrix_id = params[:id]
47
- # styles
48
- @matrix_style = params[:matrix_style]
49
- @cell_style = params[:cell_style]
50
- # Colors
51
- create_matrix_colors
52
- # now we create the background
53
- create_matrix_back( @matrix_id, @matrix_style)
54
-
55
- @nb_of_rows = nb_of_rows.to_i
56
- @nb_of_cols = nb_of_cols.to_i
57
- number_of_cells = @nb_of_rows * @nb_of_cols
58
- @cells = []
59
- cell_number = 0
60
- create_cells(@matrix_id, cell_number, number_of_cells, @cell_style)
61
-
62
- resize_matrix({ width: matrix_width, height: matrix_height })
63
- end
64
-
65
- def width(val = nil)
66
- if val
67
- resize_matrix({ height: height, width: val })
69
+ # def ratio(val)
70
+ # puts "ratio must be : #{val}"
71
+ #
72
+ # end
73
+
74
+ def fusion(params)
75
+ number_of_cells = @columns * @rows
76
+ if params[:columns]
77
+ @exceptions[:columns_fusion] = params[:columns].merge(@exceptions[:columns_fusion])
78
+ params[:columns].each do |column_to_alter, value|
79
+ cell_height = (@matrix_height - @margin * (@rows + 1)) / @rows
80
+ cells_in_column = get_column_or_row(number_of_cells, @columns, column_to_alter, true)
81
+ cells_to_alter = cells_in_column[value[0]..value[1]]
82
+ cells_to_alter.each_with_index do |cell_nb, index|
83
+ current_cell = grab("#{id.value}_#{cell_nb}")
84
+ if index == 0
85
+ current_cell.height(cell_height * cells_to_alter.length + @margin * (cells_to_alter.length - 1))
86
+ else
87
+ current_cell.hide(true)
88
+ end
89
+ end
90
+ end
68
91
  else
69
- @matrix.width.value
92
+ @exceptions[:rows_fusion] = params[:rows].merge(@exceptions[:rows_fusion])
93
+ params[:rows].each do |row_to_alter, value|
94
+ cell_width = (@matrix_width - @margin * (@columns + 1)) / @columns
95
+ cells_in_column = get_column_or_row(number_of_cells, @columns, row_to_alter, false)
96
+ cells_to_alter = cells_in_column[value[0]..value[1]]
97
+
98
+ cells_to_alter.each_with_index do |cell_nb, index|
99
+ current_cell = grab("#{id.value}_#{cell_nb}")
100
+ if index == 0
101
+ current_cell.width(cell_width * cells_to_alter.length + @margin * (cells_to_alter.length - 1))
102
+ else
103
+ current_cell.hide(true)
104
+ end
105
+ end
106
+ end
70
107
  end
71
108
 
72
109
  end
73
110
 
74
- def height(val = nil)
75
- if val
76
- resize_matrix({ width: width, height: val })
111
+ def divide(params)
112
+ number_of_cells = @columns * @rows
113
+ if params[:columns]
114
+ params[:columns].each do |column_to_alter, value|
115
+ cells_in_column = get_column_or_row(number_of_cells, @columns, column_to_alter, true)
116
+ # we get the nth first element
117
+ cells_to_alter = cells_in_column.take(value)
118
+ cells_in_column.each_with_index do |cell_nb, index|
119
+ current_cell = grab("#{id.value}_#{cell_nb}")
120
+ if cells_to_alter.include?(cell_nb)
121
+ current_cell.height(@matrix_height / value - (@margin + value))
122
+ current_cell.top(current_cell.height.value * index + @margin * (index + 1))
123
+ else
124
+ current_cell.hide(true)
125
+ end
126
+ end
127
+ end
77
128
  else
78
- @matrix.height.value
129
+ params[:rows].each do |row_to_alter, value|
130
+ cells_in_row = get_column_or_row(number_of_cells, @columns, row_to_alter, false)
131
+ # we get the nth first element
132
+ cells_to_alter = cells_in_row.take(value)
133
+ cells_in_row.each_with_index do |cell_nb, index|
134
+ current_cell = grab("#{id.value}_#{cell_nb}")
135
+ if cells_to_alter.include?(cell_nb)
136
+ current_cell.width(@matrix_width / value - @margin - (@margin / value))
137
+ current_cell.left(current_cell.width.value * index + @margin * (index + 1))
138
+ else
139
+ current_cell.hide(true)
140
+ end
141
+ end
142
+ end
79
143
  end
144
+
80
145
  end
81
146
 
82
- def left(val)
83
- @matrix.left(val)
147
+ # def override(params)
148
+ # # TODO : allow fixed height ond fixed width when resizing
149
+ # puts "should override to allow fixed height or fixed width when resizing #{params}"
150
+ # end
151
+
152
+ def first(item, &proc)
153
+ if item[:columns]
154
+ columns(0, &proc)
155
+ else
156
+ rows(0, &proc)
157
+ end
84
158
  end
85
159
 
86
- def right(val)
87
- @matrix.right(val)
160
+ def last(item, &proc)
161
+ if item[:columns]
162
+ columns(@columns - 1, &proc)
163
+ else
164
+ rows(@rows - 1, &proc)
165
+ end
88
166
  end
89
167
 
90
- def resize_matrix(params)
91
- matrix_width = params[:width]
92
- matrix_height = params[:height]
93
- cell_width = (matrix_width / @nb_of_cols) - @matrix_margin
94
- cell_height = (matrix_height / @nb_of_rows) - @matrix_margin
95
- row = -1
96
- @cells.each_with_index do |cell, index|
97
- cell.height = cell_height
98
- cell.width = cell_width
99
- row += 1 if index.modulo(@nb_of_cols).zero?
100
- cell.left(index % @nb_of_cols * (cell_width + @matrix_margin) + @matrix_margin)
101
- cell.top(row * (cell_height + @matrix_margin) + @matrix_margin)
168
+ def format_matrix(matrix_id, matrix_width, matrix_height, nb_of_rows, nb_of_cols, margin, exceptions = {})
169
+ cell_width = (matrix_width - margin * (nb_of_cols + 1)) / nb_of_cols
170
+ cell_height = (matrix_height - margin * (nb_of_rows + 1)) / nb_of_rows
171
+ ratio=cell_height/cell_width
172
+ i = 0
173
+ nb_of_rows.times do |row_index|
174
+ nb_of_cols.times do |col_index|
175
+ # Calculate the x and y position of the cell
176
+ x = (col_index + 1) * margin + col_index * cell_width
177
+ y = (row_index + 1) * margin + row_index * cell_height
178
+ current_cell = grab("#{matrix_id}_#{i}")
179
+ puts "===> #{current_cell}"
180
+ current_cell.children.each do |child|
181
+ puts "=>#{cell_width}"
182
+ grab(child).width(cell_width)
183
+ grab(child).height(cell_width)
184
+ end
185
+ current_cell.width= cell_width
186
+ current_cell.height= cell_height
187
+ current_cell.left(x)
188
+ current_cell.top(y)
189
+ i += 1
190
+ end
102
191
  end
103
192
 
104
- @matrix.width = matrix_width + @matrix_margin
105
- @matrix.height = matrix_height + @matrix_margin
106
- end
193
+ # exceptions management
194
+
195
+ number_of_cells = nb_of_rows * nb_of_cols
196
+ # columns exceptions
197
+ if exceptions
198
+ fusion({ columns: exceptions[:columns_fusion] }) if exceptions[:columns_fusion]
199
+ fusion({ rows: exceptions[:rows_fusion] }) if exceptions[:rows_fusion]
200
+ divide({ columns: exceptions[:columns_divided] }) if exceptions[:columns_divided]
201
+ divide({ rows: exceptions[:rows_divided] }) if exceptions[:rows_divided]
202
+ end
107
203
 
108
- def get_cell(id)
109
- grab("#{@matrix_id}_#{id}")
110
204
  end
111
205
 
112
- def delete(val = true)
113
- @matrix.delete(true) if val
206
+ def apply_style(current_cell, style)
207
+ current_cell.set(style)
114
208
  end
115
209
 
116
- attr_reader :cells
210
+ def matrix(params = {}, &bloc)
117
211
 
118
- def name
119
- @matrix.name
120
- end
212
+ if params[:columns]
213
+ columns_data = params.delete(:columns)
214
+ else
215
+ columns_data= { count: 4 }
216
+ end
121
217
 
122
- def get_cell_data(codes, cell_nb)
123
- codes.each do |proc|
124
- if proc.is_a? Proc
125
- assign(cell_nb, &proc)
126
- end
218
+ if params[:rows]
219
+ rows_data = params.delete(:rows)
220
+ else
221
+ rows_data= { count: 4 }
127
222
  end
128
- end
129
223
 
130
- def add(params)
131
- nb_of_cols = @nb_of_cols + params[:columns].to_i
132
- nb_of_rows = @nb_of_rows + params[:rows].to_i
133
- current_id = @matrix.atome[:id]
134
- # we delete all children to unbind any event
135
- @cells.each do |cell|
136
- cell.delete(true)
137
- cell.unbind(:all)
224
+ if params[:cells]
225
+ cells_data = params.delete(:cells)
226
+ else
227
+ cells_data= { particles: { margin: 9, color: :lightgray } }
228
+ end
229
+ cells_color=cells_data[:particles].delete(:color)
230
+ cells_color_id= color(cells_color).id.value
231
+
232
+ cells_shadow=cells_data[:particles].delete(:shadow)
233
+ cells_shadow_id= shadow(cells_shadow).id.value
234
+
235
+ exceptions_data = params.delete(:exceptions)
236
+ default_renderer = Essentials.default_params[:render_engines]
237
+ atome_type = :matrix
238
+ generated_render = params[:renderers] || default_renderer
239
+ generated_id = params[:id] || "#{atome_type}_#{Universe.atomes.length}"
240
+ generated_parents = params[:parents] || [id.value]
241
+ generated_children = params[:children] || []
242
+ params = atome_common(atome_type, generated_id, generated_render, generated_parents, generated_children, params)
243
+ the_matrix = Atome.new({ atome_type => params }, &bloc)
244
+
245
+ # TODO: use the standard atome creation method (generator.build_atome(:collector)),
246
+ # TODO suite => For now its impossible to make it draggable because it return the created box not the matrix
247
+ # get necessary params
248
+ matrix_id = params[:id]
249
+ matrix_width = params[:width]
250
+ matrix_height = params[:height]
251
+ columns = columns_data[:count]
252
+ rows = rows_data[:count]
253
+ margin = cells_data[:particles].delete(:margin)
254
+ the_matrix.instance_variable_set("@columns", columns)
255
+ the_matrix.instance_variable_set("@rows", rows)
256
+ the_matrix.instance_variable_set("@margin", margin)
257
+ the_matrix.instance_variable_set("@cell_style", cells_data[:particles])
258
+ the_matrix.instance_variable_set("@matrix_width", matrix_width)
259
+ the_matrix.instance_variable_set("@matrix_height", matrix_height)
260
+
261
+ rows = rows_data[:count]
262
+ columns = columns_data[:count]
263
+ # @rows = rows_data[:count]
264
+ # @columns = columns_data[:count]
265
+ # @margin = cells_data[:particles].delete(:margin)
266
+ # @cell_style = cells_data[:particles]
267
+ # @matrix_width = params[:width]
268
+ # @matrix_height = params[:height]
269
+
270
+ # exceptions reorganisation
271
+ if exceptions_data
272
+ columns_exceptions = exceptions_data[:columns] ||= {}
273
+ columns_fusion_exceptions = columns_exceptions[:fusion] ||= {}
274
+ columns_divided_exceptions = columns_exceptions[:divided] ||= {}
275
+ rows_exceptions = exceptions_data[:rows] ||= {}
276
+ rows_fusion_exceptions = rows_exceptions[:fusion] ||= {}
277
+ rows_divided_exceptions = rows_exceptions[:divided] ||= {}
278
+ exceptions = { columns_fusion: columns_fusion_exceptions,
279
+ columns_divided: columns_divided_exceptions,
280
+ rows_fusion: rows_fusion_exceptions,
281
+ rows_divided: rows_divided_exceptions }
282
+ the_matrix.instance_variable_set("@exceptions", exceptions)
283
+ # @exceptions = {
284
+ # columns_fusion: columns_fusion_exceptions,
285
+ # columns_divided: columns_divided_exceptions,
286
+ # rows_fusion: rows_fusion_exceptions,
287
+ # rows_divided: rows_divided_exceptions,
288
+ # }
289
+ else
290
+ exceptions = {
291
+ columns_fusion: {},
292
+ columns_divided: {},
293
+ rows_fusion: {},
294
+ rows_divided: {},
295
+ }
296
+ the_matrix.instance_variable_set("@exceptions", exceptions)
297
+ # @exceptions = {
298
+ # columns_fusion: {},
299
+ # columns_divided: {},
300
+ # rows_fusion: {},
301
+ # rows_divided: {},
302
+ # }
138
303
  end
139
- temp_id = "#{current_id}_temporary"
140
- @matrix.id = temp_id
141
- old_matrix=grab(temp_id)
142
304
 
143
- old_matrix.delete(true)
305
+ # let's create the matrix background
306
+ # current_matrix = grab(:view).box({ id: matrix_id })
307
+ # current_matrix.set(params[:matrix][:particles])
144
308
 
309
+ # cells creation below
310
+ number_of_cells = rows * columns
311
+ number_of_cells.times do |index|
312
+ current_cell = grab(matrix_id).box({ id: "#{matrix_id}_#{index}" })
313
+ the_matrix.instance_variable_set("@cell_style", cells_data[:particles])
314
+ current_cell.attached([cells_shadow_id])
315
+ current_cell.attached([cells_color_id])
316
+ apply_style(current_cell, cells_data[:particles])
317
+ end
318
+ # lets create the columns and rows
319
+ the_matrix.format_matrix(matrix_id, matrix_width, matrix_height, rows, columns, margin, exceptions)
320
+ the_matrix
321
+ end
145
322
 
146
- Matrix.new({ col: nb_of_cols, row: nb_of_rows, width: 300, height: 300, id: current_id, margin: @matrix_margin,
147
- matrix_style: @matrix_style,
148
- cell_style: @cell_style
149
- })
323
+ def add_columns(nb)
324
+ prev_nb_of_cells = @columns * @rows
325
+ nb_of_cells_to_adds = nb * @rows
326
+ new_nb_of_cells = prev_nb_of_cells + nb_of_cells_to_adds
327
+ new_nb_of_cells.times do |index|
328
+ if index < prev_nb_of_cells
329
+ grab("#{id.value}_#{index}").delete(true)
330
+ # puts index
331
+ #
332
+ end
333
+ current_cell = self.box({ id: "#{id}_#{index}" })
334
+ apply_style(current_cell, @cell_style)
335
+ end
336
+ @columns = @columns + nb
337
+ ########## old algo
338
+ # nb_of_cells_to_adds = nb * @rows
339
+ # prev_nb_of_cells = @columns * @rows
340
+ # nb_of_cells_to_adds.times do |index|
341
+ # current_cell = self.box({ id: "#{id}_#{prev_nb_of_cells + index}" })
342
+ # apply_style(current_cell, @cell_style)
343
+ # end
344
+ # @columns = @columns + nb
345
+ format_matrix(id, @matrix_width, @matrix_height, @rows, @columns, @margin, @exceptions)
346
+ end
150
347
 
151
- @matrix_dataset.each_with_index do |cell_data, index|
152
- get_cell_data(cell_data, index)
348
+ def add_rows(nb)
349
+ prev_nb_of_cells = @columns * @rows
350
+ nb_of_cells_to_adds = nb * @columns
351
+ new_nb_of_cells = prev_nb_of_cells + nb_of_cells_to_adds
352
+ new_nb_of_cells.times do |index|
353
+ if index < prev_nb_of_cells
354
+ grab("#{id.value}_#{index}").delete(true)
355
+ # puts index
356
+ #
357
+ end
358
+ current_cell = self.box({ id: "#{id}_#{index}" })
359
+ apply_style(current_cell, @cell_style)
153
360
  end
361
+ @rows = @rows + nb
362
+ ########## old algo
363
+ # nb_of_cells_to_adds = nb * @columns
364
+ # prev_nb_of_cells = @columns * @rows
365
+ # nb_of_cells_to_adds.times do |index|
366
+ # current_cell = self.box({ id: "#{id}_#{prev_nb_of_cells + index}" })
367
+ # apply_style(current_cell, @cell_style)
368
+ # end
369
+ # @rows = @rows + nb
370
+ format_matrix(id, @matrix_width, @matrix_height, @rows, @columns, @margin, @exceptions)
371
+ end
372
+
373
+ def resize(width, height)
374
+ @matrix_width = width
375
+ @matrix_height = height
376
+ grab(id.value).width(width)
377
+ grab(id.value).height(height)
378
+ format_matrix(id, @matrix_width, @matrix_height, @rows, @columns, @margin, @exceptions)
154
379
  end
155
380
 
156
- def assign(cell_nb = nil, &proc)
157
- current_cell = grab("#{@matrix_id}_#{cell_nb}")
158
- if proc
159
- @matrix_dataset[cell_nb] << proc
160
- current_cell.instance_exec(&proc) if proc.is_a? Proc
381
+ def get_column_or_row(length, num_columns, index, is_column)
382
+ # puts "length: #{length}, #{num_columns} : #{num_columns}, index : #{index}, is_column : #{is_column}"
383
+ # Compute the number of line
384
+ num_rows = length / num_columns
385
+ if is_column
386
+ result = []
387
+ (0...num_rows).each do |row|
388
+ result << (index + row * num_columns)
389
+ end
390
+ return result
161
391
  else
162
- @matrix_dataset[cell_nb]
392
+ start_index = index * num_columns
393
+ end_index = start_index + num_columns - 1
394
+ return (start_index..end_index).to_a
163
395
  end
164
396
  end
165
397
 
166
- def reformat(params)
167
- @nb_of_rows = params[:rows]
168
- @nb_of_cols = params[:cols]
169
- resize_matrix({ height: height, width: width })
170
- end
171
398
  end
@@ -6,6 +6,7 @@ generator.build_atome(:animation)
6
6
  generator.build_atome(:color)
7
7
  generator.build_sanitizer(:color) do |params|
8
8
  parent_found = found_parents_and_renderers[:parent]
9
+ parent_found = [:user_view] if parent_found == [:view]
9
10
  render_found = found_parents_and_renderers[:renderers]
10
11
  default_params = { renderers: render_found, id: "color_#{Universe.atomes.length}", type: :color,
11
12
  attach: parent_found,
@@ -27,10 +28,11 @@ generator.build_atome(:shadow)
27
28
 
28
29
  generator.build_sanitizer(:shadow) do |params|
29
30
  parent_found = found_parents_and_renderers[:parent]
31
+ parent_found = [:user_view] if parent_found == [:view]
30
32
  render_found = found_parents_and_renderers[:renderers]
31
33
  default_params = { renderers: render_found, id: "shadow_#{Universe.atomes.length}", type: :shadow,
32
34
  attach: parent_found,
33
- red: 0, green: 0, blue: 0, alpha: 1 , blur: 3, left: 3, top: 3}
35
+ red: 0, green: 0, blue: 0, alpha: 1, blur: 3, left: 3, top: 3 }
34
36
  default_params.merge!(params)
35
37
  end
36
38
  generator.build_atome(:shape)
@@ -48,3 +50,5 @@ generator.build_sanitizer(:element) do |params|
48
50
  parents: parent_found }
49
51
  default_params.merge!(params)
50
52
  end
53
+
54
+ generator.build_atome(:collector)
@@ -5,11 +5,34 @@ generator = Genesis.generator
5
5
  generator.build_particle(:type)
6
6
  generator.build_particle(:parents)
7
7
  generator.build_particle(:children)
8
+ generator.build_option(:pre_render_parents) do |parents_ids|
9
+ parents_ids.each do |parents_id|
10
+ parents_id = parents_id.value if parents_id.instance_of? Atome
11
+ parents_found = grab(parents_id)
12
+ family(parents_id)
13
+ parents_found.atome[:children] << atome[:id]
14
+ end
15
+ end
16
+
17
+ generator.build_option(:pre_render_children) do |children_ids|
18
+ children_ids.each do |child_id|
19
+ child_id = child_id.value if child_id.instance_of? Atome
20
+ child_found = grab(child_id)
21
+ parents_found=@atome[:id]
22
+ child_found.family(parents_found)
23
+ child_found.atome[:parents] = [parents_found]
24
+ end
25
+ end
26
+
27
+ generator.build_particle(:family,{render: true,store: false})
28
+
29
+
8
30
  generator.build_particle(:link) do |child_id|
9
31
  child_found = grab(child_id)
10
32
  child_found.atome[:parents] << @atome[:id]
11
33
  child_found.refresh
12
34
  end
35
+
13
36
  generator.build_particle(:id)
14
37
  generator.build_sanitizer(:id) do |params|
15
38
  if @atome[:id] != params
@@ -19,29 +42,36 @@ generator.build_sanitizer(:id) do |params|
19
42
  end
20
43
  params
21
44
  end
22
- generator.build_option(:pre_render_parents) do |parents_id_found|
23
- parents_id_found.each do |parents_id|
24
- parents_found = grab(parents_id)
25
- parents_found.children << id if parents_found
26
- end
27
- end
45
+
28
46
  generator.build_particle(:name)
29
47
 
30
48
  generator.build_particle(:active)
31
49
 
32
- generator.build_particle(:attach) do |parents|
33
- parents.each do |parent|
34
- grab(parent).atome[:attached] = [atome[:id]]
50
+ generator.build_particle(:attach)
51
+ generator.build_particle(:attached)
52
+
53
+ generator.build_option(:pre_render_attach) do |parents_ids|
54
+ parents_ids.each do |parents_id|
55
+ parents_id = parents_id.value if parents_id.instance_of? Atome
56
+ parents_found = grab(parents_id)
57
+ family(parents_id)
58
+ parents_found.atome[:attached] = [] unless parents_found.atome[:attached]
59
+ parents_found.atome[:attached] << atome[:id]
35
60
  end
36
61
  end
37
62
 
38
- generator.build_particle(:attached) do |targets|
39
- targets.each do |target|
40
- grab(target).attach([atome[:id]])
63
+ generator.build_option(:pre_render_attached) do |children_ids|
64
+ children_ids.each do |child_id|
65
+ child_id = child_id.value if child_id.instance_of? Atome
66
+ child_found = grab(child_id)
67
+ parents_found=@atome[:id]
68
+ child_found.family(parents_found)
69
+ # parents_found.atome[:attach] = [] unless parents_found.atome[:attach]
70
+ child_found.atome[:attach] = [parents_found]
41
71
  end
42
72
  end
43
73
 
44
- generator.build_particle(:intricate, :array)
74
+ generator.build_particle(:intricate, {type: :array })
45
75
 
46
76
 
47
77
  generator.build_particle(:clones) do |clones_found|
@@ -2,11 +2,26 @@
2
2
 
3
3
  generator = Genesis.generator
4
4
 
5
- generator.build_particle(:red)
6
- generator.build_particle(:green)
7
- generator.build_particle(:blue)
8
- generator.build_particle(:alpha)
9
- generator.build_particle(:diffusion)
5
+ generator.build_particle(:red) do
6
+ # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
7
+ self
8
+ end
9
+ generator.build_particle(:green) do
10
+ # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
11
+ self
12
+ end
13
+ generator.build_particle(:blue) do
14
+ # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
15
+ self
16
+ end
17
+ generator.build_particle(:alpha) do
18
+ # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
19
+ self
20
+ end
21
+ generator.build_particle(:diffusion) do
22
+ # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
23
+ self
24
+ end
10
25
  generator.build_particle(:visual)
11
26
  generator.build_particle(:overflow)
12
27
  generator.build_particle(:edit)
@@ -2,4 +2,4 @@
2
2
 
3
3
  generator = Genesis.generator
4
4
  # create particles
5
- generator.build_particle(:markers, :hash)
5
+ generator.build_particle(:markers, { type: :hash })