atome 0.5.7.1.2 → 0.5.7.1.6
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/atome.gemspec +2 -2
- data/documentation/deep learning/basic_infos.txt +1 -1
- data/lib/atome/extensions/atome.rb +57 -19
- data/lib/atome/genesis/atomes.rb +11 -0
- data/lib/atome/genesis/particles/event.rb +24 -2
- data/lib/atome/genesis/sparkle.rb +2 -1
- data/lib/atome/presets/atome.rb +5 -14
- data/lib/atome/utilities/utilities.rb +0 -10
- data/lib/atome/version.rb +1 -1
- data/lib/atome.rb +2 -1
- data/lib/atome_relative.rb +2 -1
- data/lib/molecules/intuition/tools.rb +344 -0
- data/lib/renderers/html/hierarchy.rb +2 -2
- data/lib/renderers/html/html.rb +52 -48
- data/lib/renderers/html/identity.rb +4 -1
- data/lib/renderers/html/utility.rb +1 -1
- data/vendor/assets/application/examples/above_below_before_after.rb +22 -0
- data/vendor/assets/application/examples/animation.rb +29 -1
- data/vendor/assets/application/examples/audio.rb +54 -0
- data/vendor/assets/application/examples/hypertext.rb +24 -3
- data/vendor/assets/application/examples/test.rb +1 -56
- data/vendor/assets/application/examples/tools.rb +7 -384
- data/vendor/assets/src/index.html +13 -6
- data/vendor/assets/src/index_opal.html +15 -7
- data/vendor/assets/src/index_server.html +19 -0
- data/vendor/assets/src/index_server_wasm.html +13 -6
- data/vendor/assets/src/index_wasm.html +19 -12
- data/vendor/assets/src/js/third_parties/webaudio-pianoroll.min.js +66 -0
- data/vendor/assets/src/medias/images/utils/full_keyboard.svg +50 -0
- data/vendor/assets/src/medias/images/utils/keyboard.svg +29 -0
- data/vendor/assets/src/medias/images/utils/notes.svg +28 -0
- metadata +25 -18
- /data/lib/molecules/intuition/{utillities.rb → utilities.rb} +0 -0
data/lib/renderers/html/html.rb
CHANGED
@@ -4,8 +4,6 @@
|
|
4
4
|
|
5
5
|
class HTML
|
6
6
|
|
7
|
-
|
8
|
-
|
9
7
|
# def id
|
10
8
|
# :poil
|
11
9
|
# end
|
@@ -47,14 +45,14 @@ class HTML
|
|
47
45
|
def add_font_to_css(params)
|
48
46
|
font_path = params[:path]
|
49
47
|
font_name = params[:name]
|
50
|
-
str_to_eval =
|
51
|
-
var styleSheet = document.styleSheets[0];
|
52
|
-
styleSheet.insertRule(`
|
53
|
-
@font-face {
|
54
|
-
|
55
|
-
|
56
|
-
}`, styleSheet.cssRules.length);
|
57
|
-
STRDELIM
|
48
|
+
str_to_eval = <<~STRDELIM
|
49
|
+
var styleSheet = document.styleSheets[0];
|
50
|
+
styleSheet.insertRule(`
|
51
|
+
@font-face {
|
52
|
+
font-family: '#{font_name}';
|
53
|
+
src: url('../medias/fonts/#{font_path}/#{font_name}.ttf') format('truetype');
|
54
|
+
}`, styleSheet.cssRules.length);
|
55
|
+
STRDELIM
|
58
56
|
JS.eval(str_to_eval)
|
59
57
|
end
|
60
58
|
|
@@ -221,7 +219,6 @@ STRDELIM
|
|
221
219
|
particles_from_style[key.to_sym] = value if key && value
|
222
220
|
end
|
223
221
|
|
224
|
-
# alert "hyperedit"
|
225
222
|
|
226
223
|
particles_found = particles_found.merge(particles_from_style)
|
227
224
|
current_atome = grab(@id)
|
@@ -378,6 +375,18 @@ STRDELIM
|
|
378
375
|
self
|
379
376
|
end
|
380
377
|
|
378
|
+
def audio(id)
|
379
|
+
# we remove any element if the id already exist
|
380
|
+
check_double(id)
|
381
|
+
markup_found = @original_atome.markup || :audio
|
382
|
+
@element_type = markup_found.to_s
|
383
|
+
@element = JS.global[:document].createElement(@element_type)
|
384
|
+
JS.global[:document][:body].appendChild(@element)
|
385
|
+
add_class('atome')
|
386
|
+
self.id(id)
|
387
|
+
self
|
388
|
+
end
|
389
|
+
|
381
390
|
def www(id)
|
382
391
|
# we remove any element if the id already exist
|
383
392
|
check_double(id)
|
@@ -505,7 +514,6 @@ STRDELIM
|
|
505
514
|
end
|
506
515
|
end
|
507
516
|
|
508
|
-
|
509
517
|
def transform(property, value = nil)
|
510
518
|
transform_needed = "#{property}(#{value}deg)"
|
511
519
|
@element[:style][:transform] = transform_needed.to_s
|
@@ -578,8 +586,6 @@ STRDELIM
|
|
578
586
|
@element[:style][:"-webkit-backdrop-filter"] = filter_needed
|
579
587
|
end
|
580
588
|
|
581
|
-
|
582
|
-
|
583
589
|
def currentTime(time)
|
584
590
|
@element[:currentTime] = time
|
585
591
|
end
|
@@ -598,7 +604,6 @@ STRDELIM
|
|
598
604
|
|
599
605
|
def action(_particle, action_found, option = nil)
|
600
606
|
|
601
|
-
# alert option
|
602
607
|
if action_found == :stop
|
603
608
|
currentTime(option)
|
604
609
|
@element.pause
|
@@ -1146,13 +1151,11 @@ STRDELIM
|
|
1146
1151
|
end
|
1147
1152
|
|
1148
1153
|
def touch_tap(_option)
|
1149
|
-
# alert :touch_tap
|
1150
1154
|
@element[:style][:cursor] = 'pointer'
|
1151
1155
|
interact = JS.eval("return interact('##{@id}')")
|
1152
1156
|
touch_tap = @original_atome.instance_variable_get('@touch_code')[:tap]
|
1153
1157
|
# unless @touch_removed[:tap]
|
1154
1158
|
interact.on('tap') do |native_event|
|
1155
|
-
# alert 'touchy'
|
1156
1159
|
event = Native(native_event)
|
1157
1160
|
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1158
1161
|
# and it's lead to a problem of context and force the use of grab(:view) when using atome method such as shape ,
|
@@ -1300,37 +1303,30 @@ STRDELIM
|
|
1300
1303
|
end
|
1301
1304
|
end
|
1302
1305
|
|
1306
|
+
|
1303
1307
|
# animation below
|
1304
1308
|
def animate(animation_properties)
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
atomeJsToRuby("grab('#{@id}').
|
1314
|
-
}
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1309
|
+
prop= animation_properties[:particle]
|
1310
|
+
command = <<~JS
|
1311
|
+
var target_div = document.getElementById('#{@id}');
|
1312
|
+
window.currentAnimation = popmotion.animate({
|
1313
|
+
from: #{animation_properties[ :from]},
|
1314
|
+
to: #{animation_properties[:to]},
|
1315
|
+
duration: #{animation_properties[:duration]},
|
1316
|
+
onUpdate: function(v) {
|
1317
|
+
atomeJsToRuby("grab('#{@id}').animation_callback('#{prop}', "+v+")")
|
1318
|
+
atomeJsToRuby("grab('#{@id}').#{prop}("+v+")")
|
1319
|
+
},
|
1320
|
+
onComplete: function(v) {
|
1321
|
+
window.currentAnimation = null;
|
1322
|
+
atomeJsToRuby("grab('#{@id}').animation_callback('#{prop}_end')")
|
1323
|
+
}
|
1324
|
+
});
|
1320
1325
|
JS
|
1321
1326
|
JS.eval(command)
|
1322
1327
|
end
|
1323
1328
|
|
1324
|
-
def play_animation(properties)
|
1325
|
-
puts 'change for standard method : action'
|
1326
|
-
required_keys = [:from, :to, :duration]
|
1327
|
-
unless properties.is_a?(Hash) && (required_keys - properties.keys).empty?
|
1328
|
-
raise ArgumentError, 'Properties must be a hash with :from, :to, and :duration keys'
|
1329
|
-
end
|
1330
1329
|
|
1331
|
-
animate(properties)
|
1332
|
-
|
1333
|
-
end
|
1334
1330
|
|
1335
1331
|
def stop_animation
|
1336
1332
|
JS.eval('if (window.currentAnimation) window.currentAnimation.stop();')
|
@@ -1359,7 +1355,6 @@ STRDELIM
|
|
1359
1355
|
|
1360
1356
|
table_html.appendChild(thead)
|
1361
1357
|
tbody = JS.global[:document].createElement('tbody')
|
1362
|
-
# alert data
|
1363
1358
|
data.each_with_index do |row, row_index|
|
1364
1359
|
tr = JS.global[:document].createElement('tr')
|
1365
1360
|
|
@@ -1389,8 +1384,6 @@ STRDELIM
|
|
1389
1384
|
JS.global[:document].querySelector("##{@id}").appendChild(table_html)
|
1390
1385
|
end
|
1391
1386
|
|
1392
|
-
|
1393
|
-
|
1394
1387
|
# Helper function to handle Atome objects
|
1395
1388
|
def handle_atome(atome, td_element)
|
1396
1389
|
atome.fit(cell_height)
|
@@ -1402,7 +1395,6 @@ STRDELIM
|
|
1402
1395
|
atome.left(0)
|
1403
1396
|
end
|
1404
1397
|
|
1405
|
-
|
1406
1398
|
def refresh_table(_params)
|
1407
1399
|
# first we need to extact all atome from the table or they will be deleted by the table refres
|
1408
1400
|
data = @original_atome.data
|
@@ -1442,9 +1434,21 @@ STRDELIM
|
|
1442
1434
|
def set_td_style(td)
|
1443
1435
|
cell_height = @original_atome.component[:height]
|
1444
1436
|
cell_width = @original_atome.component[:width]
|
1445
|
-
|
1437
|
+
# shadow_found = @original_atome.component[:shadow]
|
1438
|
+
# if shadow_found
|
1439
|
+
# red = shadow_found[:red] * 255
|
1440
|
+
# green = shadow_found[:green] * 255
|
1441
|
+
# blue = shadow_found[:blue] * 255
|
1442
|
+
# alpha = shadow_found[:alpha]
|
1443
|
+
# left = shadow_found[:left]
|
1444
|
+
# top = shadow_found[:top]
|
1445
|
+
# blur = shadow_found[:blur] # new correct behavior all atome's value should now be get using :value,here to resolve conflict with blur and back blur
|
1446
|
+
# inset = :inset if shadow_found[:invert]
|
1447
|
+
# shadow_created = "#{left}px #{top}px #{blur}px rgba(#{red}, #{green}, #{blue}, #{alpha}) #{inset}"
|
1448
|
+
# end
|
1449
|
+
# td[:style][:border] = '1px solid black'
|
1446
1450
|
td[:style][:backgroundColor] = 'white'
|
1447
|
-
td[:style][:boxShadow] =
|
1451
|
+
# td[:style][:boxShadow] = shadow_created
|
1448
1452
|
td[:style][:width] = "#{cell_width}px"
|
1449
1453
|
td[:style]['min-width'] = "#{cell_width}px"
|
1450
1454
|
td[:style]['max-width'] = "#{cell_height}px"
|
@@ -1641,7 +1645,7 @@ STRDELIM
|
|
1641
1645
|
|
1642
1646
|
# atomisation!
|
1643
1647
|
def atomized(html_object)
|
1644
|
-
html_object = html_object[0] if html_object.instance_of? Array
|
1648
|
+
# html_object = html_object[0] if html_object.instance_of? Array
|
1645
1649
|
@element = html_object
|
1646
1650
|
end
|
1647
1651
|
|
@@ -17,6 +17,9 @@ end
|
|
17
17
|
new({ method: :type, type: :string, renderer: :html, specific: :video }) do |_value, _user_proc|
|
18
18
|
html.video(@id)
|
19
19
|
end
|
20
|
+
new({ method: :type, type: :string, renderer: :html, specific: :audio }) do |_value, _user_proc|
|
21
|
+
html.audio(@id)
|
22
|
+
end
|
20
23
|
|
21
24
|
new({ method: :type, type: :string, renderer: :html, specific: :www }) do |_value, _user_proc|
|
22
25
|
html.www(@id)
|
@@ -95,7 +98,7 @@ new({ method: :data, type: :string, specific: :table, renderer: :html }) do |val
|
|
95
98
|
end
|
96
99
|
|
97
100
|
new({ method: :type, type: :hash, specific: :atomized, renderer: :html }) do |value, _user_proc|
|
98
|
-
html.atomized(
|
101
|
+
html.atomized(alien)
|
99
102
|
end
|
100
103
|
|
101
104
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
b=box
|
4
|
+
margin = 12
|
5
|
+
b2=box({top: below(b, margin)})
|
6
|
+
b3=box({top: below(b2, margin)})
|
7
|
+
b4=box({top: below(b3, margin)})
|
8
|
+
box({top: below(b4, margin)})
|
9
|
+
i=0
|
10
|
+
while i< 10 do
|
11
|
+
b2=box({top: below(b, margin)})
|
12
|
+
i+=1
|
13
|
+
end
|
14
|
+
|
15
|
+
b = circle(left: 66)
|
16
|
+
margin = 12
|
17
|
+
i = 0
|
18
|
+
|
19
|
+
while i < 10 do
|
20
|
+
b = circle({top: below(b, margin), left: 66})
|
21
|
+
i += 1
|
22
|
+
end
|
@@ -87,5 +87,33 @@
|
|
87
87
|
|
88
88
|
b=box({id: :the_box})
|
89
89
|
|
90
|
-
b.animate({ to:
|
90
|
+
b.animate({ to: 333, particle: :width, duration: 3000}) do |val|
|
91
|
+
puts "width +#{val}"
|
92
|
+
end
|
93
|
+
|
94
|
+
b.animate({ to: 456, particle: :left, duration: 5000}) do |val|
|
95
|
+
puts "left +#{val}"
|
96
|
+
end
|
97
|
+
|
98
|
+
b.animate({ end: :left}) do |val|
|
99
|
+
puts "left ended"
|
100
|
+
end
|
101
|
+
|
102
|
+
b.animate({ to: 69, particle: :smooth, duration: 10000}) do |val|
|
103
|
+
puts "smooth +#{val}"
|
104
|
+
end
|
105
|
+
|
106
|
+
b.animate({ end: :smooth}) do |val|
|
107
|
+
puts " cool smooth end now!!!"
|
108
|
+
end
|
109
|
+
|
110
|
+
b.animate({ to: 90, particle: :rotate, duration: 10000}) do |val|
|
111
|
+
puts "rotate +#{val}"
|
112
|
+
end
|
113
|
+
|
114
|
+
b.animate({ to: 222, particle: :top, duration: 10000}) do |val|
|
115
|
+
puts "top +#{val}"
|
116
|
+
end
|
117
|
+
|
118
|
+
|
91
119
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# audio tag
|
4
|
+
a = audio({ path: 'medias/audios/clap.wav', id: :basic_audio })
|
5
|
+
b=box({id: :playButton})
|
6
|
+
b.text(:audio_tag)
|
7
|
+
a.left(333)
|
8
|
+
b.touch(:down) do
|
9
|
+
a.play(true)
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
### Web Audio
|
15
|
+
audio({ path: 'medias/audios/clap.wav', id: :audioElement })
|
16
|
+
@audio_context = JS.eval('return new AudioContext()')
|
17
|
+
@audio_element = JS.global[:document].getElementById('audioElement')
|
18
|
+
@track = @audio_context.createMediaElementSource(@audio_element)
|
19
|
+
|
20
|
+
@gain_node = @audio_context.createGain()
|
21
|
+
@gain_node[:gain][:value] = 0.5
|
22
|
+
|
23
|
+
@track.connect(@gain_node)
|
24
|
+
@gain_node.connect(@audio_context[:destination])
|
25
|
+
|
26
|
+
def play_audio
|
27
|
+
@audio_context[:resume].to_s if @audio_context[:state].to_s == 'suspended'
|
28
|
+
@audio_element.play
|
29
|
+
end
|
30
|
+
b2=box({left: 166})
|
31
|
+
b2.text(:web_audio)
|
32
|
+
b2.touch(:down) do
|
33
|
+
play_audio
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
# ######### wadjs
|
38
|
+
bb=box({left: 333})
|
39
|
+
bb.text(:wadjs)
|
40
|
+
init_code = "window.snare = new Wad({source : 'medias/audios/clap.wav'});"
|
41
|
+
JS.eval(init_code)
|
42
|
+
|
43
|
+
play_code = <<~STRDEL
|
44
|
+
window.snare.play();
|
45
|
+
setTimeout(function() {
|
46
|
+
window.snare.stop();
|
47
|
+
}, 300);
|
48
|
+
STRDEL
|
49
|
+
|
50
|
+
|
51
|
+
bb.touch(:down) do
|
52
|
+
JS.eval(play_code)
|
53
|
+
end
|
54
|
+
|
@@ -58,7 +58,7 @@ html_desc = <<STR
|
|
58
58
|
</nav>
|
59
59
|
</header>
|
60
60
|
|
61
|
-
<section id='
|
61
|
+
<section id='div_id' class="section my_class" style='left: 333px;color: yellow'>
|
62
62
|
<h2>PRODUCTIONS AUDIOVISUELLES</h2>
|
63
63
|
<!-- Contenu de la section -->
|
64
64
|
</section>
|
@@ -105,8 +105,29 @@ b.hypertext(html_desc)
|
|
105
105
|
# get tag content convert to data
|
106
106
|
# get style and class convert to particle
|
107
107
|
# end
|
108
|
-
b.hyperedit(:
|
109
|
-
puts
|
108
|
+
b.hyperedit(:div_id) do |tag_desc|
|
109
|
+
puts tag_desc.class
|
110
|
+
end
|
111
|
+
|
112
|
+
wait 2 do
|
113
|
+
div_result = HTML.locate(id: 'div_id') # find by ID
|
114
|
+
|
115
|
+
atomized_el= atomizer({ target: div_result, id: :my_second_html_obj })
|
116
|
+
atomized_el.rotate(55)
|
117
|
+
atomized_el.color(:purple)
|
118
|
+
atomized_el.position(:absolute)
|
119
|
+
atomized_el.left(255)
|
120
|
+
atomized_el.top(255)
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
wait 3 do
|
125
|
+
# or handle the objet in pure ruby js style
|
126
|
+
div_result = HTML.locate(id: 'div_id') # find by ID
|
127
|
+
div_result[:style][:left]= "66px"
|
128
|
+
puts "the div is : #{div_result[:style][:left]}"
|
129
|
+
|
130
|
+
|
110
131
|
end
|
111
132
|
|
112
133
|
# TODO : create an html to atome converter
|
@@ -1,57 +1,2 @@
|
|
1
|
-
|
2
|
-
left: 333, top: 0, width: 300, smooth: 15, height: 900, overflow: :scroll, option: { header: false },
|
3
|
-
component: {
|
4
|
-
border: { thickness: 5, color: :blue, pattern: :dotted },
|
5
|
-
overflow: :auto,
|
6
|
-
color: "white",
|
7
|
-
shadow: {
|
8
|
-
id: :s4,
|
9
|
-
left: 20, top: 0, blur: 9,
|
10
|
-
option: :natural,
|
11
|
-
red: 0, green: 1, blue: 0, alpha: 1
|
12
|
-
},
|
13
|
-
# height: 80,
|
14
|
-
# width: 12,
|
15
|
-
component: { size: 12, color: :black }
|
16
|
-
},
|
17
|
-
data: [
|
18
|
-
{ remove_me: :nonono },
|
19
|
-
{ dfgdf: 1, name: 'Alice', age: 30, no: 'oko', t: 123, r: 654, f: 123, g: 654, w: 123, x: 654, c: 123, v: 654 },
|
20
|
-
]
|
21
|
-
})
|
1
|
+
# frozen_string_literal: true
|
22
2
|
|
23
|
-
|
24
|
-
|
25
|
-
m.data( [
|
26
|
-
{header_title: nil },
|
27
|
-
{ dfgdf:nil, name: nil, age: nil, no: nil, t: nil, r: nil, f: nil, g: nil, w: nil, x: nil, c: nil, v: nil },
|
28
|
-
{ id: nil, name: nil, age: nil },
|
29
|
-
{ dfg: nil, name: nil, age: nil, no: nil },
|
30
|
-
{ dfgd: nil, name: nil, age: nil, no: nil },
|
31
|
-
{header_title: nil },
|
32
|
-
{ dfgdf:nil, name: nil, age: nil, no: nil, t: nil, r: nil, f: nil, g: nil, w: nil, x: nil, c: nil, v: nil },
|
33
|
-
{ id: nil, name: nil, age: nil },
|
34
|
-
{ dfg: nil, name: nil, age: nil, no: nil },
|
35
|
-
{ dfgd: nil, name: nil, age: nil, no: nil },
|
36
|
-
{header_title: nil },
|
37
|
-
{ dfgdf:nil, name: nil, age: nil, no: nil, t: nil, r: nil, f: nil, g: nil, w: nil, x: nil, c: nil, v: nil },
|
38
|
-
{ id: nil, name: nil, age: nil },
|
39
|
-
{ dfg: nil, name: nil, age: nil, no: nil },
|
40
|
-
{ dfgd: nil, name: nil, age: nil, no: nil },
|
41
|
-
{header_title: nil },
|
42
|
-
{ dfgdf:nil, name: nil, age: nil, no: nil, t: nil, r: nil, f: nil, g: nil, w: nil, x: nil, c: nil, v: nil },
|
43
|
-
{ id: nil, name: nil, age: nil },
|
44
|
-
{ dfg: nil, name: nil, age: nil, no: nil },
|
45
|
-
{ dfgd: nil, name: nil, age: nil, no: nil },
|
46
|
-
{header_title: nil },
|
47
|
-
{ dfgdf:nil, name: nil, age: nil, no: nil, t: nil, r: nil, f: nil, g: nil, w: nil, x: nil, c: nil, v: nil },
|
48
|
-
{ id: nil, name: nil, age: nil },
|
49
|
-
{ dfg: nil, name: nil, age: nil, no: nil },
|
50
|
-
{ dfgd: nil, name: nil, age: nil, no: nil },
|
51
|
-
{header_title: nil },
|
52
|
-
{ dfgdf:nil, name: nil, age: nil, no: nil, t: nil, r: nil, f: nil, g: nil, w: nil, x: nil, c: nil, v: nil },
|
53
|
-
{ id: nil, name: nil, age: nil },
|
54
|
-
{ dfg: nil, name: nil, age: nil, no: nil },
|
55
|
-
{ dfgd: nil, name: nil, age: nil, no: nil },
|
56
|
-
|
57
|
-
])
|