atome 0.5.6.8.7 → 0.5.7.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/basic.md +7 -8
  3. data/documentation/deep learning/basic_infos.txt +6 -6
  4. data/documentation/installation/atome_server.md +66 -1
  5. data/documentation/installation/buiding_atome.md +307 -0
  6. data/lib/atome/atome.rb +2 -3
  7. data/lib/atome/extensions/atome.rb +38 -12
  8. data/lib/atome/genesis/atomes.rb +1 -1
  9. data/lib/atome/genesis/genesis.rb +11 -11
  10. data/lib/atome/genesis/particles/event.rb +58 -50
  11. data/lib/atome/genesis/particles/identity.rb +3 -0
  12. data/lib/atome/genesis/particles/property.rb +2 -1
  13. data/lib/atome/genesis/particles/utility.rb +19 -12
  14. data/lib/atome/genesis/presets.rb +10 -0
  15. data/lib/atome/genesis/sparkle.rb +11 -9
  16. data/lib/atome/kernel/universe.rb +22 -11
  17. data/lib/atome/presets/atome.rb +20 -17
  18. data/lib/atome/utilities/essentials.rb +5 -5
  19. data/lib/atome/utilities/utilities.rb +168 -15
  20. data/lib/atome/version.rb +1 -1
  21. data/lib/atome.rb +1 -0
  22. data/lib/atome_relative.rb +1 -0
  23. data/lib/molecules/init.rb +22 -42
  24. data/lib/molecules/intuition/_deprecated_inputs.rb +111 -0
  25. data/lib/molecules/intuition/utillities.rb +105 -11
  26. data/lib/renderers/html/event.rb +20 -4
  27. data/lib/renderers/html/html.rb +145 -161
  28. data/lib/renderers/html/identity.rb +10 -2
  29. data/lib/renderers/html/utility.rb +64 -8
  30. data/vendor/assets/application/examples/b64_to_image.rb +9 -0
  31. data/vendor/assets/application/examples/drag.rb +9 -2
  32. data/vendor/assets/application/examples/matrix.rb +77 -114
  33. data/vendor/assets/application/examples/recorder.rb +74 -0
  34. data/vendor/assets/application/examples/site.rb +41 -0
  35. data/vendor/assets/application/examples/sub_atome_manipulation.rb +0 -2
  36. data/vendor/assets/application/examples/svg_img_to_vector.rb +6 -0
  37. data/vendor/assets/application/examples/svg_vectorizer.rb +21 -0
  38. data/vendor/assets/application/examples/table.rb +1 -1
  39. data/vendor/assets/application/examples/test.rb +572 -0
  40. data/vendor/assets/application/examples/tools.rb +650 -304
  41. data/vendor/assets/application/examples/vector.rb +16 -3
  42. data/vendor/assets/server/atome_server.rb +3 -2
  43. data/vendor/assets/server/atome_server_wasm.rb +2 -2
  44. data/vendor/assets/server/eDen.rb +135 -14
  45. data/vendor/assets/src/index.html +1 -1
  46. data/vendor/assets/src/index_opal.html +1 -1
  47. data/vendor/assets/src/index_server.html +1 -1
  48. data/vendor/assets/src/index_server_wasm.html +1 -1
  49. data/vendor/assets/src/index_wasm.html +1 -1
  50. data/vendor/assets/src/js/atome/atome.js +250 -49
  51. data/vendor/assets/src/js/atome/atome_helpers/communication.js +4 -4
  52. data/vendor/assets/src/js/atome/specific/opal.js +19 -3
  53. data/vendor/assets/src/js/atome/specific/wasm.js +18 -3
  54. data/vendor/assets/src/js/molecules/web.js +1 -1
  55. data/vendor/assets/src/medias/images/icons/Lowpass.svg +8 -0
  56. data/vendor/assets/src/medias/images/icons/activate.svg +3 -0
  57. data/vendor/assets/src/medias/images/icons/audio.svg +7 -0
  58. data/vendor/assets/src/medias/images/icons/band_pass.svg +8 -0
  59. data/vendor/assets/src/medias/images/icons/clear.svg +5 -0
  60. data/vendor/assets/src/medias/images/icons/color.svg +5 -0
  61. data/vendor/assets/src/medias/images/icons/copy.svg +8 -0
  62. data/vendor/assets/src/medias/images/icons/create.svg +3 -0
  63. data/vendor/assets/src/medias/images/icons/delete.svg +8 -0
  64. data/vendor/assets/src/medias/images/icons/edit-.svg +4 -0
  65. data/vendor/assets/src/medias/images/icons/edit.svg +4 -0
  66. data/vendor/assets/src/medias/images/icons/edition.svg +4 -0
  67. data/vendor/assets/src/medias/images/icons/equalizer-.svg +5 -0
  68. data/vendor/assets/src/medias/images/icons/equalizer.svg +5 -0
  69. data/vendor/assets/src/medias/images/icons/filter.svg +4 -0
  70. data/vendor/assets/src/medias/images/icons/folder.svg +4 -0
  71. data/vendor/assets/src/medias/images/icons/group.svg +6 -0
  72. data/vendor/assets/src/medias/images/icons/hamburger.svg +8 -0
  73. data/vendor/assets/src/medias/images/icons/high_pass.svg +5 -0
  74. data/vendor/assets/src/medias/images/icons/link.svg +4 -0
  75. data/vendor/assets/src/medias/images/icons/load.svg +4 -0
  76. data/vendor/assets/src/medias/images/icons/low_pass.svg +5 -0
  77. data/vendor/assets/src/medias/images/icons/microphone.svg +7 -0
  78. data/vendor/assets/src/medias/images/icons/midi_in.svg +4 -0
  79. data/vendor/assets/src/medias/images/icons/midi_out.svg +4 -0
  80. data/vendor/assets/src/medias/images/icons/modules.svg +11 -0
  81. data/vendor/assets/src/medias/images/icons/paste.svg +4 -0
  82. data/vendor/assets/src/medias/images/icons/pause.svg +5 -0
  83. data/vendor/assets/src/medias/images/icons/play.svg +7 -0
  84. data/vendor/assets/src/medias/images/icons/record.svg +4 -0
  85. data/vendor/assets/src/medias/images/icons/save.svg +5 -0
  86. data/vendor/assets/src/medias/images/icons/select--.svg +4 -0
  87. data/vendor/assets/src/medias/images/icons/select-.svg +5 -0
  88. data/vendor/assets/src/medias/images/icons/select-all.svg +4 -0
  89. data/vendor/assets/src/medias/images/icons/select.svg +4 -0
  90. data/vendor/assets/src/medias/images/icons/settings.svg +5 -0
  91. data/vendor/assets/src/medias/images/icons/settings0.svg +2 -0
  92. data/vendor/assets/src/medias/images/icons/settings1.svg +17 -0
  93. data/vendor/assets/src/medias/images/icons/settings2.svg +25 -0
  94. data/vendor/assets/src/medias/images/icons/settings_old.svg +6 -0
  95. data/vendor/assets/src/medias/images/icons/shape.svg +7 -0
  96. data/vendor/assets/src/medias/images/icons/speaker.svg +6 -0
  97. data/vendor/assets/src/medias/images/icons/stop.svg +4 -0
  98. data/vendor/assets/src/medias/images/icons/tool.svg +7 -0
  99. data/vendor/assets/src/medias/images/icons/tools.svg +9 -0
  100. data/vendor/assets/src/medias/images/icons/undo2.svg +4 -0
  101. data/vendor/assets/src/medias/images/icons/validate.svg +9 -0
  102. data/vendor/assets/src/medias/images/icons/vie.svg +3 -0
  103. data/vendor/assets/src/medias/images/icons/wave-saw.svg +3 -0
  104. data/vendor/assets/src/medias/images/icons/wave-sine.svg +3 -0
  105. data/vendor/assets/src/medias/images/icons/wave-square-.svg +4 -0
  106. data/vendor/assets/src/medias/images/icons/wave-square.svg +3 -0
  107. data/vendor/assets/src/medias/images/icons/wave-triangle.svg +3 -0
  108. data/vendor/assets/src/medias/images/icons/waveform-.svg +4 -0
  109. data/vendor/assets/src/medias/images/icons/waveform.svg +7 -0
  110. metadata +68 -6
  111. data/lib/molecules/intuition/inputs.rb +0 -111
  112. /data/lib/molecules/{examples → _deprecated_examples}/site.rb +0 -0
  113. /data/lib/molecules/intuition/{toolbox.rb → _deprecated_toolbox.rb} +0 -0
@@ -1,12 +1,584 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # grab(:intuition).box({id: :toolbox, left: 33, top: 333})
4
+ # toolbox_style contain all tools styles
5
+ size = 33
6
+ smooth = 3
7
+ shadow({
8
+ id: :tool_shade,
9
+ left: 3, top: 3, blur: 3,
10
+ invert: false,
11
+ red: 0, green: 0, blue: 0, alpha: 0.6
12
+ })
3
13
 
14
+ color({ id: :tool_inactive_color, red: 1, green: 1, blue: 1, alpha: 0.12 })
15
+ color({ id: :tool_active_color, red: 1, green: 1, blue: 1, alpha: 0.3 })
16
+ border({ id: :tool_box_border, thickness: 1, red: 1, green: 1, blue: 1, alpha: 0.06, pattern: :solid, inside: true })
17
+ # Tool's style object container below
18
+ element({ aid: :toolbox_style, id: :toolbox_style, data: {
19
+ color: :gray,
20
+ size: size,
21
+ smooth: smooth
22
+ } })
4
23
 
24
+ class Atome
25
+ @tools_actions_to_exec = {}
5
26
 
27
+ class << self
6
28
 
29
+ def init_intuition
30
+ Atome.start_click_analysis
31
+ Universe.tools.each_with_index do |(tool_name, bloc), index|
32
+ # puts "add position and orientation"
33
+ A.build_tool({ name: tool_name, index: index }, &bloc)
34
+ end
35
+ end
7
36
 
37
+ def selection
38
+ grab(Universe.current_user).selection.collect
39
+ end
8
40
 
41
+ def add_tool_actions(tool_name, tool_content)
42
+ # alert "tool_content is : tool_content#{tool_content}"
43
+ # int8_f=tool_content[:int8]
44
+ # activation_f=tool_content[:active]
45
+ # inactivation_f=tool_content[:inactive]
46
+ # creator=tool_content[:creation]
47
+ # alterator=tool_content[:alteration]
48
+ @tools_actions_to_exec[tool_name] = tool_content
49
+ end
9
50
 
51
+ def tool_actions_to_exec
52
+ @tools_actions_to_exec
53
+ end
10
54
 
55
+ def activate_click_analysis
11
56
 
57
+ # the condition below avoid touchdown analysis accumulation
58
+ unless @click_analysis_active
59
+ # this method analyse all object under the touchdown to find the first user objet and return it's id
12
60
 
61
+ @click_analysis = lambda { |native_event|
62
+ # the instance variable below check if we can apply tool (cf: if the atome we don't want to apply tool)
63
+ if Universe.allow_tool_operations
64
+ event = Native(native_event)
65
+ x = event[:clientX]
66
+ y = event[:clientY]
67
+ elements = JS.global[:document].elementsFromPoint(x, y)
68
+ elements.to_a.each do |element|
69
+ id_found = element[:id].to_s
70
+ atome_touched = grab(id_found)
71
+ if grab(id_found) && grab(id_found).tag[:system]
72
+ else
73
+ @creations_f = []
74
+ @alterations_f = []
75
+ current_tool = ''
76
+ @tools_actions_to_exec.each do |tool_name, actions|
77
+ current_tool = grab(tool_name)
78
+ @creations_f = @creations_f.concat(actions[:creation]) if actions[:creation] # Concaténation
79
+ @alterations_f = @alterations_f.concat(actions[:alteration]) if actions[:alteration] # Concaténation
80
+ end
81
+ # Creation below
82
+ @creations_f.each do |create_content|
83
+ code_before_applying = create_content[:pre]
84
+ code_after_applying = create_content[:post]
85
+ instance_exec(atome_touched,event,&code_before_applying) if code_before_applying.is_a? Proc
86
+ atome_type = create_content[:type]
87
+ particles = create_content[:particles]
88
+ new_atome = grab(:view).send(atome_type)
89
+ particles.each do |particle_found, value_found|
90
+ new_atome.send(particle_found, value_found)
91
+ end
92
+ new_atome.resize(true)
93
+ new_atome.drag(true)
94
+ new_atome.left(event[:pageX].to_i)
95
+ new_atome.top(event[:pageY].to_i)
96
+ current_tool.data << new_atome
97
+ instance_exec(atome_touched,new_atome,event,&code_after_applying) if code_after_applying.is_a? Proc
98
+
99
+ # now applying alterations on new atome if needed:
100
+ @alterations_f.each do |actions_f|
101
+ code_before_applying = actions_f[:pre]
102
+ code_after_applying = actions_f[:post]
103
+ instance_exec(new_atome,event,&code_before_applying) if code_before_applying.is_a? Proc
104
+ action = actions_f[:particle]
105
+ value = actions_f[:value]
106
+ new_atome.send(action, value)
107
+ instance_exec(new_atome,event,&code_after_applying) if code_after_applying.is_a? Proc
108
+ end
109
+
110
+
111
+ end
112
+ if atome_touched
113
+ @alterations_f.each do |actions_f|
114
+ code_before_applying = actions_f[:pre]
115
+ code_after_applying = actions_f[:post]
116
+ instance_exec(nil,event,&code_before_applying) if code_before_applying.is_a? Proc
117
+ action = actions_f[:particle]
118
+ value = actions_f[:value]
119
+ atome_touched.send(action, value)
120
+ instance_exec(nil,event,&code_after_applying) if code_after_applying.is_a? Proc
121
+ end
122
+ # Atome.instance_exec(id_found, x, y, &@click_analysis_action) if @click_analysis_action.is_a?(Proc)
123
+ end
124
+ break
125
+ end
126
+ end
127
+ else
128
+ Universe.allow_tool_operations=true
129
+ end
130
+
131
+ }
132
+ @click_analysis_active = true
133
+ end
134
+
135
+ end
136
+
137
+ def de_activate_click_analysis
138
+ # alert 'we need to find how many tools are still active'
139
+ @click_analysis = nil
140
+ @click_analysis_active = false
141
+ end
142
+
143
+ def start_click_analysis
144
+ @click_analysis_active = false
145
+ JS.global[:document].addEventListener('mouseup') do |native_event|
146
+ Atome.instance_exec(native_event, &@click_analysis) if @click_analysis.is_a?(Proc)
147
+ end
148
+ end
149
+
150
+ end
151
+
152
+ def build_tool(params, &bloc)
153
+ label = params[:name]
154
+ name = "#{params[:name]}_tool"
155
+ index = params[:index]
156
+ orientation = params[:orientation]
157
+ orientation_wanted = :sn
158
+ color({ id: :active_tool_col, alpha: 1, red: 1, green: 1, blue: 1 })
159
+ color({ id: :inactive_tool_col, alpha: 0.6 })
160
+ tool_content = Atome.instance_exec(&bloc) if bloc.is_a?(Proc)
161
+ grab(:intuition).storage[:tool_open] ||= []
162
+ grab(:intuition).storage[:tool_open] << name
163
+ size = grab(:toolbox_style).data[:size]
164
+ smooth = grab(:toolbox_style).data[:smooth]
165
+ case orientation_wanted
166
+ when :sn
167
+ top = :auto
168
+ bottom = index * (size + 3)
169
+ left = 0
170
+ right = :auto
171
+ when :ns
172
+ when :ew
173
+ when :we
174
+ else
175
+ #
176
+ end
177
+
178
+ # tool creation
179
+ tool = grab(:intuition).box({ id: name,
180
+ tag: { system: true },
181
+ # orientation: orientation_wanted,
182
+ top: top,
183
+ bottom: bottom,
184
+ left: left,
185
+ right: right,
186
+ width: size,
187
+ height: size,
188
+ smooth: smooth,
189
+ apply: [:tool_inactive_color, :tool_box_border, :tool_shade],
190
+ state: :closed,
191
+ # storage: { taxonomy: Intuition.impulse },
192
+ })
193
+ tool.vector({ tag: { system: true }, left: 9, top: :auto, bottom: 9, width: 18, height: 18, id: "#{name}_icon" })
194
+ tool.text({ tag: { system: true }, data: label, component: { size: 9 }, color: :grey, id: "#{name}_label" })
195
+ tool.touch(true) do |ev|
196
+ # we add all specific tool actions to @tools_actions_to_exec hash
197
+
198
+ Atome.add_tool_actions(name, tool_content)
199
+ # we set allow_tool_operations to false to ignore tool operation when clicking on a tool
200
+ Universe.allow_tool_operations=false
201
+ # we create the creation_layer if not already exist
202
+
203
+ tick(name)
204
+ # active code exec
205
+ if tick[name] == 1 # first click
206
+ # we set edit mode to true (this allow to prevent user atome to respond from click)
207
+ Universe.edit_mode = true
208
+ # activate tool analysis test
209
+ Atome.activate_click_analysis
210
+
211
+ # check_me_first = lambda { |atome_id_found, x, y|
212
+ # puts "first user atome ==> #{grab(atome_id_found).id}, x: #{x}, y: #{y}"
213
+ # }
214
+ # Atome.instance_variable_set('@click_analysis_action', check_me_first)
215
+ # init the tool
216
+ tool.data = []
217
+ # generic behavior
218
+ tool.apply(:active_tool_col)
219
+ # activation code
220
+ tool_content[:active].each do |code_exec|
221
+ tool.instance_exec(&code_exec)
222
+ end if tool_content && tool_content[:active]
223
+ if tool_content && tool_content[:alteration]
224
+ # here we treat any selected items on tool activation
225
+ tool_content[:alteration].each do |action|
226
+ Atome.selection.each do |atome_id_to_treat|
227
+ atome_to_treat=grab(atome_id_to_treat)
228
+ pre_proc = action[:pre]
229
+ tool.instance_exec(atome_to_treat,nil, &pre_proc) if pre_proc.is_a? Proc
230
+ particle_f = action[:particle]
231
+ value_f = action[:value]
232
+ atome_to_treat.send(particle_f, value_f)
233
+ post_proc = action[:post]
234
+ tool.instance_exec(atome_to_treat,nil, &post_proc) if post_proc.is_a? Proc
235
+ end
236
+ end
237
+ end
238
+
239
+ else
240
+ # when closing delete tools action from tool_actions_to_exec
241
+ Atome.tool_actions_to_exec.delete(name)
242
+ # we check if all tools are inactive if so we set edit_mode to false
243
+ if Atome.tool_actions_to_exec.length == 0
244
+ # puts "Atome.tool_actions_to_exec.length = 0"
245
+ Atome.de_activate_click_analysis
246
+ Universe.edit_mode = false
247
+ end
248
+
249
+ # inactivation code
250
+ tool_content[:inactive].each do |code_exec|
251
+ tool.instance_exec(tool.data, &code_exec)
252
+ end if tool_content && tool_content[:inactive]
253
+
254
+ # generic behavior
255
+ # we remove touch and resize binding on newly created atomes
256
+ tool.apply(:inactive_tool_col)
257
+ tool.data.each do |new_atome|
258
+ new_atome.drag(false)
259
+ new_atome.resize(:remove)
260
+ end
261
+ tick[name] = 0
262
+ end
263
+ end
264
+ end
265
+ end
266
+
267
+ module Intuition
268
+ class << self
269
+ @toolbox = { impulse: [:capture_tool, :communication_tool, :creation_tool, :view_tool, :time_tool, :find_tool, :home_tool],
270
+ capture_tool: [:microphone_tool, :camera_tool,]
271
+ }
272
+
273
+ def intuition_int8
274
+ # tool taxonomy and list
275
+ {
276
+ capture: { int8: { french: :enregistrement, english: :record, german: :datensatz } },
277
+ communication: { french: :communication, english: :communication, german: :communication },
278
+ tool: { french: :outils, english: :tools, german: :werkzeuge },
279
+ view: { french: :vue, english: :view, german: :aussicht },
280
+ time: { french: :horloge, english: :clock, german: :Uhr },
281
+ find: { french: :trouve, english: :find, german: :finden },
282
+ home: { french: :accueil, english: :home, german: :zuhause },
283
+ code: { french: :code, english: :code, german: :code },
284
+ impulse: { french: :impulse, english: :impulse, german: :impulse },
285
+ }
286
+ end
287
+
288
+ def impulse
289
+
290
+ # initialise touchdown analysis
291
+ # Atome.start_click_analysis
292
+
293
+ # tool start point
294
+ # [:capture_tool, :communication, :tool, :view, :time, :find, :home]
295
+ end
296
+ end
297
+
298
+ end
299
+
300
+ ##########################################################
301
+ # new({ tool: :impulse }) do |params|
302
+ #
303
+ # creation_code = lambda { |event|
304
+ # puts :box_creation
305
+ # }
306
+ #
307
+ # active_code = lambda { |event|
308
+ # puts :start
309
+ # apply([:tool_active_color])
310
+ # storage[:taxonomy].each_with_index do |tool, index|
311
+ #
312
+ # # Atome.display_tool("tool_#{tool}", index + 1, :ns)
313
+ # end
314
+ # state(:open)
315
+ # }
316
+ #
317
+ # inactive_code = lambda { |param|
318
+ # puts :stop
319
+ # # impulse.storage[:taxonomy].each do |tool|
320
+ # # grab("tool_#{tool}").delete(true)
321
+ # # end
322
+ # # impulse.apply([:tool_inactive_color])
323
+ # # impulse.state(:closed)
324
+ # }
325
+ #
326
+ # {
327
+ # active: [active_code],
328
+ # inactive: [inactive_code],
329
+ # creation: [creation_code],
330
+ # int8: { french: :impulse, english: :impulse, german: :impulse }
331
+ # }
332
+ # end
333
+
334
+ # toolbox creation
335
+ # Atome.display_tool(:impulse, 0, :ns)
336
+ # grab(:impulse).touch(true) do
337
+ # impulse = grab(:impulse)
338
+ # if impulse.state == :closed
339
+ # impulse.apply([:tool_active_color])
340
+ # impulse.storage[:taxonomy].each_with_index do |tool, index|
341
+ #
342
+ # Atome.display_tool("tool_#{tool}", index + 1, :ns)
343
+ # end
344
+ # impulse.state(:open)
345
+ # else
346
+ # impulse.storage[:taxonomy].each do |tool|
347
+ # grab("tool_#{tool}").delete(true)
348
+ # end
349
+ # impulse.apply([:tool_inactive_color])
350
+ # impulse.state(:closed)
351
+ # end
352
+ # end
353
+
354
+ # ##############################################################################################
355
+
356
+ new({ tool: :shape }) do |params|
357
+
358
+ active_code = lambda {
359
+ puts :creation_tool_code_activated
360
+ # puts "activation code here"
361
+ }
362
+
363
+ inactive_code = lambda { |atomes_treated|
364
+ puts :creation_tool_code_inactivated
365
+ # atomes_treated.each do |new_atome|
366
+ # if new_atome.selected
367
+ # new_atome.left(new_atome.left + 33)
368
+ # new_atome.color({ red: rand, green: rand, blue: rand })
369
+ # end
370
+ # end
371
+ }
372
+ pre_crea_code = lambda { |atome_touched, event|
373
+ puts "pre_creation_code : atome_touched : #{atome_touched} event : #{event} "
374
+ # Atome.selection.each do |atome_to_treat|
375
+ # grab(atome_to_treat).color(:red)
376
+ # grab(atome_to_treat).rotate(21)
377
+ # puts "pre"
378
+ # end
379
+ }
380
+
381
+ post_crea_code = lambda { |atome_touched, new_atome, event|
382
+ puts "post_creation_code,atome_touched: #{atome_touched}, new_atome :#{new_atome}, event : #{event}"
383
+
384
+ # new_atome.color(:blue)
385
+ # puts "post"
386
+ }
387
+
388
+ creation_code = [{ type: :box, particles: { width: 66, height: 66 }, pre: pre_crea_code },
389
+ { type: :circle, particles: { width: 66, height: 66 }, post: post_crea_code }
390
+ ]
391
+ pre_code = lambda { |atome_touched, event|
392
+ # grab(atome_touched).height(99)
393
+ puts 'alteration pre treatment'
394
+ }
395
+
396
+ post_code = lambda { |atome_touched, event|
397
+
398
+ atome_touched.height(199)
399
+ # new_atome.height(199) if new_atome
400
+ # grab(new_atome).width(99)
401
+ puts 'alteration post treatment'
402
+
403
+ }
404
+
405
+ alterations = [{ particle: :blur, value: 3, pre: pre_code, post: post_code }]
406
+
407
+ { creation: creation_code, alteration: alterations,
408
+ active: [active_code],
409
+ inactive: [inactive_code],
410
+ int8: { french: :formes, english: :shape, german: :jesaispas } }
411
+
412
+ end
413
+
414
+ ### tool2 test
415
+
416
+ new({ tool: :color }) do |params|
417
+
418
+
419
+ active_code = lambda {
420
+ # grab(:intuition).data[:color] = :red
421
+ puts :alteration_tool_code_activated
422
+ }
423
+
424
+ inactive_code = lambda { |param|
425
+ puts :alteration_tool_code_inactivated
426
+ }
427
+ pre_code= lambda { |atome_touched, event|
428
+ puts "post_creation_code,atome_touched: #{atome_touched}, event : #{event}"
429
+
430
+ # new_atome.color(:blue)
431
+ # puts "post"
432
+ }
433
+ post_code= lambda { |atome_touched, event|
434
+ puts "post_creation_code,atome_touched: #{atome_touched}, event : #{event}"
435
+
436
+ # new_atome.color(:blue)
437
+ # puts "post"
438
+ }
439
+ alterations = [{ particle: :width, value: 22 }, { particle: :color, value: :red, pre: pre_code,
440
+ post: post_code, }, { particle: :rotate, value: 33 }]
441
+ {
442
+ active: [active_code],
443
+ inactive: [inactive_code],
444
+ alteration: alterations,
445
+
446
+ int8: { french: :couleur, english: :color, german: :colorad } }
447
+
448
+ end
449
+
450
+ # new({ tool: :color }) do |params|
451
+ #
452
+ # { alteration: [{ particle: :blur, value: 22 }] }
453
+ #
454
+ # end
455
+ # verif below
456
+ # wait 1 do
457
+
458
+ Atome.init_intuition
459
+ # end
460
+
461
+ # ##############################################################################################
462
+ #
463
+
464
+ b = box({ left: 123, top: 66, selected: false, id: :the_box })
465
+ b.touch(:down) do
466
+ puts '"im touched"'
467
+ end
468
+ circle({ left: 123, top: 120, selected: true, id: :the_circle, drag: true })
469
+
470
+ # def id_found_under_touch(obj_found)
471
+ # alert obj_found
472
+ # end
473
+ # aa=<<STR
474
+ # document.addEventListener('click', function(event) {
475
+ # var x = event.clientX;
476
+ # var y = event.clientY;
477
+ # var elementUnderCursor = document.elementFromPoint(x, y).id;
478
+ # Opal.Object.$id_found_under_touch(elementUnderCursor);
479
+ # });
480
+ # STR
481
+ #
482
+ # JS.eval(aa)
483
+
484
+ # ###################### marche
485
+ class Atome
486
+
487
+ def set_action_on_touch(&action)
488
+ @touch_action = action
489
+
490
+ end
491
+
492
+ # def set_atome_on_touch
493
+ # document = JS.global[:document]
494
+ # document.addEventListener("click") do |native_event|
495
+ # event = Native(native_event)
496
+ # x = event[:clientX]
497
+ # y = event[:clientY]
498
+ # element = document.elementFromPoint(x, y)
499
+ # element_id = element[:id]
500
+ # puts "test if element is a system element else select it "
501
+ # @touch_action.call(element_id) if @touch_action.is_a? Proc
502
+ # end
503
+ # end
504
+
505
+ # def set_atome_on_touch
506
+ # document = JS.global[:document]
507
+ # document.addEventListener("click") do |native_event|
508
+ # event = Native(native_event)
509
+ # x = event[:clientX]
510
+ # y = event[:clientY]
511
+ # element = document.elementFromPoint(x, y)
512
+ #
513
+ # # Boucle pour remonter la hiérarchie des éléments
514
+ # while element && element != document
515
+ # # Vérifie si l'élément a l'ID 'view'
516
+ # if element[:id].to_s == 'view'
517
+ # element_id = element[:id]
518
+ # @touch_action.call(element_id) if @touch_action.is_a? Proc
519
+ #
520
+ # # alert "Clic sur un descendant de 'view'"
521
+ # break
522
+ # end
523
+ # # Passe au parent de l'élément actuel
524
+ # # element = element.JS[:parentNode]
525
+ # break
526
+ # end
527
+ # end
528
+ # end
529
+
530
+ def remove_get_atome_on_touch
531
+ @touch_action = nil
532
+ end
533
+
534
+ end
535
+
536
+ ###### verif
537
+ # A.set_action_on_touch do |at_id|
538
+ # puts "==> #{at_id}"
539
+ # end
540
+ # A.set_atome_on_touch
541
+ #
542
+ #
543
+ # wait 2 do
544
+ # A.remove_get_atome_on_touch
545
+ # wait 3 do
546
+ # puts 'ready again !!'
547
+ # A.set_action_on_touch do |at_id|
548
+ # puts "******> #{at_id}"
549
+ # end
550
+ # end
551
+ # end
552
+
553
+ ###### good algo
554
+ # class Atome
555
+ # class << self
556
+ #
557
+ #
558
+ # end
559
+ #
560
+ # end
561
+
562
+ # check_me_first = lambda { |atome_id_found|
563
+ # puts "first user atome ==> #{grab(atome_id_found).id}"
564
+ # }
565
+ # Atome.instance_variable_set('@click_analysis_action', check_me_first)
566
+ # alert grab(:intuition).instance_variable_get('@click_analysis_action')
567
+
568
+ # wait 3 do
569
+ # check_me = lambda { |atome_id_found|
570
+ # puts "Cool cool cool, for :#{atome_id_found}"
571
+ # }
572
+ # Atome.instance_variable_set('@click_analysis_action', check_me)
573
+ # # wait 2 do
574
+ # # Atome.de_activate_click_analysis
575
+ # # alert :game_over
576
+ # # end
577
+ # end
578
+
579
+ # array1 = [1, 2, 3]
580
+ # array2 = nil
581
+ # array1.concat(array2) if array2
582
+ #
583
+ # alert array1
584
+ bb = box()