atome 0.5.7.3.6 → 0.5.7.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/documentation/deep learning/architecture.txt +4 -4
- data/documentation/deep learning/basic_infos.txt +2 -2
- data/documentation/deep learning/example_of_users_code.rb +43 -43
- data/documentation/installation/buiding_atome.md +2 -2
- data/lib/atome/atome.rb +24 -56
- data/lib/atome/extensions/atome.rb +31 -77
- data/lib/atome/extensions/sha.rb +7 -7
- data/lib/atome/genesis/atomes.rb +1 -1
- data/lib/atome/genesis/genesis.rb +6 -95
- data/lib/atome/genesis/particles/communication.rb +1 -1
- data/lib/atome/genesis/particles/event.rb +0 -8
- data/lib/atome/genesis/particles/geometry.rb +3 -4
- data/lib/atome/genesis/particles/hierarchy.rb +28 -27
- data/lib/atome/genesis/particles/identity.rb +0 -30
- data/lib/atome/genesis/particles/material.rb +13 -12
- data/lib/atome/genesis/particles/property.rb +41 -16
- data/lib/atome/genesis/particles/security.rb +0 -45
- data/lib/atome/genesis/particles/utility.rb +77 -137
- data/lib/atome/genesis/sparkle.rb +3 -12
- data/lib/atome/kernel/black_matter.rb +2 -0
- data/lib/atome/kernel/universe.rb +5 -45
- data/lib/atome/presets/atome.rb +0 -22
- data/lib/atome/utilities/utilities.rb +19 -8
- data/lib/atome/version.rb +2 -1
- data/lib/molecules/init.rb +0 -14
- data/lib/molecules/intuition/tools.rb +24 -43
- data/lib/molecules/intuition/utilities.rb +261 -135
- data/lib/platform_specific/opal/atome_opal_extensions.rb +0 -1
- data/lib/platform_specific/opal/extensions/color.rb +0 -5
- data/lib/platform_specific/opal/extensions/geolocation.rb +5 -5
- data/lib/platform_specific/opal/extensions/object.rb +1 -1
- data/lib/platform_specific/opal/extensions/ping.rb +11 -20
- data/lib/renderers/html/effect.rb +0 -11
- data/lib/renderers/html/event.rb +0 -7
- data/lib/renderers/html/geometry.rb +0 -31
- data/lib/renderers/html/html.rb +32 -128
- data/lib/renderers/html/material.rb +0 -22
- data/lib/renderers/html/spatial.rb +0 -9
- data/lib/renderers/html/utility.rb +5 -8
- data/lib/renderers/renderer.rb +0 -1
- data/vendor/assets/application/examples/account.rb +35 -0
- data/vendor/assets/application/examples/actor&role.rb +23 -0
- data/vendor/assets/application/examples/animation.rb +1 -1
- data/vendor/assets/application/examples/applications.rb +26 -77
- data/vendor/assets/application/examples/atome.rb +1 -1
- data/vendor/assets/application/examples/attach.rb +7 -7
- data/vendor/assets/application/examples/attached.rb +13 -15
- data/vendor/assets/application/examples/basic_understanding.rb +1 -1
- data/vendor/assets/application/examples/buttons.rb +48 -0
- data/vendor/assets/application/examples/clear.rb +12 -12
- data/vendor/assets/application/examples/clones&monitoring.rb +1 -1
- data/vendor/assets/application/examples/delete.rb +19 -14
- data/vendor/assets/application/examples/detach.rb +8 -0
- data/vendor/assets/application/examples/dig.rb +1 -1
- data/vendor/assets/application/examples/display.rb +6 -6
- data/vendor/assets/application/examples/drag.rb +1 -1
- data/vendor/assets/application/examples/duplicate.rb +6 -6
- data/vendor/assets/application/examples/exchange.rb +17 -0
- data/vendor/assets/application/examples/generator_and_build.rb +3 -3
- data/vendor/assets/application/examples/hierarchy.rb +5 -5
- data/vendor/assets/application/examples/layout.rb +1 -1
- data/vendor/assets/application/examples/preset.rb +3 -3
- data/vendor/assets/application/examples/selected.rb +1 -1
- data/vendor/assets/application/examples/shapes.rb +1 -1
- data/vendor/assets/application/examples/size.rb +1 -1
- data/vendor/assets/application/examples/test.rb +0 -320
- data/vendor/assets/application/examples/tools.rb +136 -192
- data/vendor/assets/application/examples/unfasten.rb +23 -0
- data/vendor/assets/application/index.rb +1 -1
- data/vendor/assets/server/atome_server.rb +1 -0
- data/vendor/assets/server/capture.rb +0 -1
- data/vendor/assets/server/database.rb +0 -1
- data/vendor/assets/server/eDen.rb +16 -94
- data/vendor/assets/src/index_server_wasm.html +1 -0
- data/vendor/assets/src/index_wasm.html +0 -6
- data/vendor/assets/src/js/atome/specific/wasm.js +22 -4
- data/vendor/assets/src/js/third_parties/three.min.js +1 -1
- data/vendor/assets/src/medias/fonts/Roboto/LICENSE.txt +1 -1
- data/vendor/assets/src/medias/fonts/Roboto_Slab/LICENSE.txt +1 -1
- metadata +8 -6
- data/lib/molecules/_deprecated_examples/site.rb +0 -34
- data/lib/molecules/intuition/_deprecated_inputs.rb +0 -111
- data/lib/molecules/intuition/_deprecated_toolbox.rb +0 -282
- data/lib/platform_specific/opal/extensions/sha.rb +0 -25
@@ -42,31 +42,15 @@ module ObjectExtension
|
|
42
42
|
end
|
43
43
|
render_method = "#{renderer_found}_#{params[:specific]}#{params[:method]}"
|
44
44
|
Genesis.build_render(render_method, &bloc)
|
45
|
-
# elsif params.key?(:callback)
|
46
|
-
# particle_targetted = params[:callback]
|
47
|
-
# Atome.define_method("#{particle_targetted}_callback", option) do
|
48
|
-
# alert option
|
49
|
-
# bloc.call(option)
|
50
|
-
# end
|
51
45
|
elsif params.key?(:molecule)
|
52
46
|
molecule = params[:molecule]
|
53
47
|
Genesis.build_molecule(molecule, &bloc)
|
54
48
|
Universe.add_to_molecule_list(molecule)
|
55
|
-
|
56
|
-
# elsif params.key?(:applicaton)
|
57
|
-
# alert params
|
58
|
-
|
59
|
-
# molecule=params[:molecule]
|
60
|
-
# Genesis.build_molecule(molecule, &bloc)
|
61
|
-
# Universe.add_to_molecule_list(molecule)
|
62
49
|
elsif params.key?(:tool)
|
63
50
|
# we only store tools definition in the universe so it can be instanced using "A.build_tool" method when needed
|
64
|
-
|
65
51
|
tool_content = Atome.instance_exec(&bloc) if bloc.is_a?(Proc)
|
66
|
-
|
67
52
|
Universe.tools[params[:tool]] = tool_content
|
68
53
|
# Universe.tools[params[:tool]]=bloc
|
69
|
-
|
70
54
|
elsif params.key?(:template)
|
71
55
|
A.build_template(&bloc)
|
72
56
|
elsif params.key?(:code)
|
@@ -75,22 +59,40 @@ module ObjectExtension
|
|
75
59
|
A.build_test(&bloc)
|
76
60
|
elsif params.key?(:preset)
|
77
61
|
Atome.preset_builder(params[:preset], &bloc)
|
78
|
-
# A.build_test(&bloc)
|
79
62
|
end
|
80
63
|
super if defined?(super)
|
81
64
|
end
|
82
65
|
|
83
66
|
end
|
67
|
+
|
84
68
|
# atome extensions
|
85
69
|
class Object
|
86
70
|
include ObjectExtension
|
71
|
+
|
72
|
+
def deep_copy(obj)
|
73
|
+
# utility for buttons
|
74
|
+
case obj
|
75
|
+
when Hash
|
76
|
+
obj.each_with_object({}) do |(k, v), h|
|
77
|
+
unless k == :code # exception to avoid Proc accumulation
|
78
|
+
h[deep_copy(k)] = deep_copy(v)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
when Array
|
82
|
+
obj.map { |e| deep_copy(e) }
|
83
|
+
else
|
84
|
+
obj.dup rescue obj
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
87
88
|
def flash(msg)
|
88
|
-
flash_box=box({width: 235, height: 112})
|
89
|
+
flash_box = box({ width: 235, height: 112 })
|
89
90
|
flash_box.text(msg)
|
90
91
|
flash_box.touch(true) do
|
91
92
|
flash_box.delete({ recursive: true })
|
92
93
|
end
|
93
94
|
end
|
95
|
+
|
94
96
|
def reorder_particles(hash_to_reorder)
|
95
97
|
# we reorder the hash
|
96
98
|
ordered_keys = %i[renderers id alien type attach int8 unit]
|
@@ -99,7 +101,6 @@ class Object
|
|
99
101
|
other_part = hash_to_reorder.reject { |k, _| ordered_keys.include?(k) }
|
100
102
|
# merge the parts to obtain an re-ordered hash
|
101
103
|
ordered_part.merge(other_part)
|
102
|
-
# reordered_hash
|
103
104
|
end
|
104
105
|
|
105
106
|
def delete (atomes)
|
@@ -120,31 +121,9 @@ class Object
|
|
120
121
|
return if id_to_get == false
|
121
122
|
aid_to_get = Universe.atomes_ids[id_to_get]
|
122
123
|
aid_to_get = '' if aid_to_get.instance_of? Array
|
123
|
-
# id_to_get = id_to_get.to_sym
|
124
|
-
|
125
|
-
# if id_to_get.nil? do
|
126
|
-
# if aid_to_get.nil?
|
127
|
-
# alert id_to_get
|
128
|
-
# else
|
129
|
-
|
130
|
-
# end
|
131
|
-
# end
|
132
|
-
# alert Universe.atomes[id_to_get]
|
133
124
|
Universe.atomes[aid_to_get]
|
134
125
|
end
|
135
126
|
|
136
|
-
# def box(params = {}, &proc)
|
137
|
-
# grab(:view).box(params, &proc)
|
138
|
-
# end
|
139
|
-
#
|
140
|
-
# # def intuition(params = {}, &proc)
|
141
|
-
# # grab(:view).intuition(params, &proc)
|
142
|
-
# # end
|
143
|
-
#
|
144
|
-
# def circle(params = {}, &proc)
|
145
|
-
# grab(:view).circle(params, &proc)
|
146
|
-
# end
|
147
|
-
|
148
127
|
# the method below generate Atome method creation at Object level
|
149
128
|
def atome_method_for_object(element)
|
150
129
|
Object.define_method element do |params, &user_proc|
|
@@ -170,10 +149,6 @@ class Object
|
|
170
149
|
id
|
171
150
|
end
|
172
151
|
|
173
|
-
# def repeater(counter, proc)
|
174
|
-
# instance_exec(counter, &proc) if proc.is_a?(Proc)
|
175
|
-
# end
|
176
|
-
|
177
152
|
def repeat_callback(params, counter)
|
178
153
|
@repeat[params].call(counter)
|
179
154
|
end
|
@@ -303,7 +278,6 @@ class Object
|
|
303
278
|
end
|
304
279
|
console_top.shadow({
|
305
280
|
id: :s1,
|
306
|
-
# affect: [:the_circle],
|
307
281
|
left: 0, top: 3, blur: 9,
|
308
282
|
invert: false,
|
309
283
|
red: 0, green: 0, blue: 0, alpha: 1
|
@@ -313,8 +287,6 @@ class Object
|
|
313
287
|
y = console.to_px(:top) + dy.to_f
|
314
288
|
console.top(y)
|
315
289
|
console.height(:auto)
|
316
|
-
total_height = grab(:view).to_px(:height)
|
317
|
-
# console_back.height(total_height-console.top)
|
318
290
|
end
|
319
291
|
console_output = console_back.text({ data: '', id: :console_output, component: { size: 12 } })
|
320
292
|
JS.eval <<~JS
|
@@ -328,7 +300,7 @@ class Object
|
|
328
300
|
oldLog.apply(console, arguments);
|
329
301
|
};
|
330
302
|
}());
|
331
|
-
|
303
|
+
JS
|
332
304
|
|
333
305
|
console_clear = console_top.circle({ id: :console_clear, color: :red, top: 3, left: 3, width: 19, height: 19 })
|
334
306
|
console_clear.touch(true) do
|
@@ -336,8 +308,6 @@ class Object
|
|
336
308
|
end
|
337
309
|
JS.global[:document].addEventListener("contextmenu") do |event|
|
338
310
|
end
|
339
|
-
# element[:style][:WebkitUserSelect] = 'none'
|
340
|
-
# element[:style][:MozUserSelect] = 'none'
|
341
311
|
else
|
342
312
|
grab(:console_back).delete(true)
|
343
313
|
JS.global[:document].addEventListener("contextmenu") do |native_event|
|
@@ -446,7 +416,7 @@ class Object
|
|
446
416
|
ids = []
|
447
417
|
dig_recursive = lambda do |atome|
|
448
418
|
ids << atome.id
|
449
|
-
atome.
|
419
|
+
atome.fasten.each { |fasten_atome| dig_recursive.call(grab(fasten_atome)) }
|
450
420
|
end
|
451
421
|
dig_recursive.call(self)
|
452
422
|
ids
|
@@ -485,19 +455,13 @@ class Object
|
|
485
455
|
current_atome.height(current_atome.to_px(:height) * ratio)
|
486
456
|
end
|
487
457
|
end
|
488
|
-
# total_size, max_other_axis_size = calculate_total_size(objet_atome, axis)
|
489
|
-
# scale_factor = target_size.to_f / total_size
|
490
|
-
# resize_and_reposition(objet_atome, scale_factor, axis, max_other_axis_size)
|
491
458
|
end
|
492
459
|
|
493
460
|
def found_area_used(ids)
|
494
|
-
|
495
461
|
min_x, min_y = Float::INFINITY, Float::INFINITY
|
496
462
|
max_x, max_y = 0, 0
|
497
|
-
|
498
463
|
ids.each do |id|
|
499
464
|
atome = grab(id)
|
500
|
-
|
501
465
|
x = atome.compute({ particle: :left })[:value]
|
502
466
|
y = atome.compute({ particle: :top })[:value]
|
503
467
|
width = atome.to_px(:width)
|
@@ -507,24 +471,19 @@ class Object
|
|
507
471
|
max_x = [max_x, x + width].max
|
508
472
|
max_y = [max_y, y + height].max
|
509
473
|
end
|
510
|
-
|
511
474
|
{ min: { x: min_x, y: min_y }, max: { x: max_x, y: max_y } }
|
512
|
-
|
513
475
|
end
|
514
476
|
|
515
477
|
def calculate_total_size(objet_atome, axis)
|
516
478
|
total_size = (axis == :x) ? objet_atome.to_px(:width) : objet_atome.to_px(:height)
|
517
479
|
max_other_axis_size = (axis == :x) ? objet_atome.to_px(:height) : objet_atome.to_px(:width)
|
518
|
-
|
519
|
-
objet_atome.attached.each do |child_id|
|
480
|
+
objet_atome.fasten.each do |child_id|
|
520
481
|
child = grab(child_id)
|
521
482
|
child_size = (axis == :x) ? child.to_px(:width) : child.to_px(:height)
|
522
483
|
other_axis_size = (axis == :x) ? child.to_px(:height) : child.to_px(:width)
|
523
|
-
|
524
484
|
total_size += child_size
|
525
485
|
max_other_axis_size = [max_other_axis_size, other_axis_size].max
|
526
486
|
end
|
527
|
-
|
528
487
|
[total_size, max_other_axis_size]
|
529
488
|
end
|
530
489
|
|
@@ -532,7 +491,7 @@ class Object
|
|
532
491
|
current_position = 0
|
533
492
|
resize_object(objet_atome, scale_factor, axis, max_other_axis_size)
|
534
493
|
current_position += (axis == :x) ? objet_atome.to_px(:width) : objet_atome.to_px(:height)
|
535
|
-
objet_atome.
|
494
|
+
objet_atome.fasten.each do |child_id|
|
536
495
|
child = grab(child_id)
|
537
496
|
resize_object(child, scale_factor, axis, max_other_axis_size)
|
538
497
|
child.top(child.top * scale_factor)
|
@@ -560,11 +519,11 @@ class Object
|
|
560
519
|
params = { target: params }
|
561
520
|
end
|
562
521
|
id = params[:id]
|
563
|
-
if id
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
522
|
+
id_wanted = if id
|
523
|
+
{ id: id }
|
524
|
+
else
|
525
|
+
{}
|
526
|
+
end
|
568
527
|
basis = { alien: params[:target], renderers: [:html], type: :atomized }.merge(id_wanted)
|
569
528
|
a = Atome.new(basis)
|
570
529
|
return a
|
@@ -573,10 +532,8 @@ class Object
|
|
573
532
|
|
574
533
|
def touch_allow(allow)
|
575
534
|
if allow
|
576
|
-
# Retire l'écouteur d'événements en utilisant la fonction globale
|
577
535
|
JS.eval('document.removeEventListener("contextmenu", window.preventDefaultAction);')
|
578
536
|
else
|
579
|
-
# Ajoute l'écouteur d'événements en utilisant la fonction globale
|
580
537
|
JS.eval('document.addEventListener("contextmenu", window.preventDefaultAction);')
|
581
538
|
end
|
582
539
|
end
|
@@ -586,13 +543,13 @@ class Object
|
|
586
543
|
# allow selection and text copy
|
587
544
|
JS.eval(<<~JS)
|
588
545
|
document.body.style.userSelect = 'auto'; // allow text slectiion
|
589
|
-
document.removeEventListener('copy', preventDefaultAction); // allow copy
|
546
|
+
document.removeEventListener('copy', preventDefaultAction); // allow copy
|
590
547
|
JS
|
591
548
|
else
|
592
549
|
# lock selection and text copy
|
593
550
|
JS.eval(<<~JS)
|
594
551
|
document.body.style.userSelect = 'none'; // prevent text selection
|
595
|
-
document.addEventListener('copy', preventDefaultAction); // prevent copy
|
552
|
+
document.addEventListener('copy', preventDefaultAction); // prevent copy
|
596
553
|
JS
|
597
554
|
end
|
598
555
|
end
|
@@ -811,7 +768,4 @@ class CssProxy
|
|
811
768
|
parsed = JSON.parse(msg)
|
812
769
|
bloc.call(parsed)
|
813
770
|
end
|
814
|
-
|
815
771
|
end
|
816
|
-
|
817
|
-
|
data/lib/atome/extensions/sha.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# # frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
|
3
|
+
# to create a hash
|
4
|
+
class Atome
|
5
|
+
def calculate_sha(string)
|
6
|
+
Digest::SHA256.hexdigest(string)
|
7
|
+
end
|
8
|
+
end
|
data/lib/atome/genesis/atomes.rb
CHANGED
@@ -90,7 +90,7 @@ new({ post: :text }) do |params|
|
|
90
90
|
if index == 0
|
91
91
|
send(:data, data_found)
|
92
92
|
else
|
93
|
-
# we create new text's atome
|
93
|
+
# we create new text's atome fasten to the main one (the first element above)
|
94
94
|
text(data_found)
|
95
95
|
end
|
96
96
|
|
@@ -22,8 +22,6 @@ class Genesis
|
|
22
22
|
# we add the new method to the particle's collection of methods
|
23
23
|
Universe.add_to_particle_list(particle_name, type, category)
|
24
24
|
# the line below create an empty particle method for each renderer, eg: browser_left, headless_width, ...
|
25
|
-
# the line below create the corresponding particle method for Batch class
|
26
|
-
# particle_method_for_batch(particle_name)
|
27
25
|
auto_render_generator(particle_name) if render
|
28
26
|
new_particle(particle_name, store, render, &particle_proc)
|
29
27
|
# the line below create all alternatives methods such as create 'method='
|
@@ -36,11 +34,9 @@ class Genesis
|
|
36
34
|
# the method below generate Atome method creation at Object level,
|
37
35
|
# so a syntax like : 'text(:hello)' is possible instead of the mandatory : grab(:view).text(:hello)
|
38
36
|
atome_method_for_object(atome_name)
|
39
|
-
# the line below create the corresponding atome method for Batch class
|
40
|
-
# atome_method_for_batch(atome_name)
|
41
37
|
unless Essentials.default_params[atome_name]
|
42
38
|
# we create default params for the new created atome, adding the hash to : module essential, @default_params
|
43
|
-
# FIXME : the hash : attach: [:view] means that newly atome will systematically be
|
39
|
+
# FIXME : the hash : attach: [:view] means that newly atome will systematically be fasten to the wview instaed of the parent:
|
44
40
|
# ex : b.www will attach to view not b!
|
45
41
|
Essentials.new_default_params(atome_name => { type: atome_name })
|
46
42
|
end
|
@@ -76,9 +72,6 @@ class Genesis
|
|
76
72
|
end
|
77
73
|
|
78
74
|
def new_particle(element, store, render, &_method_proc)
|
79
|
-
# unless @id
|
80
|
-
# alert self.id
|
81
|
-
# end
|
82
75
|
|
83
76
|
Atome.define_method element do |params = nil, &user_proc|
|
84
77
|
@history[element] ||= []
|
@@ -87,7 +80,6 @@ class Genesis
|
|
87
80
|
params = particle_sanitizer(element, params, &user_proc)
|
88
81
|
# the line below execute the main code when creating a new particle
|
89
82
|
# ex : new({ particle: :my_particle } do....
|
90
|
-
# instance_exec(params, user_proc, &method_proc) if method_proc.is_a?(Proc)
|
91
83
|
Genesis.create_particle(element, store, render)
|
92
84
|
# TODO: try to optimise and find a better way wo we can remove the condition below
|
93
85
|
if @type == :group && !%i[type id collect layout].include?(element)
|
@@ -98,18 +90,12 @@ class Genesis
|
|
98
90
|
|
99
91
|
computed_params = send("set_#{element}", params, &user_proc) # sent to : create_particle / Atome.define_method "set_#{element}"
|
100
92
|
|
101
|
-
# we historicize all write action below
|
102
|
-
# we add the changes to the stack that must be synchronised
|
103
|
-
# Universe.historicize(@aid, :write, element, params)
|
104
93
|
computed_params
|
105
94
|
elsif params || params == false
|
106
95
|
"send a valid password to write #{element} value"
|
107
96
|
elsif read_auth(element)
|
108
97
|
# particle getter below
|
109
98
|
value_found = instance_variable_get("@#{element}")
|
110
|
-
# uncomment below to historicize all read action
|
111
|
-
# Universe.historicize(@id, :read, element, value_found)
|
112
|
-
# we add the optional read plugin
|
113
99
|
value_found = particle_read(element, value_found, &user_proc)
|
114
100
|
value_found
|
115
101
|
# TODO : create a fast method to get particle: eg:
|
@@ -117,9 +103,6 @@ class Genesis
|
|
117
103
|
else
|
118
104
|
"send a valid password to read #{element} value"
|
119
105
|
end
|
120
|
-
# else
|
121
|
-
#
|
122
|
-
# end
|
123
106
|
end
|
124
107
|
end
|
125
108
|
|
@@ -145,25 +128,18 @@ class Genesis
|
|
145
128
|
# as getter should give us all atome of a given within the atome
|
146
129
|
# ex : puts a.shape => return all atome with the type 'shape' in this atome
|
147
130
|
collected_atomes = []
|
148
|
-
# attached.each do |attached_atome|
|
149
|
-
# collected_atomes << attached_atome if grab(attached_atome).type.to_sym == element.to_sym
|
150
|
-
# end
|
151
131
|
if Universe.applicable_atomes.include?(element)
|
152
|
-
# we do the same for apply to be able to retrieve 'color' and other atome that apply instead of being
|
153
|
-
@apply.each do |
|
154
|
-
collected_atomes <<
|
132
|
+
# we do the same for apply to be able to retrieve 'color' and other atome that apply instead of being fasten
|
133
|
+
@apply.each do |fasten_atome|
|
134
|
+
collected_atomes << fasten_atome if grab(fasten_atome).type.to_sym == element.to_sym
|
155
135
|
end
|
156
136
|
else
|
157
|
-
|
158
|
-
|
159
|
-
attached.each do |attached_atome|
|
160
|
-
collected_atomes << attached_atome if grab(attached_atome).type.to_sym == element.to_sym
|
137
|
+
fasten.each do |fasten_atome|
|
138
|
+
collected_atomes << fasten_atome if grab(fasten_atome).type.to_sym == element.to_sym
|
161
139
|
end
|
162
|
-
# end
|
163
140
|
|
164
141
|
end
|
165
142
|
# TODO/ FIXME : potential problem with group here"
|
166
|
-
# group({ collect: collected_atomes })
|
167
143
|
collected_atomes
|
168
144
|
end
|
169
145
|
end
|
@@ -174,7 +150,6 @@ class Genesis
|
|
174
150
|
# Object.const_set(element, Module.new)
|
175
151
|
# we add the newly created atome to the list of "child in it's category, eg if it's a shape we add the new atome
|
176
152
|
# to the shape particles list : @!atome[:shape] << params[:id]
|
177
|
-
# Atome.new(params, &user_proc)
|
178
153
|
|
179
154
|
if Universe.atomes[params[:id]]
|
180
155
|
# if atome id already exist we grab the previous one
|
@@ -192,75 +167,11 @@ class Genesis
|
|
192
167
|
end
|
193
168
|
|
194
169
|
def new_molecule(molecule, &method_proc)
|
195
|
-
|
196
170
|
Molecule.define_method molecule do |params, &user_proc|
|
197
171
|
object_to_return = instance_exec(params, user_proc, &method_proc) if method_proc.is_a?(Proc)
|
198
|
-
# new_objet = Object.new
|
199
|
-
# # we store the molecule into an instance variable in a basic ruby object
|
200
|
-
# new_objet.instance_variable_set(:@molecule, object_to_return)
|
201
|
-
# new_objet
|
202
172
|
object_to_return
|
203
173
|
end
|
204
|
-
|
205
|
-
# # the method define below is the slowest but params are analysed and sanitized
|
206
|
-
# Atome.define_method element do |params = nil, &user_proc|
|
207
|
-
# instance_exec(params, user_proc, &method_proc) if method_proc.is_a?(Proc)
|
208
|
-
# if params
|
209
|
-
# params = atome_sanitizer(element, params, &user_proc)
|
210
|
-
# atome_processor(element, params, &user_proc)
|
211
|
-
# else
|
212
|
-
# # when no params passed whe assume teh user want a getter,
|
213
|
-
# # as getter should give us all atome of a given within the atome
|
214
|
-
# # ex : puts a.shape => return all atome with the type 'shape' in this atome
|
215
|
-
# collected_atomes = []
|
216
|
-
# # attached.each do |attached_atome|
|
217
|
-
# # collected_atomes << attached_atome if grab(attached_atome).type.to_sym == element.to_sym
|
218
|
-
# # end
|
219
|
-
# # TODO : add category for atome( material/physical vs modifier : color, shadow, .. vs shape, image ..)
|
220
|
-
# # then add condition same things fo code in presets/atome atome_common
|
221
|
-
# if %i[color shadow paint border].include?(element)
|
222
|
-
# # we do the same for apply to be able to retrieve 'color' and other atome that apply instead of being attached
|
223
|
-
# @apply.each do |attached_atome|
|
224
|
-
# collected_atomes << attached_atome if grab(attached_atome).type.to_sym == element.to_sym
|
225
|
-
# end
|
226
|
-
# else
|
227
|
-
# # collected_atomes = attached
|
228
|
-
# # if @attached
|
229
|
-
# attached.each do |attached_atome|
|
230
|
-
# collected_atomes << attached_atome if grab(attached_atome).type.to_sym == element.to_sym
|
231
|
-
# end
|
232
|
-
# # end
|
233
|
-
#
|
234
|
-
# end
|
235
|
-
# # TODO/ FIXME : potential problem with group here"
|
236
|
-
# # group({ collect: collected_atomes })
|
237
|
-
# collected_atomes
|
238
|
-
# end
|
239
|
-
# end
|
240
|
-
#
|
241
|
-
# # the method define below is the fastest params are passed directly
|
242
|
-
# Atome.define_method "set_#{element}" do |params, &user_proc|
|
243
|
-
# # we generate the corresponding module here:
|
244
|
-
# # Object.const_set(element, Module.new)
|
245
|
-
# # we add the newly created atome to the list of "child in it's category, eg if it's a shape we add the new atome
|
246
|
-
# # to the shape particles list : @!atome[:shape] << params[:id]
|
247
|
-
# # Atome.new(params, &user_proc)
|
248
|
-
#
|
249
|
-
# if Universe.atomes[params[:id]]
|
250
|
-
# # if atome id already exist we grab the previous one
|
251
|
-
# # this prevent the creation of new atome if the atome already exist
|
252
|
-
# previous_atome= grab(params[:id])
|
253
|
-
# # now we must re-affect affected atomes
|
254
|
-
# previous_atome.affect(params[:affect])
|
255
|
-
# previous_atome
|
256
|
-
# else
|
257
|
-
# Atome.new(params, &user_proc)
|
258
|
-
# end
|
259
|
-
# # Now we return the newly created atome instead of the current atome that is the parent cf: b=box; c=b.circle
|
260
|
-
# end
|
261
|
-
|
262
174
|
end
|
263
|
-
|
264
175
|
end
|
265
176
|
|
266
177
|
end
|
@@ -28,7 +28,7 @@ new({ particle: :language, category: :communication, type: :string }) do |params
|
|
28
28
|
@data = int8[params]
|
29
29
|
params
|
30
30
|
end
|
31
|
-
# method below are used for communication with
|
31
|
+
# method below are used for communication with native core
|
32
32
|
def receptor(msg)
|
33
33
|
parsed = JSON.parse(msg)
|
34
34
|
A.controller_code[:controller].call(parsed)
|
@@ -1,9 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
class Atome
|
3
3
|
def animation_callback(proc_sub_category, value=nil)
|
4
|
-
# puts "#{p◊roc_sub_category}"
|
5
4
|
proc_found = @animate_code[proc_sub_category]
|
6
|
-
# puts proc_found
|
7
5
|
instance_exec(value,&proc_found) if proc_found.is_a?(Proc)
|
8
6
|
end
|
9
7
|
end
|
@@ -371,9 +369,3 @@ end
|
|
371
369
|
new({ after: :animate }) do |params|
|
372
370
|
html.animate(params) unless params[:end] || params[:start]
|
373
371
|
end
|
374
|
-
|
375
|
-
|
376
|
-
# new({ particle: :repeat, category: :event, type: :boolean })
|
377
|
-
# # new({ particle: :sort }) do |_value, sort_proc|
|
378
|
-
# # @sort_proc = sort_proc
|
379
|
-
# # end
|
@@ -7,10 +7,9 @@ new({ particle: :size, category: :geometry, type: :int }) do |params|
|
|
7
7
|
params = { value: params } unless params.instance_of? Hash
|
8
8
|
params[:recursive] ||= false
|
9
9
|
params[:reference] ||= :x
|
10
|
-
params[:target] ||= :self # :all resize atome +
|
11
|
-
# self: resize the current atome to current value
|
10
|
+
params[:target] ||= :self # :all resize atome + fasten +distance between to the value
|
12
11
|
params[:propagate] ||= :raw # proportional atome children will be resize according
|
13
|
-
# to its parent , raw apply the raw value to the
|
12
|
+
# to its parent , raw apply the raw value to the fasten atomes
|
14
13
|
if params[:reference] == :x
|
15
14
|
original_width = width
|
16
15
|
width(params[:value])
|
@@ -22,7 +21,7 @@ new({ particle: :size, category: :geometry, type: :int }) do |params|
|
|
22
21
|
end
|
23
22
|
|
24
23
|
if params[:recursive]
|
25
|
-
|
24
|
+
fasten.each do |atome_id|
|
26
25
|
grab(atome_id).size(params)
|
27
26
|
end
|
28
27
|
|
@@ -3,26 +3,19 @@ def detach_child(child)
|
|
3
3
|
return unless child.attach
|
4
4
|
|
5
5
|
parent = grab(child.attach)
|
6
|
-
parent.
|
6
|
+
parent.fasten.delete(@id)
|
7
7
|
|
8
8
|
end
|
9
9
|
|
10
|
-
# def detach_from_parent(parent_found, child_found)
|
11
|
-
# child_found.attach(parent_found.id)
|
12
|
-
# end
|
13
|
-
|
14
10
|
def attachment_common(child_id, parents_id, direction, &user_proc)
|
15
11
|
|
16
12
|
parent_found = grab(parents_id)
|
17
13
|
if direction == :attach
|
18
14
|
if parent_found
|
19
|
-
parent_found.
|
20
|
-
parent_found.
|
15
|
+
parent_found.fasten ||= []
|
16
|
+
parent_found.fasten.push(@id) unless parent_found.fasten.include?(@id)
|
21
17
|
detach_child(self)
|
22
18
|
render(:attach, parents_id, &user_proc)
|
23
|
-
else
|
24
|
-
# we remove the current id from parent
|
25
|
-
# grab(attach).attached.delete(@id)
|
26
19
|
end
|
27
20
|
else
|
28
21
|
child_found = grab(child_id)
|
@@ -36,19 +29,41 @@ new({ particle: :attach, category: :hierarchy, type: :string, render: false }) d
|
|
36
29
|
parents_id
|
37
30
|
end
|
38
31
|
|
39
|
-
new({ particle: :
|
32
|
+
new({ particle: :fasten, category: :hierarchy, type: :string, render: false }) do |children_ids, &user_proc|
|
40
33
|
children_ids = [children_ids] unless children_ids.instance_of?(Array)
|
41
34
|
parents_id = @id
|
42
35
|
children_ids.each do |children_id|
|
43
|
-
attachment_common(children_id, parents_id, :
|
36
|
+
attachment_common(children_id, parents_id, :fasten, &user_proc)
|
44
37
|
end
|
45
38
|
children_ids
|
46
39
|
end
|
47
40
|
|
48
|
-
new({ sanitizer: :
|
41
|
+
new({ sanitizer: :fasten }) do |children_ids|
|
49
42
|
children_ids
|
50
43
|
end
|
51
44
|
|
45
|
+
new({ particle: :unfasten }) do |params|
|
46
|
+
params = fasten if params == :all
|
47
|
+
dup_params = params.dup
|
48
|
+
dup_params.each do |param|
|
49
|
+
if fasten.include?(param)
|
50
|
+
fasten.delete(param)
|
51
|
+
atome_to_unfasten = grab(param)
|
52
|
+
atome_to_unfasten_left = atome_to_unfasten.left
|
53
|
+
atome_to_unfasten_top = atome_to_unfasten.top
|
54
|
+
parent_top = top
|
55
|
+
parent_left = left
|
56
|
+
atome_to_unfasten.attach(:view)
|
57
|
+
atome_to_unfasten.left(atome_to_unfasten_left + parent_left)
|
58
|
+
atome_to_unfasten.top(atome_to_unfasten_top + parent_top)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
new({ particle: :detach }) do |params|
|
64
|
+
grab(params).unfasten([id])
|
65
|
+
end
|
66
|
+
|
52
67
|
new({ particle: :apply, category: :hierarchy, type: :string, render: false, store: false }) do |parents_ids, &user_proc|
|
53
68
|
@apply ||= []
|
54
69
|
parents_ids = [parents_ids] unless parents_ids.instance_of?(Array)
|
@@ -88,18 +103,4 @@ new({ particle: :affect, category: :hierarchy, type: :string, render: false }) d
|
|
88
103
|
children_ids
|
89
104
|
end
|
90
105
|
|
91
|
-
new({ particle: :detached, category: :hierarchy, type: :string, store: false }) # unfastened
|
92
|
-
new({ sanitizer: :detached }) do |values|
|
93
|
-
# unfastened
|
94
|
-
if values.instance_of? Array
|
95
|
-
values.each do |value|
|
96
|
-
detach_atome(value)
|
97
|
-
end
|
98
|
-
else
|
99
|
-
detach_atome(values)
|
100
|
-
# we sanitize the values so it always return an array to the renderer
|
101
|
-
values = [values]
|
102
|
-
end
|
103
|
-
values
|
104
|
-
end
|
105
106
|
new({ particle: :collect, category: :hierarchy, type: :string })
|
@@ -7,41 +7,11 @@ new({ sanitizer: :id }) do |params|
|
|
7
7
|
# first we sanitize the the id below
|
8
8
|
|
9
9
|
params = params.to_sym
|
10
|
-
# we check id is already assign
|
11
|
-
# the condition below is to prevent the creation of multiple unwanted colors with same property and no ID specified
|
12
|
-
# if @id.to_sym != params
|
13
|
-
# Universe.update_atome_id(params, self, @id)
|
14
|
-
# else
|
15
|
-
# Universe.add_to_atomes(params, self)
|
16
|
-
# end
|
17
|
-
|
18
|
-
# Universe.atomes.each do |_aid,atome_f|
|
19
|
-
#
|
20
|
-
# if atome_f.id == params
|
21
|
-
# puts "===> no for #{params}"
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# end
|
25
10
|
|
26
11
|
params
|
27
12
|
end
|
28
13
|
new({ particle: :name, category: :identity, type: :string })
|
29
14
|
new({ particle: :active, category: :identity, type: :boolean })
|
30
|
-
# new({ particle: :entangled, type: :array })
|
31
|
-
# new({ particle: :clones }) do |clones_found|
|
32
|
-
# clones_found.each_with_index do |clone_found, index|
|
33
|
-
# particles_entangled = clone_found[:entangled] ||= []
|
34
|
-
# clone_id = "#{particles[:id]}_clone_#{index}"
|
35
|
-
# original_id = atome[:id]
|
36
|
-
# clone_found[:id] = clone_id
|
37
|
-
# clone_found = particles.merge(clone_found)
|
38
|
-
# clone_found.delete(:html_object)
|
39
|
-
# cloned_atome = Atome.new(clone_found)
|
40
|
-
# monitor({ atomes: [original_id], particles: particles_entangled }) do |_atome, particle, value|
|
41
|
-
# cloned_atome.send(particle, value)
|
42
|
-
# end
|
43
|
-
# end
|
44
|
-
# end
|
45
15
|
new({ particle: :markup, category: :identity, type: :string })
|
46
16
|
new({ particle: :bundle, category: :identity, type: :string })
|
47
17
|
new({ particle: :data, category: :identity, type: :string })
|