atome 0.5.6.8.7 → 0.5.7.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/documentation/basic.md +7 -8
- data/documentation/deep learning/basic_infos.txt +6 -6
- data/documentation/installation/atome_server.md +66 -1
- data/documentation/installation/buiding_atome.md +307 -0
- data/lib/atome/atome.rb +2 -3
- data/lib/atome/extensions/atome.rb +38 -12
- data/lib/atome/genesis/atomes.rb +1 -1
- data/lib/atome/genesis/genesis.rb +11 -11
- data/lib/atome/genesis/particles/event.rb +58 -50
- data/lib/atome/genesis/particles/identity.rb +3 -0
- data/lib/atome/genesis/particles/property.rb +2 -1
- data/lib/atome/genesis/particles/utility.rb +19 -12
- data/lib/atome/genesis/presets.rb +10 -0
- data/lib/atome/genesis/sparkle.rb +11 -9
- data/lib/atome/kernel/universe.rb +22 -11
- data/lib/atome/presets/atome.rb +20 -17
- data/lib/atome/utilities/essentials.rb +5 -5
- data/lib/atome/utilities/utilities.rb +173 -16
- data/lib/atome/version.rb +1 -1
- data/lib/atome.rb +1 -0
- data/lib/atome_relative.rb +1 -0
- data/lib/molecules/init.rb +22 -42
- data/lib/molecules/intuition/_deprecated_inputs.rb +111 -0
- data/lib/molecules/intuition/utillities.rb +105 -11
- data/lib/renderers/html/event.rb +20 -4
- data/lib/renderers/html/html.rb +161 -161
- data/lib/renderers/html/identity.rb +10 -2
- data/lib/renderers/html/material.rb +4 -0
- data/lib/renderers/html/utility.rb +64 -8
- data/vendor/assets/application/examples/b64_to_image.rb +9 -0
- data/vendor/assets/application/examples/drag.rb +9 -2
- data/vendor/assets/application/examples/fonts.rb +15 -0
- data/vendor/assets/application/examples/matrix.rb +77 -114
- data/vendor/assets/application/examples/recorder.rb +74 -0
- data/vendor/assets/application/examples/site.rb +41 -0
- data/vendor/assets/application/examples/sub_atome_manipulation.rb +0 -2
- data/vendor/assets/application/examples/svg_img_to_vector.rb +6 -0
- data/vendor/assets/application/examples/svg_vectorizer.rb +21 -0
- data/vendor/assets/application/examples/table.rb +1 -1
- data/vendor/assets/application/examples/test.rb +572 -0
- data/vendor/assets/application/examples/tools.rb +650 -304
- data/vendor/assets/application/examples/vector.rb +16 -3
- data/vendor/assets/server/atome_server.rb +3 -2
- data/vendor/assets/server/atome_server_wasm.rb +2 -2
- data/vendor/assets/server/eDen.rb +135 -14
- data/vendor/assets/src/css/style.css +4 -0
- data/vendor/assets/src/index.html +1 -1
- data/vendor/assets/src/index_opal.html +1 -1
- data/vendor/assets/src/index_server.html +1 -1
- data/vendor/assets/src/index_server_wasm.html +1 -1
- data/vendor/assets/src/index_wasm.html +1 -1
- data/vendor/assets/src/js/atome/atome.js +250 -49
- data/vendor/assets/src/js/atome/atome_helpers/communication.js +4 -4
- data/vendor/assets/src/js/atome/specific/opal.js +19 -3
- data/vendor/assets/src/js/atome/specific/wasm.js +18 -3
- data/vendor/assets/src/js/molecules/web.js +1 -1
- data/vendor/assets/src/medias/images/icons/Lowpass.svg +8 -0
- data/vendor/assets/src/medias/images/icons/activate.svg +3 -0
- data/vendor/assets/src/medias/images/icons/audio.svg +7 -0
- data/vendor/assets/src/medias/images/icons/band_pass.svg +8 -0
- data/vendor/assets/src/medias/images/icons/clear.svg +5 -0
- data/vendor/assets/src/medias/images/icons/color.svg +5 -0
- data/vendor/assets/src/medias/images/icons/copy.svg +8 -0
- data/vendor/assets/src/medias/images/icons/create.svg +3 -0
- data/vendor/assets/src/medias/images/icons/delete.svg +8 -0
- data/vendor/assets/src/medias/images/icons/edit-.svg +4 -0
- data/vendor/assets/src/medias/images/icons/edit.svg +4 -0
- data/vendor/assets/src/medias/images/icons/edition.svg +4 -0
- data/vendor/assets/src/medias/images/icons/equalizer-.svg +5 -0
- data/vendor/assets/src/medias/images/icons/equalizer.svg +5 -0
- data/vendor/assets/src/medias/images/icons/filter.svg +4 -0
- data/vendor/assets/src/medias/images/icons/folder.svg +4 -0
- data/vendor/assets/src/medias/images/icons/group.svg +6 -0
- data/vendor/assets/src/medias/images/icons/hamburger.svg +8 -0
- data/vendor/assets/src/medias/images/icons/high_pass.svg +5 -0
- data/vendor/assets/src/medias/images/icons/link.svg +4 -0
- data/vendor/assets/src/medias/images/icons/load.svg +4 -0
- data/vendor/assets/src/medias/images/icons/low_pass.svg +5 -0
- data/vendor/assets/src/medias/images/icons/microphone.svg +7 -0
- data/vendor/assets/src/medias/images/icons/midi_in.svg +4 -0
- data/vendor/assets/src/medias/images/icons/midi_out.svg +4 -0
- data/vendor/assets/src/medias/images/icons/modules.svg +11 -0
- data/vendor/assets/src/medias/images/icons/paste.svg +4 -0
- data/vendor/assets/src/medias/images/icons/pause.svg +5 -0
- data/vendor/assets/src/medias/images/icons/play.svg +7 -0
- data/vendor/assets/src/medias/images/icons/record.svg +4 -0
- data/vendor/assets/src/medias/images/icons/save.svg +5 -0
- data/vendor/assets/src/medias/images/icons/select--.svg +4 -0
- data/vendor/assets/src/medias/images/icons/select-.svg +5 -0
- data/vendor/assets/src/medias/images/icons/select-all.svg +4 -0
- data/vendor/assets/src/medias/images/icons/select.svg +4 -0
- data/vendor/assets/src/medias/images/icons/settings.svg +5 -0
- data/vendor/assets/src/medias/images/icons/settings0.svg +2 -0
- data/vendor/assets/src/medias/images/icons/settings1.svg +17 -0
- data/vendor/assets/src/medias/images/icons/settings2.svg +25 -0
- data/vendor/assets/src/medias/images/icons/settings_old.svg +6 -0
- data/vendor/assets/src/medias/images/icons/shape.svg +7 -0
- data/vendor/assets/src/medias/images/icons/speaker.svg +6 -0
- data/vendor/assets/src/medias/images/icons/stop.svg +4 -0
- data/vendor/assets/src/medias/images/icons/tool.svg +7 -0
- data/vendor/assets/src/medias/images/icons/tools.svg +9 -0
- data/vendor/assets/src/medias/images/icons/undo2.svg +4 -0
- data/vendor/assets/src/medias/images/icons/validate.svg +9 -0
- data/vendor/assets/src/medias/images/icons/vie.svg +3 -0
- data/vendor/assets/src/medias/images/icons/wave-saw.svg +3 -0
- data/vendor/assets/src/medias/images/icons/wave-sine.svg +3 -0
- data/vendor/assets/src/medias/images/icons/wave-square-.svg +4 -0
- data/vendor/assets/src/medias/images/icons/wave-square.svg +3 -0
- data/vendor/assets/src/medias/images/icons/wave-triangle.svg +3 -0
- data/vendor/assets/src/medias/images/icons/waveform-.svg +4 -0
- data/vendor/assets/src/medias/images/icons/waveform.svg +7 -0
- metadata +69 -6
- data/lib/molecules/intuition/inputs.rb +0 -111
- /data/lib/molecules/{examples → _deprecated_examples}/site.rb +0 -0
- /data/lib/molecules/intuition/{toolbox.rb → _deprecated_toolbox.rb} +0 -0
data/lib/renderers/html/html.rb
CHANGED
@@ -37,6 +37,20 @@ class HTML
|
|
37
37
|
current_div[:innerHTML] = params
|
38
38
|
end
|
39
39
|
|
40
|
+
def add_font_to_css(params)
|
41
|
+
font_path = params[:path]
|
42
|
+
font_name = params[:name]
|
43
|
+
str_to_eval = <<STRDELIM
|
44
|
+
var styleSheet = document.styleSheets[0];
|
45
|
+
styleSheet.insertRule(`
|
46
|
+
@font-face {
|
47
|
+
font-family: '#{font_name}';
|
48
|
+
src: url('../medias/fonts/#{font_path}/#{font_name}.ttf') format('truetype');
|
49
|
+
}`, styleSheet.cssRules.length);
|
50
|
+
STRDELIM
|
51
|
+
JS.eval(str_to_eval)
|
52
|
+
end
|
53
|
+
|
40
54
|
def add_css_to_atomic_style(css)
|
41
55
|
style_element = JS.global[:document].getElementById('atomic_style')
|
42
56
|
text_node = JS.global[:document].createTextNode(css)
|
@@ -302,10 +316,7 @@ class HTML
|
|
302
316
|
# editable_pres_array = Array.new(editable_pres[:length].to_i) { |i| editable_pres.call(:item, i) }
|
303
317
|
# editable_pres_array.each do |pre|
|
304
318
|
# pre.addEventListener('click') do
|
305
|
-
# # Focus sur l'élément pour activer le curseur
|
306
319
|
# pre.focus()
|
307
|
-
# alert :ok
|
308
|
-
# # Optionnel : Ajoutez du style pour rendre le curseur plus visible
|
309
320
|
# pre[:style][:caretColor] = 'blue' # Changez la couleur du curseur en bleu
|
310
321
|
# end
|
311
322
|
# end
|
@@ -400,15 +411,20 @@ class HTML
|
|
400
411
|
self
|
401
412
|
end
|
402
413
|
|
403
|
-
def svg_data(
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
414
|
+
def svg_data(all_datas)
|
415
|
+
# we remove previous datas
|
416
|
+
# @element.innerHTML = ''
|
417
|
+
all_datas.each do |full_data|
|
418
|
+
full_data.each do |type_passed, datas|
|
419
|
+
|
420
|
+
svg_ns = 'http://www.w3.org/2000/svg'
|
421
|
+
new_path = JS.global[:document].createElementNS(svg_ns.to_s, type_passed.to_s)
|
422
|
+
JS.global[:document][:body].appendChild(new_path)
|
423
|
+
datas.each do |property, value|
|
424
|
+
new_path.setAttribute(property.to_s, value.to_s)
|
425
|
+
end
|
426
|
+
@element.appendChild(new_path)
|
410
427
|
end
|
411
|
-
@element.appendChild(new_path)
|
412
428
|
end
|
413
429
|
end
|
414
430
|
|
@@ -704,11 +720,18 @@ class HTML
|
|
704
720
|
end
|
705
721
|
|
706
722
|
def drag_remove(option)
|
723
|
+
|
724
|
+
interact = JS.eval("return interact('##{@id}')")
|
725
|
+
|
707
726
|
case option
|
708
727
|
when :start
|
709
728
|
@drag_start = ''
|
710
729
|
when :end, :stop
|
711
730
|
@drag_end = ''
|
731
|
+
when :move
|
732
|
+
interact.draggable(false)
|
733
|
+
interact.unset
|
734
|
+
@drag_move = nil
|
712
735
|
when :locked
|
713
736
|
@drag_locked = ''
|
714
737
|
when :restrict
|
@@ -719,6 +742,9 @@ class HTML
|
|
719
742
|
@drag_end = ''
|
720
743
|
@drag_locked = ''
|
721
744
|
@drag_restrict = ''
|
745
|
+
@drag_move = nil
|
746
|
+
interact.draggable(false)
|
747
|
+
interact.unset
|
722
748
|
end
|
723
749
|
|
724
750
|
end
|
@@ -748,7 +774,10 @@ class HTML
|
|
748
774
|
end
|
749
775
|
|
750
776
|
def drag_move(_option)
|
777
|
+
|
751
778
|
interact = JS.eval("return interact('##{@id}')")
|
779
|
+
# interact.draggable(false)
|
780
|
+
|
752
781
|
interact.draggable({
|
753
782
|
drag: true,
|
754
783
|
inertia: { resistance: 12,
|
@@ -764,7 +793,7 @@ class HTML
|
|
764
793
|
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
765
794
|
# group etc..
|
766
795
|
@drag_move.call(event) if @drag_move.is_a?(Proc)
|
767
|
-
|
796
|
+
Universe.allow_tool_operations = false
|
768
797
|
dx = event[:dx]
|
769
798
|
dy = event[:dy]
|
770
799
|
x = (@original_atome.left || 0) + dx.to_f
|
@@ -946,8 +975,8 @@ class HTML
|
|
946
975
|
@drop_leave = ''
|
947
976
|
else
|
948
977
|
# to remove all interact event ( touch, drag, scale, ... uncomment below)
|
949
|
-
|
950
|
-
|
978
|
+
interact = JS.eval("return interact('##{@id}')")
|
979
|
+
interact.unset
|
951
980
|
@drop_activate = ''
|
952
981
|
@drop_deactivate = ''
|
953
982
|
@drop_dropped = ''
|
@@ -975,25 +1004,26 @@ class HTML
|
|
975
1004
|
modifiers: [],
|
976
1005
|
listeners: {
|
977
1006
|
move: lambda do |native_event|
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
1007
|
+
Universe.allow_tool_operations = false
|
1008
|
+
# if @resize.is_a?(Proc)
|
1009
|
+
event = Native(native_event)
|
1010
|
+
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1011
|
+
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1012
|
+
# group etc..
|
1013
|
+
@resize.call(event) if @resize.is_a?(Proc)
|
1014
|
+
x = (@element[:offsetLeft].to_i || 0)
|
1015
|
+
y = (@element[:offsetTop].to_i || 0)
|
1016
|
+
width = event[:rect][:width]
|
1017
|
+
height = event[:rect][:height]
|
1018
|
+
# Translate when resizing from any corner
|
1019
|
+
x += event[:deltaRect][:left].to_f
|
1020
|
+
y += event[:deltaRect][:top].to_f
|
1021
|
+
@original_atome.width width.to_i if width.to_i.between?(min_width, max_width)
|
1022
|
+
@original_atome.height height.to_i if height.to_i.between?(min_height, max_height)
|
1023
|
+
@original_atome.left(x)
|
1024
|
+
@original_atome.top(y)
|
996
1025
|
end
|
1026
|
+
# end
|
997
1027
|
},
|
998
1028
|
|
999
1029
|
})
|
@@ -1082,82 +1112,103 @@ class HTML
|
|
1082
1112
|
end
|
1083
1113
|
end
|
1084
1114
|
|
1085
|
-
def
|
1115
|
+
def event_validation(action_proc)
|
1116
|
+
action_proc.is_a?(Proc) && (!Universe.edit_mode || @original_atome.tag[:system])
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
def touch_down(_option)
|
1120
|
+
@element[:style][:cursor] = 'pointer'
|
1121
|
+
|
1122
|
+
@touch_down = @original_atome.instance_variable_get('@touch_code')[:down]
|
1086
1123
|
interact = JS.eval("return interact('##{@id}')")
|
1087
|
-
|
1088
|
-
|
1089
|
-
interact.on('tap') do |native_event|
|
1124
|
+
unless @touch_removed[:down]
|
1125
|
+
interact.on('down') do |native_event|
|
1090
1126
|
event = Native(native_event)
|
1091
1127
|
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1092
1128
|
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1093
1129
|
# group etc..
|
1094
|
-
|
1130
|
+
# unless Universe.edit_mode == true
|
1131
|
+
# @touch_down.call(event) if @touch_down.is_a?(Proc) && (!Universe.edit_mode || @original_atome.tag[:system])
|
1132
|
+
@touch_down.call(event) if event_validation(@touch_down)
|
1133
|
+
# end
|
1095
1134
|
end
|
1096
1135
|
end
|
1097
|
-
|
1098
1136
|
end
|
1099
1137
|
|
1100
|
-
def
|
1138
|
+
def touch_tap(_option)
|
1139
|
+
# alert :touch_tap
|
1140
|
+
@element[:style][:cursor] = 'pointer'
|
1101
1141
|
interact = JS.eval("return interact('##{@id}')")
|
1102
|
-
|
1103
|
-
unless @touch_removed[:
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1142
|
+
touch_tap = @original_atome.instance_variable_get('@touch_code')[:tap]
|
1143
|
+
# unless @touch_removed[:tap]
|
1144
|
+
interact.on('tap') do |native_event|
|
1145
|
+
# alert 'touchy'
|
1146
|
+
event = Native(native_event)
|
1147
|
+
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1148
|
+
# and it's lead to a problem of context and force the use of grab(:view) when using atome method such as shape ,
|
1149
|
+
# group etc..
|
1150
|
+
# @touch_tap.call(event) if @touch_tap.is_a?(Proc) && !Universe.edit_mode || !@original_atome.tag[:system]
|
1151
|
+
touch_tap.call(event) if event_validation(touch_tap)
|
1111
1152
|
end
|
1153
|
+
# end
|
1112
1154
|
|
1113
1155
|
end
|
1114
1156
|
|
1115
|
-
def
|
1116
|
-
@
|
1157
|
+
def touch_up(_option)
|
1158
|
+
@element[:style][:cursor] = 'pointer'
|
1117
1159
|
interact = JS.eval("return interact('##{@id}')")
|
1118
|
-
|
1119
|
-
|
1160
|
+
@touch_up = @original_atome.instance_variable_get('@touch_code')[:up]
|
1161
|
+
unless @touch_removed[:up]
|
1162
|
+
interact.on('up') do |native_event|
|
1120
1163
|
event = Native(native_event)
|
1121
1164
|
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1122
1165
|
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1123
1166
|
# group etc..
|
1124
|
-
@
|
1167
|
+
# @touch_up.call(event) if @touch_up.is_a?(Proc) && (!Universe.edit_mode || @original_atome.tag[:system])
|
1168
|
+
@touch_up.call(event) if event_validation(@touch_up)
|
1125
1169
|
end
|
1126
|
-
end
|
1127
1170
|
|
1171
|
+
end
|
1128
1172
|
end
|
1129
1173
|
|
1130
|
-
def
|
1131
|
-
@
|
1174
|
+
def touch_double(_option)
|
1175
|
+
@element[:style][:cursor] = 'pointer'
|
1132
1176
|
interact = JS.eval("return interact('##{@id}')")
|
1133
|
-
|
1134
|
-
|
1177
|
+
@touch_double = @original_atome.instance_variable_get('@touch_code')[:double]
|
1178
|
+
unless @touch_removed[:double]
|
1179
|
+
interact.on('doubletap') do |native_event|
|
1135
1180
|
event = Native(native_event)
|
1136
1181
|
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1137
1182
|
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1138
1183
|
# group etc..
|
1139
|
-
@
|
1140
|
-
|
1184
|
+
# @touch_double.call(event) if @touch_double.is_a?(Proc) && (!Universe.edit_mode || @original_atome.tag[:system])
|
1185
|
+
@touch_double.call(event) if event_validation(@touch_double)
|
1141
1186
|
|
1187
|
+
end
|
1142
1188
|
end
|
1189
|
+
|
1143
1190
|
end
|
1144
1191
|
|
1145
|
-
def
|
1192
|
+
def touch_long(_option)
|
1193
|
+
@element[:style][:cursor] = 'pointer'
|
1194
|
+
@touch_long = @original_atome.instance_variable_get('@touch_code')[:long]
|
1146
1195
|
interact = JS.eval("return interact('##{@id}')")
|
1147
|
-
|
1148
|
-
|
1149
|
-
interact.on('up') do |native_event|
|
1196
|
+
unless @touch_removed[:long]
|
1197
|
+
interact.on('hold') do |native_event|
|
1150
1198
|
event = Native(native_event)
|
1151
1199
|
# we use .call instead of instance_eval because instance_eval bring the current object as context
|
1152
1200
|
# and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
|
1153
1201
|
# group etc..
|
1154
|
-
@
|
1155
|
-
|
1202
|
+
@touch_long.call(event) if event_validation(@touch_long)
|
1203
|
+
# @touch_long.call(event) if @touch_long.is_a?(Proc) && (!Universe.edit_mode || @original_atome.tag[:system])
|
1204
|
+
# @touch_double.call(event) if event_validation(@touch_double)
|
1156
1205
|
|
1206
|
+
end
|
1157
1207
|
end
|
1158
1208
|
end
|
1159
1209
|
|
1160
1210
|
def touch_remove(option)
|
1211
|
+
@element[:style][:cursor] = 'default'
|
1161
1212
|
case option
|
1162
1213
|
when :double
|
1163
1214
|
@touch_double = ''
|
@@ -1175,16 +1226,20 @@ class HTML
|
|
1175
1226
|
@touch_removed[:up] = true
|
1176
1227
|
@touch_up = ''
|
1177
1228
|
else
|
1178
|
-
|
1179
|
-
|
1180
|
-
@
|
1181
|
-
@
|
1182
|
-
@touch_removed[:
|
1183
|
-
@
|
1184
|
-
@
|
1185
|
-
@
|
1186
|
-
@
|
1187
|
-
@
|
1229
|
+
interact = JS.eval("return interact('##{@id}')")
|
1230
|
+
interact.unset
|
1231
|
+
# @original_atome.instance_variable_set('@touch_code')
|
1232
|
+
@original_atome.instance_variable_set('@touch_code', nil)
|
1233
|
+
# @touch_removed[:double] = true
|
1234
|
+
# @touch_removed[:down] = true
|
1235
|
+
# @touch_removed[:long] = true
|
1236
|
+
# @touch_removed[:tap] = true
|
1237
|
+
# @touch_removed[:up] = true
|
1238
|
+
# @touch_double = ''
|
1239
|
+
# @touch_down = ''
|
1240
|
+
# @touch_long = ''
|
1241
|
+
# @touch_tap = ''
|
1242
|
+
# @touch_up = ''
|
1188
1243
|
# to remove all interact event ( touch, drag, scale, ... uncomment below)
|
1189
1244
|
# interact = JS.eval("return interact('##{@id}')")
|
1190
1245
|
# interact.unset
|
@@ -1244,12 +1299,12 @@ class HTML
|
|
1244
1299
|
to: #{animation_properties[:to]},
|
1245
1300
|
duration: #{animation_properties[:duration]},
|
1246
1301
|
onUpdate: function(v) {
|
1247
|
-
|
1248
|
-
|
1302
|
+
atomeJsToRuby("puts x= "+v)
|
1303
|
+
atomeJsToRuby("grab('#{@id}').left("+v+")")
|
1249
1304
|
},
|
1250
1305
|
onComplete: function() {
|
1251
1306
|
window.currentAnimation = null;
|
1252
|
-
|
1307
|
+
atomeJsToRuby("puts :complete")
|
1253
1308
|
}
|
1254
1309
|
});
|
1255
1310
|
JS
|
@@ -1549,63 +1604,14 @@ class HTML
|
|
1549
1604
|
style("filter", 'none')
|
1550
1605
|
@original_atome.apply(@original_atome.apply)
|
1551
1606
|
end
|
1552
|
-
|
1553
|
-
# reset_background
|
1554
|
-
# style(:background, '')
|
1555
|
-
# style(:background, 'black')
|
1556
|
-
# @original_atome.color(:red)
|
1557
|
-
# @original_atome.apply(@original_atome.color[0])
|
1607
|
+
|
1558
1608
|
end
|
1559
1609
|
|
1560
1610
|
def table_remove(params)
|
1561
1611
|
if params[:row]
|
1562
|
-
# row_index = params[:row]
|
1563
|
-
# table_element = JS.global[:document].querySelector("##{@id} table")
|
1564
|
-
#
|
1565
|
-
# if table_element.nil?
|
1566
|
-
# puts 'Table not found'
|
1567
|
-
# return
|
1568
|
-
# end
|
1569
|
-
#
|
1570
|
-
# rows = table_element.querySelectorAll('tbody tr').to_a
|
1571
|
-
#
|
1572
|
-
# if row_index >= rows.length
|
1573
|
-
# puts "row not found : #{row_index}"
|
1574
|
-
# return
|
1575
|
-
# end
|
1576
|
-
# row_to_remove = rows[row_index]
|
1577
|
-
#
|
1578
|
-
# row_to_remove[:parentNode].removeChild(row_to_remove)
|
1579
|
-
#
|
1580
|
-
# rows.each_with_index do |row, i|
|
1581
|
-
# next if i <= row_index
|
1582
|
-
# end
|
1583
1612
|
elsif params[:column]
|
1584
|
-
|
1585
|
-
|
1586
|
-
#
|
1587
|
-
# if table_element.nil?
|
1588
|
-
# puts 'Table not found'
|
1589
|
-
# return
|
1590
|
-
# end
|
1591
|
-
#
|
1592
|
-
# rows = table_element.querySelectorAll('tbody tr').to_a
|
1593
|
-
# rows.each do |row|
|
1594
|
-
# cells = row.querySelectorAll('td').to_a
|
1595
|
-
# if column_index < cells.length
|
1596
|
-
# cell_to_remove = cells[column_index]
|
1597
|
-
# cell_to_remove[:parentNode].removeChild(cell_to_remove)
|
1598
|
-
# end
|
1599
|
-
# end
|
1600
|
-
|
1601
|
-
end
|
1602
|
-
end
|
1603
|
-
|
1604
|
-
# def reset_background
|
1605
|
-
# style(:background, 'black')
|
1606
|
-
# style('box-shadow', 'none')
|
1607
|
-
# style('text-shadow', 'none')
|
1608
|
-
# end
|
1613
|
+
end
|
1614
|
+
end
|
1609
1615
|
|
1610
1616
|
# atomisation!
|
1611
1617
|
def atomized(html_object)
|
@@ -1613,35 +1619,6 @@ class HTML
|
|
1613
1619
|
@element = html_object
|
1614
1620
|
end
|
1615
1621
|
|
1616
|
-
# def center(options, attach)
|
1617
|
-
# parent = grab(attach)
|
1618
|
-
#
|
1619
|
-
# # Centre sur l'axe X
|
1620
|
-
# if options[:x]
|
1621
|
-
# x_position = calculate_position(options[:x], parent.to_px(:width), @original_atome.to_px(:width))
|
1622
|
-
# @original_atome.left(x_position)
|
1623
|
-
# end
|
1624
|
-
#
|
1625
|
-
# # Centre sur l'axe Y
|
1626
|
-
# if options[:y]
|
1627
|
-
# y_position = calculate_position(options[:y], parent.to_px(:height), @original_atome.to_px(:height))
|
1628
|
-
# @original_atome.top(y_position)
|
1629
|
-
# end
|
1630
|
-
# end
|
1631
|
-
#
|
1632
|
-
# # Méthode auxiliaire pour calculer la position
|
1633
|
-
# def calculate_position(option, parent_dimension, self_dimension)
|
1634
|
-
# if option.is_a?(String) && option.end_with?('%')
|
1635
|
-
# percent = option.chop.to_f / 100.0
|
1636
|
-
# (parent_dimension - self_dimension) * percent
|
1637
|
-
# elsif option == 0
|
1638
|
-
# # Cas spécial pour centrer l'objet
|
1639
|
-
# (parent_dimension - self_dimension) / 2.0
|
1640
|
-
# else
|
1641
|
-
# option
|
1642
|
-
# end
|
1643
|
-
# end
|
1644
|
-
|
1645
1622
|
def center(options, attach)
|
1646
1623
|
@center_options = options
|
1647
1624
|
|
@@ -1657,10 +1634,33 @@ class HTML
|
|
1657
1634
|
end
|
1658
1635
|
end
|
1659
1636
|
|
1637
|
+
def record_audio(params)
|
1638
|
+
duration = params[:duration] * 1000
|
1639
|
+
name = params[:name]
|
1640
|
+
JS.eval("recordAudio(#{duration},'#{@id}', '#{name}')")
|
1641
|
+
end
|
1642
|
+
|
1643
|
+
def record_video(params)
|
1644
|
+
duration = params[:duration] * 1000
|
1645
|
+
name = params[:name]
|
1646
|
+
JS.eval("recordVideo(#{duration},'#{@id}', '#{name}')")
|
1647
|
+
end
|
1648
|
+
|
1649
|
+
def stop_video_preview(id)
|
1650
|
+
JS.eval("stopPreview('#{id}')")
|
1651
|
+
end
|
1652
|
+
|
1653
|
+
def video_preview(id, video, audio)
|
1654
|
+
JS.eval("create_preview('#{id}','#{video}','#{audio}')")
|
1655
|
+
end
|
1656
|
+
|
1657
|
+
def stop_media_recorder(id)
|
1658
|
+
JS.eval("writeatomestore('#{id}', 'record', 'stop')")
|
1659
|
+
end
|
1660
|
+
|
1660
1661
|
private
|
1661
1662
|
|
1662
1663
|
def apply_centering(options, parent)
|
1663
|
-
# Centre sur l'axe X
|
1664
1664
|
if options[:x]
|
1665
1665
|
x_position = calculate_position(options[:x], parent.to_px(:width), @original_atome.to_px(:width))
|
1666
1666
|
@original_atome.left(x_position)
|
@@ -51,6 +51,9 @@ new({ method: :data, type: :string, specific: :text, renderer: :html }) do |para
|
|
51
51
|
end
|
52
52
|
|
53
53
|
new({ method: :data, type: :string, specific: :vector, renderer: :html }) do |value|
|
54
|
+
unless value.instance_of? Array
|
55
|
+
value=[value]
|
56
|
+
end
|
54
57
|
html.svg_data(value)
|
55
58
|
end
|
56
59
|
|
@@ -87,10 +90,15 @@ new({ renderer: :html, method: :category, type: :symbol }) do |category_names|
|
|
87
90
|
end
|
88
91
|
end
|
89
92
|
|
90
|
-
new({ method: :data, type: :string, specific: :
|
93
|
+
new({ method: :data, type: :string, specific: :table, renderer: :html }) do |value, _user_proc|
|
91
94
|
html.table(value)
|
92
95
|
end
|
93
96
|
|
94
97
|
new({ method: :type, type: :hash, specific: :atomized, renderer: :html }) do |value, _user_proc|
|
95
|
-
html.atomized(
|
98
|
+
html.atomized(value)
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
new({ renderer: :html, method: :selected, specific: :text }) do |value, &bloc|
|
103
|
+
html.select_text(value)
|
96
104
|
end
|
@@ -81,4 +81,8 @@ end
|
|
81
81
|
new({ method: :opacity, type: :integer, renderer: :html}) do |value|
|
82
82
|
# html.opacity(value)
|
83
83
|
html.style('opacity',value)
|
84
|
+
end
|
85
|
+
|
86
|
+
new({ method: :visual, type: :string, renderer: :html, specific: :text }) do |value, _user_proc|
|
87
|
+
html.style('fontFamily', value)
|
84
88
|
end
|
@@ -26,8 +26,7 @@ new({ renderer: :html, method: :terminal, type: :string }) do |value, &bloc|
|
|
26
26
|
html.terminal(id, value)
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
new({renderer: :html, method: :match}) do |params, bloc|
|
29
|
+
new({ renderer: :html, method: :match }) do |params, bloc|
|
31
30
|
case id
|
32
31
|
when :atome || :view
|
33
32
|
result = bloc.call
|
@@ -37,7 +36,6 @@ new({renderer: :html, method: :match}) do |params, bloc|
|
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
|
-
|
41
39
|
new({ renderer: :html, method: :import, type: :blob }) do |_params, bloc|
|
42
40
|
|
43
41
|
if Atome::host == 'web-opal'
|
@@ -75,6 +73,7 @@ new({ renderer: :html, method: :import, type: :blob }) do |_params, bloc|
|
|
75
73
|
end
|
76
74
|
div_element.appendChild(input_element)
|
77
75
|
end
|
76
|
+
|
78
77
|
create_file_browser(:options) do |file_content|
|
79
78
|
# puts "wasm ===>#{file_content}"
|
80
79
|
bloc.call(file_content)
|
@@ -83,11 +82,6 @@ new({ renderer: :html, method: :import, type: :blob }) do |_params, bloc|
|
|
83
82
|
|
84
83
|
end
|
85
84
|
|
86
|
-
|
87
|
-
new({ renderer: :html, method: :selected, specific: :text }) do |value, &bloc|
|
88
|
-
html.select_text(value)
|
89
|
-
end
|
90
|
-
|
91
85
|
new({ method: :compute, type: :hash, renderer: :html }) do |params|
|
92
86
|
element = JS.global[:document].getElementById(@id.to_s)
|
93
87
|
bounding_box = element.getBoundingClientRect()
|
@@ -111,4 +105,66 @@ new({ method: :compute, type: :hash, renderer: :html }) do |params|
|
|
111
105
|
@compute[:value] = value_found
|
112
106
|
end
|
113
107
|
|
108
|
+
new({ renderer: :html, method: :preview }) do |params, user_proc|
|
109
|
+
if params[:id]
|
110
|
+
id_f = params[:id]
|
111
|
+
else
|
112
|
+
id_f = identity_generator
|
113
|
+
end
|
114
|
+
if params[:stop]
|
115
|
+
html.stop_video_preview(id_f)
|
116
|
+
else
|
117
|
+
|
118
|
+
if params[:media] == :video
|
119
|
+
html.video_preview(id_f, true, false)
|
120
|
+
elsif params[:media] == :audio
|
121
|
+
html.video_preview(id_f, false, true)
|
122
|
+
elsif params[:media] == :all
|
123
|
+
html.video_preview(id_f, true, true)
|
124
|
+
else
|
125
|
+
html.video_preview(id_f, true, true)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
new({ renderer: :html, method: :record }) do |params, user_proc|
|
131
|
+
duration = params[:duration] ||= 1000000
|
132
|
+
media = params[:media] ||= :video
|
133
|
+
mode = params[:mode] ||= :web # web or native
|
134
|
+
name = params[:name] ||= :record
|
135
|
+
path = params[:path] ||= './'
|
136
|
+
data = params[:data] ||= {}
|
137
|
+
stop = params[:stop]
|
138
|
+
if stop
|
139
|
+
if @video_recorder_type == :web || @audio_recorder_type == :web
|
140
|
+
html.stop_media_recorder(id)
|
141
|
+
elsif @video_recorder_type == :native || @audio_recorder_type == :native
|
142
|
+
A.message({ action: :stop_recording, data: params })
|
143
|
+
end
|
144
|
+
|
145
|
+
elsif media == :video
|
146
|
+
type = params[:type] ||= :mp4
|
147
|
+
if mode == :native
|
148
|
+
@video_recorder_type = :native
|
149
|
+
A.message({ action: :record, data: { type: type, duration: duration, name: name, path: path, media: media, data: data } }) do |result|
|
150
|
+
user_proc.call(result)
|
151
|
+
end
|
152
|
+
else
|
153
|
+
@video_recorder_type = :web
|
154
|
+
html.record_video(params)
|
155
|
+
end
|
156
|
+
|
157
|
+
elsif media == :audio
|
158
|
+
type = params[:type] ||= :wav
|
159
|
+
if mode == :native
|
160
|
+
@audio_recorder_type = :native
|
161
|
+
A.message({ action: :record, data: { type: type, duration: duration, name: name, path: path, media: media, data: data } }) do |result|
|
162
|
+
user_proc.call(result)
|
163
|
+
end
|
164
|
+
else
|
165
|
+
@audio_recorder_type = :web
|
166
|
+
html.record_audio(params)
|
167
|
+
end
|
168
|
+
end
|
114
169
|
|
170
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
image({ id: :logo })
|
4
|
+
def_2 = "M 536.75,-0.25 C 536.75,-0.25 536.75,-0.08 536.75,0.25 536.75,25.82 536.75,1023.75 536.75,1023.75 536.75,1024.08 536.75,1024.25 536.75,1024.25 L 486.75,1024.25 C 486.75,1024.25 486.75,1024.08 486.75,1023.75 486.75,998.18 486.75,0.25 486.75,0.25 486.75,0.24 486.75,-0.2 486.75,-0.2 L 536.75,-0.25 536.75,-0.25 Z M 536.75,-0.25"
|
5
|
+
vector({ id: :my_svg, top: 33, left: 99, data: { path: { d: def_2, id: :p2, stroke: :red, 'stroke-width' => 3, fill: :green } } })
|
6
|
+
|
7
|
+
wait 1 do
|
8
|
+
grab(:view).b64_to_tag({ id: 'my_svg', target: :logo })
|
9
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
a=box({width: 666, height: 777, color: :orange})
|
3
|
-
b = box({ left: 666, color: :blue, smooth: 6, id: :the_box2, depth: 1 })
|
3
|
+
b = box({ left: 666, color: :blue, smooth: 6, id: :the_box2, depth: 1 , top: 66})
|
4
4
|
cc=circle({color: :red, left: 0, top: 0})
|
5
5
|
clone = ""
|
6
6
|
b.drag(:start) do
|
7
7
|
b.color(:black)
|
8
8
|
b.height(123)
|
9
9
|
# beware you must use grab(:view) else it'll be attached to the context, that means to 'b' in this case
|
10
|
-
clone = grab(:view).circle({
|
10
|
+
clone = grab(:view).circle({ color: :white, left: b.left, top: b.top, depth: 3 })
|
11
11
|
end
|
12
12
|
|
13
13
|
b.drag(:stop) do
|
@@ -44,4 +44,11 @@ t.touch(true) do
|
|
44
44
|
b.drag({remove: :stop})
|
45
45
|
end
|
46
46
|
|
47
|
+
tt= text({data: "remove drag on circles", top: 99})
|
48
|
+
|
49
|
+
tt.touch(true) do
|
50
|
+
cc.drag(false)
|
51
|
+
c.drag(false)
|
52
|
+
end
|
53
|
+
|
47
54
|
|