atome 0.5.2.8 → 0.5.3.4

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