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.
- checksums.yaml +4 -4
- data/Rakefile +7 -1
- data/app_builder_helpers/Rakefile +2 -2
- data/exe/atome +7 -1
- data/lib/atome/atome.rb +28 -26
- data/lib/atome/extensions/atome.rb +4 -0
- data/lib/atome/extensions/matrix.rb +360 -130
- data/lib/atome/genesis/generators/atome.rb +5 -1
- data/lib/atome/genesis/generators/identity.rb +43 -13
- data/lib/atome/genesis/generators/material.rb +20 -5
- data/lib/atome/genesis/generators/time.rb +1 -1
- data/lib/atome/genesis/generators/utility.rb +26 -2
- data/lib/atome/genesis/genesis.rb +12 -4
- data/lib/atome/genesis/sparkle.rb +35 -3
- data/lib/atome/helpers/essentials.rb +24 -15
- data/lib/atome/helpers/utilities.rb +42 -3
- data/lib/atome/kernel/batch.rb +48 -0
- data/lib/atome/presets/atome.rb +22 -6
- data/lib/atome/renderers/browser/atome.rb +1 -3
- data/lib/atome/renderers/browser/browser.rb +14 -1
- data/lib/atome/renderers/browser/geometry.rb +10 -2
- data/lib/atome/renderers/browser/helpers/video_helper.rb +1 -1
- data/lib/atome/renderers/browser/helpers/web_helper.rb +1 -5
- data/lib/atome/renderers/browser/identity.rb +7 -11
- data/lib/atome/renderers/browser/material.rb +10 -0
- data/lib/atome/renderers/html/atome.rb +2 -0
- data/lib/atome/renderers/renderer.rb +3 -2
- data/lib/atome/version.rb +1 -1
- data/lib/atome.rb +2 -1
- data/sig/atome.rbs +14 -0
- data/vendor/assets/Rakefile +1 -1
- data/vendor/assets/src/css/style.css +6 -6
- data/vendor/assets/src/medias/rubies/examples/_2_solve.rb +41 -27
- data/vendor/assets/src/medias/rubies/examples/_attach.rb +12 -0
- data/vendor/assets/src/medias/rubies/examples/_audio.rb +81 -28
- data/vendor/assets/src/medias/rubies/examples/_dataset.rb +191 -111
- data/vendor/assets/src/medias/rubies/examples/_table2.rb +38 -0
- data/vendor/assets/src/medias/rubies/examples/clone.rb +4 -4
- data/vendor/assets/src/medias/rubies/examples/code.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/delete.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/drag.rb +2 -1
- data/vendor/assets/src/medias/rubies/examples/schedule.rb +5 -2
- data/vendor/assets/src/medias/rubies/examples/table.rb +479 -0
- data/vendor/assets/src/medias/rubies/examples/to_px.rb +10 -0
- metadata +8 -4
- data/vendor/assets/src/medias/rubies/examples/attach.rb +0 -12
@@ -1,171 +1,401 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
75
|
-
|
76
|
-
|
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
|
-
@
|
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
|
83
|
-
@
|
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
|
87
|
-
|
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
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
|
-
|
105
|
-
|
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
|
109
|
-
|
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
|
-
|
113
|
-
|
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
|
-
|
223
|
+
rows_data = if params[:rows]
|
224
|
+
params.delete(:rows)
|
225
|
+
else
|
226
|
+
{ count: 4 }
|
227
|
+
end
|
117
228
|
|
118
|
-
|
119
|
-
|
120
|
-
|
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
|
-
|
123
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
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
|
-
|
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
|
-
|
147
|
-
|
148
|
-
|
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
|
-
|
152
|
-
|
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
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
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
|
167
|
-
|
168
|
-
|
169
|
-
|
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
|
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
|
-
|
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)
|
33
|
-
|
34
|
-
|
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.
|
39
|
-
|
40
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
generator.build_particle(:
|
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)
|