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
@@ -6,6 +6,7 @@ require 'json'
6
6
  class Atome
7
7
  class << self
8
8
  attr_accessor :initialized
9
+
9
10
  def sanitize_data_for_json(data)
10
11
  data = data.gsub('"', '\\"')
11
12
  # case data
@@ -21,13 +22,12 @@ class Atome
21
22
  data
22
23
  end
23
24
 
24
-
25
25
  def send_localstorage_content
26
26
  storage = JS.global[:localStorage]
27
27
  storage_array = storage.to_a
28
28
  storage_array.each_with_index do |_i, index|
29
29
  key = JS.global[:localStorage].key(index)
30
- sanitize_data_for_json(storage.getItem(key))
30
+ sanitize_data_for_json(storage.getItem(key))
31
31
  end
32
32
  end
33
33
 
@@ -49,6 +49,26 @@ class Atome
49
49
  JS.eval(js_command)
50
50
  end
51
51
 
52
+ # atome builder
53
+ def preset_builder(preset_name, &bloc)
54
+ # Important : previously def box , def circle
55
+ Universe.atome_preset << preset_name
56
+ Object.define_method preset_name do |params = {}, &proc|
57
+ grab(:view).send(preset_name, params, &proc)
58
+ end
59
+ define_method preset_name do |params|
60
+ preset_to_add = instance_exec(params, &bloc) if bloc.is_a? Proc
61
+ if Essentials.default_params[preset_name]
62
+ Essentials.default_params[preset_name].merge(preset_to_add) if preset_to_add
63
+ else
64
+ Essentials.default_params[preset_name] = preset_to_add if preset_to_add
65
+ end
66
+ params = atome_common(preset_name, params)
67
+ preset_common(params, &bloc)
68
+ end
69
+
70
+ end
71
+
52
72
  # monitoring system
53
73
  def monitoring(atomes_to_monitor, particles_to_monitor, &bloc)
54
74
  atomes_to_monitor.each do |atome_to_monitor|
@@ -81,6 +101,18 @@ class Atome
81
101
  end
82
102
  end
83
103
 
104
+ def controller_listener
105
+ return if $host == :html
106
+ atome_js.JS.controller_listener() # js folder atome/helipers/atome/communication
107
+ end
108
+
109
+ def handleSVGContent(svg_content, target)
110
+ puts svg_content
111
+ atome_content = A.vectorizer(svg_content)
112
+ target_vector = grab(target)
113
+ target_vector.data(atome_content)
114
+ end
115
+
84
116
  end
85
117
 
86
118
  @initialized = {}
@@ -114,12 +146,6 @@ class Atome
114
146
  send(js_action, js_body)
115
147
  end
116
148
 
117
- def self.controller_listener
118
- return if $host == :html
119
-
120
- atome_js.JS.controller_listener() # js folder atome/helipers/atome/communication
121
- end
122
-
123
149
  def collapse(new_atome)
124
150
  initialized_procs = []
125
151
  initialized = Atome.initialized
@@ -127,13 +153,13 @@ class Atome
127
153
  new_atome.each do |element, value|
128
154
  send(element, value)
129
155
  initialized_proc = initialized[element]
130
- initialized_procs << {value => initialized_proc } if initialized_proc.is_a?(Proc)
156
+ initialized_procs << { value => initialized_proc } if initialized_proc.is_a?(Proc)
131
157
  end
132
158
 
133
159
  initialized_procs.each do |value|
134
- value.each do |val, proc|
135
- instance_exec(val, &proc)
136
- end
160
+ value.each do |val, proc|
161
+ instance_exec(val, &proc)
162
+ end
137
163
  end
138
164
 
139
165
  end
@@ -318,6 +344,23 @@ class Atome
318
344
  send("#{element}_callback", return_params)
319
345
  end
320
346
 
347
+ def js_callback(id, particle, value,sub=nil )
348
+ current_atome= grab(id)
349
+ # # alert current_atome.instance_variable_get('@record_code')
350
+ proc_found= current_atome.instance_variable_get("@#{particle}_code")[particle.to_sym]
351
+ # proc_found= current_atome.instance_variable_get("@record_code")[:record]
352
+ # # alert particle.class
353
+ # # alert proc_found.class
354
+ # proc_found.call
355
+ instance_exec(value, &proc_found) if proc_found.is_a?(Proc)
356
+ # # # puts "params to be exec #{id}, #{particle}, #{value}, #{sub}"
357
+ # alpha= grab(:the_big_box)
358
+ # proc_found= alpha.instance_variable_get("@record_code")[:record]
359
+ # proc_found.call
360
+
361
+ end
362
+
363
+
321
364
  # def callback(data)
322
365
  # @callback[data.keys[0]] = data[data.keys[0]]
323
366
  # end
@@ -431,7 +474,6 @@ class Atome
431
474
  end
432
475
  end
433
476
 
434
-
435
477
  def init_websocket
436
478
  connection(@current_server)
437
479
  end
@@ -458,8 +500,6 @@ class Atome
458
500
  storage_items
459
501
  end
460
502
 
461
-
462
-
463
503
  # def to_sym
464
504
  # puts "sanitizer temp patch when an atome is passed instead of an id"
465
505
  # @id
@@ -491,7 +531,120 @@ class Atome
491
531
  current_state
492
532
  end
493
533
 
534
+ def vectorizer(svg_content)
535
+ atome_content = []
536
+
537
+ # circle_regex = /<circle\s+.*?id\s*=\s*"(.*?)"\s+(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?fill\s*=\s*"(.*?)"\s+cx\s*=\s*"(\d+)"\s+cy\s*=\s*"(\d+)"\s+r\s*=\s*"(\d+)".*?\/>/
538
+ circle_regex = /<circle\s+.*?id\s*=\s*"(.*?)"\s+(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?fill\s*=\s*"(.*?)"\s+cx\s*=\s*"(\d+(?:\.\d+)?)"\s+cy\s*=\s*"(\d+(?:\.\d+)?)"\s+r\s*=\s*"(\d+(?:\.\d+)?)"\s*.*?\/>/
539
+
540
+ svg_content.scan(circle_regex) do |id, stroke, stroke_width, fill, cx, cy, r|
541
+ stroke = stroke || 'none'
542
+ stroke_width = stroke_width || '0'
543
+ fill = fill || 'none'
544
+ circle_def = { circle: { cx: cx, cy: cy, r: r, id: id, stroke: stroke, "stroke-width" => stroke_width, fill: fill } }
545
+ atome_content << circle_def
546
+ end
547
+
548
+ # path_regex = /<path\s+.*?d\s*=\s*"([^"]+)"\s+(?:id\s*=\s*"(.*?)"\s+)?(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?fill\s*=\s*"(.*?)".*?\/>/
549
+ path_regex = /<path\s+.*?d\s*=\s*"([^"]+)"\s+(?:id\s*=\s*"(.*?)"\s+)?(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?fill\s*=\s*"(.*?)".*?\/>/
550
+
551
+ svg_content.scan(path_regex) do |d, id, stroke, stroke_width, fill|
552
+ id = id || 'path_id'
553
+ stroke = stroke || 'none'
554
+ stroke_width = stroke_width || '0'
555
+ fill = fill || 'none'
556
+ path_def = { path: { d: d, id: id, stroke: stroke, 'stroke-width' => stroke_width, fill: fill } }
557
+ atome_content << path_def
558
+ end
559
+
560
+ # rect_regex = /<rect\s+.*?id\s*=\s*"(.*?)"\s+(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?fill\s*=\s*"(.*?)"\s+x\s*=\s*"(\d+)"\s+y\s*=\s*"(\d+)"\s+width\s*=\s*"(\d+)"\s+height\s*=\s*"(\d+)".*?\/>/
561
+ rect_regex = /<rect\s+.*?id\s*=\s*"(.*?)"\s+(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?fill\s*=\s*"(.*?)"\s+x\s*=\s*"(\d+(?:\.\d+)?)"\s+y\s*=\s*"(\d+(?:\.\d+)?)"\s+width\s*=\s*"(\d+(?:\.\d+)?)"\s+height\s*=\s*"(\d+(?:\.\d+)?)"\s*.*?\/>/
562
+
563
+ svg_content.scan(rect_regex) do |id, stroke, stroke_width, fill, x, y, width, height|
564
+ id = id || 'rect_id'
565
+ stroke = stroke || 'none'
566
+ stroke_width = stroke_width || '0'
567
+ fill = fill || 'none'
568
+ rect_def = { rect: { x: x, y: y, width: width, height: height, id: id, stroke: stroke, 'stroke-width' => stroke_width, fill: fill } }
569
+ atome_content << rect_def
570
+ end
571
+
572
+ # line_regex = /<line\s+.*?id\s*=\s*"(.*?)"\s+(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?x1\s*=\s*"(\d+)"\s+y1\s*=\s*"(\d+)"\s+x2\s*=\s*"(\d+)"\s+y2\s*=\s*"(\d+)".*?\/>/
573
+ line_regex = /<line\s+.*?id\s*=\s*"(.*?)"\s+(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?x1\s*=\s*"(\d+(?:\.\d+)?)"\s+y1\s*=\s*"(\d+(?:\.\d+)?)"\s+x2\s*=\s*"(\d+(?:\.\d+)?)"\s+y2\s*=\s*"(\d+(?:\.\d+)?)"\s*.*?\/>/
574
+
575
+ svg_content.scan(line_regex) do |id, stroke, stroke_width, x1, y1, x2, y2|
576
+ id = id || 'line_id'
577
+ stroke = stroke || 'none'
578
+ stroke_width = stroke_width || '0'
579
+ line_def = { line: { x1: x1, y1: y1, x2: x2, y2: y2, id: id, stroke: stroke, 'stroke-width' => stroke_width } }
580
+ atome_content << line_def
581
+ end
582
+
583
+ # ellipse_regex = /<ellipse\s+.*?id\s*=\s*"(.*?)"\s+(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?fill\s*=\s*"(.*?)"\s+cx\s*=\s*"(\d+)"\s+cy\s*=\s*"(\d+)"\s+rx\s*=\s*"(\d+)"\s+ry\s*=\s*"(\d+)".*?\/>/
584
+ ellipse_regex = /<ellipse\s+.*?id\s*=\s*"(.*?)"\s+(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?fill\s*=\s*"(.*?)"\s+cx\s*=\s*"(\d+(?:\.\d+)?)"\s+cy\s*=\s*"(\d+(?:\.\d+)?)"\s+rx\s*=\s*"(\d+(?:\.\d+)?)"\s+ry\s*=\s*"(\d+(?:\.\d+)?)"\s*.*?\/>/
585
+
586
+ svg_content.scan(ellipse_regex) do |id, stroke, stroke_width, fill, cx, cy, rx, ry|
587
+ id = id || 'ellipse_id'
588
+ stroke = stroke || 'none'
589
+ stroke_width = stroke_width || '0'
590
+ fill = fill || 'none'
591
+ ellipse_def = { ellipse: { cx: cx, cy: cy, rx: rx, ry: ry, id: id, stroke: stroke, 'stroke-width' => stroke_width, fill: fill } }
592
+ atome_content << ellipse_def
593
+ end
594
+
595
+ # polygon_regex = /<polygon\s+(?:id\s*=\s*"(.*?)"\s+)?(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?(?:fill\s*=\s*"(.*?)"\s+)?points\s*=\s*"([^"]+)".*?\/>/
596
+ polygon_regex = /<polygon\s+(?:id\s*=\s*"(.*?)"\s+)?(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?(?:fill\s*=\s*"(.*?)"\s+)?points\s*=\s*"([^"]+)".*?\/>/
597
+ svg_content.scan(polygon_regex) do |id, stroke, stroke_width, fill, points|
598
+ id ||= 'polygon_id'
599
+ stroke ||= 'none'
600
+ stroke_width ||= '0'
601
+ fill ||= 'none'
602
+ polygon_def = { polygon: { points: points, id: id, stroke: stroke, 'stroke-width' => stroke_width, fill: fill } }
603
+ atome_content << polygon_def
604
+ end
605
+
606
+ polyline_regex = /<polyline\s+.*?points\s*=\s*"([^"]+)"\s+(?:id\s*=\s*"(.*?)"\s+)?(?:stroke\s*=\s*"(.*?)"\s+)?(?:stroke-width\s*=\s*"(.*?)"\s+)?(?:fill\s*=\s*"(.*?)")?.*?\/>/
607
+ svg_content.scan(polyline_regex) do |points, id, stroke, stroke_width, fill|
608
+ id ||= 'polyline_id'
609
+ stroke ||= 'none'
610
+ stroke_width ||= '0'
611
+ fill ||= 'none'
612
+ polyline_def = { polyline: { points: points, id: id, stroke: stroke, 'stroke-width' => stroke_width, fill: fill } }
613
+ atome_content << polyline_def
614
+ end
615
+
616
+ atome_content
617
+ end
618
+
619
+ def b64_to_tag(params)
620
+ unless params[:target]
621
+ new_img = image({ left: 0, top: 0 })
622
+ params[:target] = new_img.id
623
+ end
624
+ new_tag = <<STRR
625
+ var serializer = new XMLSerializer();
626
+ var svg_string = serializer.serializeToString(document.getElementById('#{params[:id]}'));
627
+ var encoded_svg = btoa(unescape(encodeURIComponent(svg_string)));
628
+ var img = document.getElementById('#{params[:target]}');
629
+ img.src = "data:image/svg+xml;base64," + encoded_svg;
630
+ var parent = document.getElementById('#{id}');
631
+ parent.appendChild(img);
632
+ STRR
633
+ JS.eval(new_tag)
634
+ new_atome = grab(params[:target])
635
+ html_obj = new_atome.html.object
636
+ obj_src = html_obj[:src]
637
+ new_atome.path(obj_src)
638
+ new_atome
639
+ end
494
640
 
641
+ def fetch_svg(params)
642
+ source = params[:source]
643
+ img_element = JS.global[:document].getElementById(source.to_s)
644
+ svg_path = img_element.getAttribute("src")
645
+ target = params[:target]
646
+ JS.eval("fetchSVGContent('#{svg_path}', '#{target}')")
647
+ end
495
648
 
496
649
  end
497
650
 
data/lib/atome/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  # return atome version
4
4
  class Atome
5
- VERSION = '0.5.6.8.7'
5
+ VERSION = '0.5.7.0.2'
6
6
  end
data/lib/atome.rb CHANGED
@@ -34,6 +34,7 @@ require 'renderers/html/index'
34
34
  require 'renderers/headless/index'
35
35
  require 'renderers/server/index'
36
36
  require 'atome/utilities/sanitizer'
37
+ require 'atome/genesis/presets'
37
38
  require 'atome/genesis/sparkle'
38
39
  require 'molecules/init'
39
40
  require 'molecules/intuition/utillities'
@@ -33,6 +33,7 @@ require_relative './renderers/html/index_relative'
33
33
  require_relative './renderers/headless/index_relative'
34
34
  require_relative './renderers/server/index_relative'
35
35
  require_relative './atome/utilities/sanitizer'
36
+ require_relative './atome/genesis/presets'
36
37
  require_relative './atome/genesis/sparkle'
37
38
  require_relative './molecules/init'
38
39
  require_relative './molecules/intuition/utillities'
@@ -1,48 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Molecule
4
- def new(params, &bloc)
5
- if params[:page]
6
- site_found = grab(params[:page][:application])
7
- site_found.clear(true)
8
- page_id = params[:page][:name]
9
- site_found.box({ id: page_id })
10
- elsif params[:application]
11
-
12
- footer_header_size=33
13
- footer_header_color=color({red: 0, green: 0, blue: 0, id: :footer_header_color})
14
-
15
- if params[:header]
16
- top = footer_header_size
17
- header=box({ left: 0, right: 0, width: :auto, top: 0, height: top, id: :header })
18
- # header.attach(:footer_header_color)
19
- else
20
- top = 0
21
- end
22
- if params[:footer]
23
- bottom = footer_header_size
24
- box({ left: 0, right: 0, width: :auto, top: :auto, bottom: 0, height: bottom, id: :footer })
25
- else
26
- bottom = 0
27
- end
28
- box({ left: 0, right: 0, width: :auto, top: top, bottom: bottom, height: :auto, id: params[:application] })
29
- elsif params[:module]
30
-
31
- end
32
- super if defined?(super)
33
- end
34
- end
35
-
36
- class Object
37
- include Molecule
38
- end
39
-
40
- # tests
41
- # new({application: :compose, header: true, footer: true })
42
- #
43
- # new(page: {name: :home, application: :compose, attach: :root })
44
- #
45
- # new(module: {name: :home, application: :compose, attach: :root })
4
+
5
+ end
6
+
7
+ class Object
8
+ include Molecule
9
+ # we add a getter for the molecule in standard ruby Object
10
+ # def molecule
11
+ # @molecule
12
+ # end
13
+ end
14
+
15
+ class Atome
16
+ include Molecule
17
+ end
18
+
19
+
20
+ # tests
21
+ # new({application: :compose, header: true, footer: true })
22
+ #
23
+ # new(page: {name: :home, application: :compose, attach: :root })
24
+ #
25
+ # new(module: {name: :home, application: :compose, attach: :root })
46
26
 
47
27
 
48
28
 
@@ -0,0 +1,111 @@
1
+ # # frozen_string_literal: true
2
+ #
3
+ # # def atome_common(atome_preset, params)
4
+ # # basic_params = { renderers: [] }
5
+ # # # TODO : remove Essentials.default_params[atome_preset] || {} as it is
6
+ # # # applied twice because preset is now a particle
7
+ # # preset_params = Essentials.default_params[atome_preset] || {}
8
+ # #
9
+ # # basic_params[:type] = preset_params[:type] || :element
10
+ # # basic_params[:id] = params[:id] || identity_generator(atome_preset)
11
+ # # basic_params[:renderers] = @renderers || preset_params[:renderers]
12
+ # # essential_params = basic_params.merge(preset_params)
13
+ # # reordered_params = essential_params.reject { |key, _| params.has_key?(key) }
14
+ # # params = reordered_params.merge(params)
15
+ # #
16
+ # # # condition to handle color/shadow/paint atomes that shouldn't be attach to view
17
+ # # # TODO : add category for atome( material/physical vs modifier : color, shadow, .. vs shape, image ..)
18
+ # # # then add condition same things fo code in genesis new_atome
19
+ # # if %i[color shadow paint].include?(atome_preset)
20
+ # # unless params[:affect]
21
+ # # params[:affect] = if @id == :view
22
+ # # [:black_matter]
23
+ # # else
24
+ # # [@id]
25
+ # # end
26
+ # # end
27
+ # # else
28
+ # # params[:attach] = params[:attach] || @id || :view
29
+ # # end
30
+ # # params
31
+ # # end
32
+ # #
33
+ # # def preset_common(params, &bloc)
34
+ # # # if an atome with current id exist we update the ID in the params
35
+ # # params[:id] = "#{params[:id]}_#{Universe.atomes.length}" if grab(params[:id])
36
+ # # Atome.new(params, &bloc)
37
+ # # end
38
+ # # class EVe < Atome
39
+ # class EVe < Atome
40
+ # def initialize
41
+ # @atomes = {}
42
+ # end
43
+ #
44
+ # def atome(atome_to_find)
45
+ # @atomes[atome_to_find]
46
+ # end
47
+ #
48
+ # def input_box(params = {}, &bloc)
49
+ # height_wanted = 15
50
+ # width_wanted = 222
51
+ # input_back = Atome.new(
52
+ # { renderers: [:html], id: :input_back, type: :shape, attach: :view, apply: [:shape_color],
53
+ # left: 120, top: 120,data: '', width: width_wanted, height: height_wanted + height_wanted * 20 / 100, smooth: 6 })
54
+ #
55
+ # @atomes[:input_back] = input_back
56
+ #
57
+ # Atome.new(
58
+ # { renderers: [:html], id: :input_text_color, type: :color, tag: ({ system: true, persistent: true }),
59
+ # red: 0.1, green: 0.1, blue: 0.1, alpha: 1 }
60
+ # )
61
+ #
62
+ # text_input = Atome.new(
63
+ # { renderers: [:html], id: :input_text, type: :text, apply: [:input_text_color], component: { size: height_wanted },
64
+ # data: :input, left: height_wanted * 20 / 100, top: 0, edit: true, attach: :input_back, height: height_wanted, position: :absolute })
65
+ #
66
+ # text_input.touch(true) do
67
+ # text_input.component({ selected: { color: 'rgba(0,0,0,0.3)', text: :orange } })
68
+ # end
69
+ #
70
+ # text_input.keyboard(:down) do |native_event|
71
+ # event = Native(native_event)
72
+ # if event[:keyCode].to_s == '13'
73
+ # # we prevent the input
74
+ # event.preventDefault()
75
+ # end
76
+ #
77
+ # end
78
+ #
79
+ # text_input.keyboard(:up) do |native_event|
80
+ # input_back.data=text_input.data
81
+ # end
82
+ # @atomes[:input_text] = text_input
83
+ #
84
+ # input_back
85
+ # end
86
+ #
87
+ # end
88
+ #
89
+ # def input(params = {}, &proc)
90
+ # text_color = :white
91
+ # text_size = 12
92
+ # back_color = :gray
93
+ # width = 2000
94
+ # in_b = EVe.new()
95
+ # in_b.input_box
96
+ # end
97
+ #
98
+ # i= input
99
+ #
100
+ # b=box({top: 0, left: 0, width: 33, height: 33})
101
+ # b.touch(true) do
102
+ # puts "i.data : #{i.data}"
103
+ # end
104
+ # i.left(66)
105
+ # i.color(:white)
106
+ # i.text.left(55)
107
+ #
108
+ #
109
+ #
110
+ #
111
+ #
@@ -118,11 +118,7 @@ new(molecule: :list) do |params, _bloc|
118
118
  attach_to = params[:attach] || default_parent
119
119
  renderer_found = grab(attach_to).renderers
120
120
  list = Atome.new({ renderers: renderer_found, id: new_id, type: :shape, color: { alpha: 0 }, attach: attach_to }.merge(params))
121
- # Atome.new(
122
- # { renderers: [:html], type: :shape, attach: :view, color: back_col,
123
- # left: 0, top: 0, data: '', attach: attach_to,
124
- # smooth: 6, overflow: :hidden,
125
- # })
121
+
126
122
  # now the listing
127
123
  listing.each_with_index do |data, index|
128
124
  # let's create the container
@@ -209,11 +205,11 @@ new({ molecule: :slider }) do |params, bloc|
209
205
 
210
206
  update_value = lambda do |cursor_position, cursor_size, slider_size, orientation|
211
207
  effective_slider_size = slider_size - cursor_size
212
- if orientation == :vertical
213
- percentage = 1.0 - (cursor_position.to_f / effective_slider_size)
214
- else
215
- percentage = cursor_position.to_f / effective_slider_size
216
- end
208
+ percentage = if orientation == :vertical
209
+ 1.0 - (cursor_position.to_f / effective_slider_size)
210
+ else
211
+ cursor_position.to_f / effective_slider_size
212
+ end
217
213
  value_range = max_value - min_value
218
214
  calculated_value = min_value + (value_range * percentage).round
219
215
  calculated_value.clamp(min_value, max_value)
@@ -302,7 +298,7 @@ new(molecule: :button) do |params, bloc|
302
298
 
303
299
  button.touch(:down) do
304
300
  button.tick(:button)
305
- bloc.call((button.tick[:button]-1) % states)
301
+ bloc.call((button.tick[:button] - 1) % states)
306
302
 
307
303
  end
308
304
 
@@ -312,3 +308,101 @@ new(molecule: :button) do |params, bloc|
312
308
 
313
309
  button
314
310
  end
311
+
312
+ new(molecule: :matrix) do |params, &bloc|
313
+ id = params[:id]
314
+ rows = params[:rows]
315
+ columns = params[:columns]
316
+ spacing = params[:spacing]
317
+ size = params[:size]
318
+
319
+ parent_found = self
320
+ current_matrix = group({ id: id })
321
+
322
+ current_matrix.data({ spacing: spacing, size: size })
323
+ matrix_cells = []
324
+ total_spacing_x = spacing * (rows + 1)
325
+ total_spacing_y = spacing * (columns + 1)
326
+ size_coefficient = if size.instance_of? String
327
+ size.end_with?('%') ? (size.to_f / 100) : size.to_f / parent_found.to_px(:width)
328
+ else
329
+ size.to_f / parent_found.to_px(:width)
330
+ end
331
+ view_width = parent_found.to_px(:width)
332
+ view_height = parent_found.to_px(:height)
333
+ matrix_back = box({ id: "#{id}_background", width: size, height: size, color: { alpha: 0 } })
334
+
335
+ if view_width > view_height
336
+ full_size=view_height * size_coefficient
337
+ available_width = full_size - total_spacing_x
338
+ available_height = full_size - total_spacing_y
339
+ matrix_back.width(full_size)
340
+ matrix_back.height(full_size)
341
+ else
342
+ full_size=view_width * size_coefficient
343
+ available_width = full_size - total_spacing_x
344
+ available_height = full_size - total_spacing_y
345
+ matrix_back.width(full_size)
346
+ matrix_back.height(full_size)
347
+ end
348
+ box_width = available_width / rows
349
+ box_height = available_height / columns
350
+
351
+ columns.times do |y|
352
+ rows.times do |x|
353
+ id_generated = "#{id}_#{x}_#{y}"
354
+ matrix_cells << id_generated
355
+ new_box = matrix_back.box({ id: id_generated })
356
+ new_box.width(box_width)
357
+ new_box.height(box_height)
358
+ new_box.left((box_width + spacing) * x + spacing)
359
+ new_box.top((box_height + spacing) * y + spacing)
360
+ end
361
+ end
362
+ current_matrix.collect(matrix_cells)
363
+ current_matrix
364
+ # end
365
+ end
366
+ new(molecule: :page) do |params, &bloc|
367
+
368
+ b = box({ color: :red, left: 99, drag: true })
369
+ b.text(params)
370
+ end
371
+
372
+ new(molecule: :application) do |params, &bloc|
373
+
374
+ main_page = box({ drag: true, width: :auto, height: :auto, top: 0, bottom: 0, left: 0, right: 0 })
375
+
376
+ main_page
377
+
378
+ # def new(params, &bloc)
379
+ # if params[:page]
380
+ # site_found = grab(params[:page][:application])
381
+ # site_found.clear(true)
382
+ # page_id = params[:page][:name]
383
+ # site_found.box({ id: page_id })
384
+ # elsif params[:application]
385
+ #
386
+ # footer_header_size = 33
387
+ # footer_header_color = color({ red: 0, green: 0, blue: 0, id: :footer_header_color })
388
+ #
389
+ # if params[:header]
390
+ # top = footer_header_size
391
+ # header = box({ left: 0, right: 0, width: :auto, top: 0, height: top, id: :header })
392
+ # # header.attach(:footer_header_color)
393
+ # else
394
+ # top = 0
395
+ # end
396
+ # if params[:footer]
397
+ # bottom = footer_header_size
398
+ # box({ left: 0, right: 0, width: :auto, top: :auto, bottom: 0, height: bottom, id: :footer })
399
+ # else
400
+ # bottom = 0
401
+ # end
402
+ # box({ left: 0, right: 0, width: :auto, top: top, bottom: bottom, height: :auto, id: params[:application] })
403
+ # elsif params[:module]
404
+ #
405
+ # end
406
+ # super if defined?(super)
407
+ # end
408
+ end
@@ -1,8 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  new({ method: :drag, type: :symbol, renderer: :html }) do |params|
4
- option = @drag[params]
5
- html.event(:drag, params, option)
4
+ # if @drag
5
+ # option = @drag[params]
6
+ # else
7
+ # params = :remove
8
+ # option = true
9
+ # end
10
+ # html.event(:drag, params, option)
11
+
12
+ if params
13
+ option = @drag[params]
14
+ html.event(:drag, params, option)
15
+ else
16
+ html.event(:drag, :remove, true)
17
+ end
6
18
  end
7
19
 
8
20
  new({ method: :drop, type: :symbol, renderer: :html }) do |params|
@@ -11,8 +23,12 @@ new({ method: :drop, type: :symbol, renderer: :html }) do |params|
11
23
  end
12
24
 
13
25
  new({ method: :touch, type: :integer, renderer: :html }) do |params|
14
- option = @touch[params]
15
- html.event(:touch, params, option)
26
+ if params
27
+ option = @touch[params]
28
+ html.event(:touch, params, option)
29
+ else
30
+ html.event(:touch, :remove, true)
31
+ end
16
32
  end
17
33
 
18
34
  new({ method: :over, type: :integer, renderer: :html }) do |params|