atome 0.5.3.2 → 0.5.3.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +8 -3
  3. data/app_builder_helpers/Rakefile +9 -3
  4. data/exe/atome +11 -18
  5. data/lib/atome/atome.rb +29 -19
  6. data/lib/atome/extensions/atome.rb +23 -1
  7. data/lib/atome/extensions/matrix.rb +71 -63
  8. data/lib/atome/genesis/generators/atome.rb +149 -22
  9. data/lib/atome/genesis/generators/effect.rb +8 -3
  10. data/lib/atome/genesis/generators/event.rb +77 -34
  11. data/lib/atome/genesis/generators/geometry.rb +21 -5
  12. data/lib/atome/genesis/generators/identity.rb +110 -57
  13. data/lib/atome/genesis/generators/material.rb +74 -16
  14. data/lib/atome/genesis/generators/spatial.rb +8 -9
  15. data/lib/atome/genesis/generators/time.rb +1 -1
  16. data/lib/atome/genesis/generators/utility.rb +66 -39
  17. data/lib/atome/genesis/genesis.rb +7 -5
  18. data/lib/atome/genesis/sparkle.rb +8 -2
  19. data/lib/atome/helpers/essentials.rb +2 -6
  20. data/lib/atome/helpers/utilities.rb +15 -0
  21. data/lib/atome/kernel/universe.rb +2 -2
  22. data/lib/atome/presets/atome.rb +60 -61
  23. data/lib/atome/renderers/browser/event.rb +6 -3
  24. data/lib/atome/renderers/browser/geometry.rb +18 -10
  25. data/lib/atome/renderers/browser/helpers/browser_helper.rb +9 -0
  26. data/lib/atome/renderers/browser/helpers/color_helper.rb +4 -4
  27. data/lib/atome/renderers/browser/helpers/event_helper.rb +24 -12
  28. data/lib/atome/renderers/browser/helpers/shape_helper.rb +4 -4
  29. data/lib/atome/renderers/browser/helpers/text_helper.rb +4 -4
  30. data/lib/atome/renderers/browser/helpers/video_helper.rb +1 -1
  31. data/lib/atome/renderers/browser/helpers/web_helper.rb +4 -4
  32. data/lib/atome/renderers/browser/identity.rb +4 -0
  33. data/lib/atome/renderers/browser/material.rb +20 -1
  34. data/lib/atome/renderers/browser/spatial.rb +4 -0
  35. data/lib/atome/version.rb +1 -1
  36. data/sig/atome.rbs +12 -0
  37. data/sig/genesis.rbs +3 -0
  38. data/vendor/assets/application/index.rb +2 -0
  39. data/vendor/assets/src/index.html +1 -1
  40. data/vendor/assets/src/js/atome/atome.js +2 -1
  41. data/vendor/assets/src/medias/images/icons/email.svg +13 -0
  42. data/vendor/assets/src/medias/images/icons/mail_gray.svg +6 -0
  43. data/vendor/assets/src/medias/images/icons/mail_green.svg +6 -0
  44. data/vendor/assets/src/medias/images/icons/mail_orange.svg +6 -0
  45. data/vendor/assets/src/medias/images/icons/undo.svg +4 -0
  46. data/vendor/assets/src/medias/images/logos/Orange/Facebook.svg +8 -0
  47. data/vendor/assets/src/medias/images/logos/Orange/TikTok.svg +11 -0
  48. data/vendor/assets/src/medias/images/logos/Orange/Twitter.svg +8 -0
  49. data/vendor/assets/src/medias/images/logos/Orange/instagram.svg +8 -0
  50. data/vendor/assets/src/medias/images/logos/Orange/vimeo.svg +8 -0
  51. data/vendor/assets/src/medias/images/logos/Orange/youtube.svg +7 -0
  52. data/vendor/assets/src/medias/images/logos/gray/Facebook.svg +8 -0
  53. data/vendor/assets/src/medias/images/logos/gray/TikTok.svg +11 -0
  54. data/vendor/assets/src/medias/images/logos/gray/Twitter.svg +8 -0
  55. data/vendor/assets/src/medias/images/logos/gray/instagram.svg +8 -0
  56. data/vendor/assets/src/medias/images/logos/gray/vimeo.svg +8 -0
  57. data/vendor/assets/src/medias/images/logos/gray/youtube.svg +7 -0
  58. data/vendor/assets/src/medias/images/logos/gray/youtube2.svg +13 -0
  59. data/vendor/assets/src/medias/images/logos/vimeo.svg +17 -0
  60. data/vendor/assets/src/medias/rubies/examples/_table2.rb +108 -0
  61. data/vendor/assets/src/medias/rubies/examples/add.rb +1 -3
  62. data/vendor/assets/src/medias/rubies/examples/attached.rb +16 -0
  63. data/vendor/assets/src/medias/rubies/examples/class.rb +13 -0
  64. data/vendor/assets/src/medias/rubies/examples/code.rb +1 -1
  65. data/vendor/assets/src/medias/rubies/examples/depth.rb +6 -0
  66. data/vendor/assets/src/medias/rubies/examples/detached.rb +13 -0
  67. data/vendor/assets/src/medias/rubies/examples/matrix.rb +1 -1
  68. data/vendor/assets/src/medias/rubies/examples/opacity.rb +5 -0
  69. data/vendor/assets/src/medias/rubies/examples/over.rb +19 -0
  70. data/vendor/assets/src/medias/rubies/examples/read.rb +1 -0
  71. data/vendor/assets/src/medias/rubies/examples/schedule.rb +5 -2
  72. data/vendor/assets/src/medias/rubies/examples/text.rb +12 -11
  73. data/vendor/assets/src/medias/rubies/examples/time.rb +5 -1
  74. metadata +31 -10
  75. data/vendor/assets/src/medias/images/cache.svg +0 -10
  76. data/vendor/assets/src/medias/images/eyes.jpg +0 -0
  77. data/vendor/assets/src/medias/images/killer.jpg +0 -0
  78. data/vendor/assets/src/medias/images/logos/GitHub-Mark.eps +0 -7696
  79. data/vendor/assets/src/medias/images/poisson.jpg +0 -0
  80. data/vendor/assets/src/medias/images/sky.jpg +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3b3eb14241b108a8fff26a1d336211199a4cf7a133069e399383f8c590be948
4
- data.tar.gz: 4bab390e92b2b65a180a2537902ca68bbb7a78faed8debf8cbf2e05063647b7f
3
+ metadata.gz: 949a07eee4e8a4e64c796c8c03b4f38ce5e8681db043ae498dc0d6dd1f48ab8f
4
+ data.tar.gz: 32816c3ee8e8ad508f87e49ea84213df1ed3d486f9a162d82d0f14f0ad71dd71
5
5
  SHA512:
6
- metadata.gz: 71670c634ee463c0de14a00749d760174831029b1c6e45df1cb4fd6101ea51f083ff4c895d35a93de28a472bb63feb40ee23cd5c27d12f56571f62e6276654e6
7
- data.tar.gz: def487b5d20de25b4c112d65d850d94a454651750dfc240a329128b3cfbd42088bb391c29667f7de65297da2ed65bda55dea446ff436580bd3195891818c7947
6
+ metadata.gz: 5c1f9a2bf45e6094d76aa2574361958b9a8e40c2a76c1ad60fd48a8e15823898c949a37198757387af509fbe5ec61a1c3ff8d88adf51b5a69ccf5d435bad7605
7
+ data.tar.gz: 31c7c58e7cd2512875a71d3d65318a318737138a376a7169e3998d3a33e3f5a94ce80fcbbeec36f71234da4bf091dbd2c3e696320f8aa6755682ae2829273764
data/Rakefile CHANGED
@@ -26,7 +26,8 @@ task :run_browser do
26
26
  FileUtils.copy_entry('vendor/assets/src/css/', 'test/test_app/src/css/')
27
27
  FileUtils.copy_entry('vendor/assets/src/medias/', 'test/test_app/src/medias/')
28
28
  `gem cleanup atome;yes | gem uninstall atome ;gem build atome.gemspec;gem install atome`
29
- `cd test/test_app;atome update;atome run`
29
+ `cd test/test_app;atome update;atome run compile`
30
+ puts 'atome browser is running'
30
31
  end
31
32
 
32
33
 
@@ -55,12 +56,16 @@ end
55
56
 
56
57
  task :run_example_server do
57
58
  FileUtils.copy_entry('vendor/assets/src/medias/rubies/examples/', 'test/test_app/src/medias/rubies/examples/')
58
- `cd test/test_app;atome run server `
59
+ `cd test/test_app;atome run server`
59
60
  end
60
61
 
61
62
 
62
63
  task :taurification do
63
- `cd test/test_app;cargo tauri dev `
64
+ `cd test/test_app;cargo tauri dev`
65
+ end
66
+
67
+ task :osx do
68
+ `cd test/test_app;atome run osx guard`
64
69
  end
65
70
 
66
71
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  require 'opal'
6
6
  # require 'opal-jquery'
7
- require 'opal-browser'
7
+ require 'atome-opal-browser'
8
8
  require 'parser'
9
9
  # require 'ruby2js'
10
10
  require 'uglifier'
@@ -57,10 +57,16 @@ def build_aui(user_project_path)
57
57
  end
58
58
 
59
59
  def copy_assets_files(user_project_path, gem_location)
60
- build_location = "#{gem_location}/../vendor/assets/src/"
60
+ # build_location = "#{gem_location}/../vendor/assets/src/"
61
61
  server_location = "#{gem_location}/../vendor/assets/server/"
62
- FileUtils.copy_entry build_location, "#{user_project_path}/src", preserve: nil
63
62
  FileUtils.copy_entry server_location, "#{user_project_path}/server", preserve: nil
63
+ # FileUtils.copy_entry build_location, "#{user_project_path}/src", preserve: nil
64
+ css_location ="#{gem_location}/../vendor/assets/src/css/"
65
+ FileUtils.copy_entry css_location, "#{user_project_path}/src/css", preserve: nil
66
+ js_location ="#{gem_location}/../vendor/assets/src/js/"
67
+ FileUtils.copy_entry js_location, "#{user_project_path}/src/js", preserve: nil
68
+ index_location ="#{gem_location}/../vendor/assets/src/index.html"
69
+ FileUtils.copy_entry index_location, "#{user_project_path}/src/index.html", preserve: nil
64
70
  end
65
71
 
66
72
  def build_atome_kernel(user_project_path, gem_location)
data/exe/atome CHANGED
@@ -117,22 +117,27 @@ end
117
117
 
118
118
  def guard_check
119
119
  loop do
120
- sleep 3
120
+ sleep 1
121
121
  end
122
122
  nil unless ARGV.include?('guard')
123
123
  end
124
124
 
125
125
  def browser_case(location)
126
- `cd #{location}/src;open index.html`
126
+ # `cd #{location}/src;open index.html`
127
127
  guard_check
128
128
  end
129
129
 
130
+ #
131
+
132
+ def osx_case(location)
133
+ `cd #{location};cargo tauri dev`
134
+ end
135
+
130
136
  def compile_case(location)
131
137
  `cd #{location}/src`
132
138
  guard_check
133
139
  end
134
140
 
135
-
136
141
  def server_case(port, location)
137
142
  threads = []
138
143
  threads << Thread.new do
@@ -142,32 +147,20 @@ def server_case(port, location)
142
147
  `cd #{location}/server;rackup --server puma --port #{port} --env production`
143
148
  end
144
149
 
145
- def test_native(build_target)
146
- case build_target
147
- when :freebsd
148
- # freebsd
149
- when :osx
150
- # osx
151
- when :windows
152
- # windows
153
- else
154
- # freebsd
155
- end
156
- end
157
-
158
150
  def run_case(build_target, location, port)
159
151
  case build_target
160
152
  when :server
161
153
  server_case(port, location)
162
154
  when :browser
163
155
  browser_case(location)
156
+ when :osx
157
+ osx_case(location)
164
158
  when :compile
165
159
  compile_case(location)
166
160
  when :native
167
- test_native(build_target)
168
161
  # freebsd
169
162
  else
170
- browser_case(location)
163
+ guard_check
171
164
  end
172
165
  end
173
166
 
data/lib/atome/atome.rb CHANGED
@@ -8,7 +8,6 @@
8
8
  class Atome
9
9
  # TODO : clean or delete @private_atome
10
10
  include Essentials
11
-
12
11
  private
13
12
 
14
13
  def initialize(atomes = {}, &atomes_proc)
@@ -27,13 +26,13 @@ class Atome
27
26
  end
28
27
  end
29
28
 
30
- def new_particle(element,store,render, &method_proc)
29
+ def new_particle(element, store, render, &method_proc)
31
30
  Atome.define_method element do |params = nil, &user_proc|
32
31
  if params || params == false
33
32
  # the line below execute the proc created when using the build_particle method
34
33
  instance_exec(params, user_proc, &method_proc) if method_proc.is_a?(Proc)
35
34
  params = sanitize(element, params)
36
- create_particle(element,store,render)
35
+ create_particle(element, store, render)
37
36
  send("set_#{element}", params, &user_proc)
38
37
  else
39
38
  get_particle(element, &user_proc)
@@ -41,25 +40,37 @@ class Atome
41
40
  end
42
41
  end
43
42
 
44
-
45
-
46
- def additional_particle_methods(element,store,render , &method_proc)
43
+ def additional_particle_methods(element, store, render, &method_proc)
47
44
  Atome.define_method "#{element}=" do |params = nil, &user_proc|
48
45
  instance_exec(params, user_proc, &method_proc) if method_proc.is_a?(Proc)
49
46
  params = sanitize(element, params)
50
- particle_creation(element, params, store,render,&user_proc)
47
+ particle_creation(element, params, store, render, &user_proc)
51
48
  end
52
49
  end
53
50
 
54
-
55
51
  def atome_creation_pre_treatment(element, params, &user_proc)
56
52
  params = sanitize(element, params)
57
53
  create_atome(element)
58
54
  send("set_#{element}", params, &user_proc)
59
55
  end
60
56
 
57
+ def atome_initializer(element, params = {})
58
+ temp_default = Essentials.default_params[element] || {}
59
+ generated_render = params[:renderers] || []
60
+ generated_id = params[:id] || "#{element}_#{Universe.atomes.length}"
61
+ generated_parents = params[:parents] || [id.value]
62
+ generated_children = params[:children] || []
63
+ temp_default[:id] = generated_id
64
+ temp_default[:parents] = generated_parents
65
+ temp_default[:clones] = []
66
+ temp_default[:renderers] = generated_render
67
+ temp_default[:children] = generated_children
68
+ temp_default.merge(params)
69
+ end
70
+
61
71
  def new_atome(element, &method_proc)
62
72
  Atome.define_method element do |params = nil, &user_proc|
73
+
63
74
  if params
64
75
  instance_exec(params, user_proc, &method_proc) if method_proc.is_a?(Proc)
65
76
  atome_creation_pre_treatment(element, params, &user_proc)
@@ -78,14 +89,13 @@ class Atome
78
89
  end
79
90
 
80
91
  def run_optional_proc(proc_name, atome = self, element, &user_proc)
81
- params=instance_variable_get("@#{element}")
92
+ params = instance_variable_get("@#{element}")
82
93
  option_found = Universe.get_optional_method(proc_name)
83
94
  atome.instance_exec(params, user_proc, atome, &option_found) if option_found.is_a?(Proc)
84
95
  end
85
96
 
86
-
87
97
  def store_value(element)
88
- params=instance_variable_get("@#{element}")
98
+ params = instance_variable_get("@#{element}")
89
99
  @atome[element] = params
90
100
  end
91
101
 
@@ -93,14 +103,15 @@ class Atome
93
103
 
94
104
  # the line below is used for ephemera atomes
95
105
  attr_accessor :property, :value, :real_atome, :user_proc
96
- attr_reader :atome, :structure#, :at_time
106
+ attr_reader :atome, :structure # , :at_time
97
107
 
98
108
  def set(value)
99
109
  @real_atome[@property] = value
100
110
  end
101
111
 
102
- def particle_creation(element, params,store,render, &user_proc)
112
+ def particle_creation(element, params, store, render, &user_proc)
103
113
  return false unless security_pass(element, params)
114
+
104
115
  # we create a proc holder of any new particle if user pass a bloc
105
116
  store_code_bloc(element, &user_proc) if user_proc
106
117
  # Params is now an instance variable so it should be passed thru different methods
@@ -115,14 +126,12 @@ class Atome
115
126
  self
116
127
  end
117
128
 
118
-
119
- def create_particle(element,store,render)
129
+ def create_particle(element, store, render)
120
130
  Atome.define_method "set_#{element}" do |params, &user_proc|
121
- particle_creation(element, params, store,render,&user_proc)
131
+ particle_creation(element, params, store, render, &user_proc)
122
132
  end
123
133
  end
124
134
 
125
-
126
135
  def get(element)
127
136
  @atome[element]
128
137
  end
@@ -133,8 +142,8 @@ class Atome
133
142
  virtual_atome.real_atome = @atome
134
143
  virtual_atome.property = element
135
144
  virtual_atome.user_proc = user_proc
136
- run_optional_proc("pre_get_#{@atome[:type]}".to_sym, "virtual_atome", &user_proc)
137
- run_optional_proc("pre_get_#{element}".to_sym, self, "virtual_atome", &user_proc)
145
+ # run_optional_proc("pre_get_#{@atome[:type]}".to_sym, 'virtual_atome', &user_proc)
146
+ # run_optional_proc("pre_get_#{element}".to_sym, self, 'virtual_atome', &user_proc)
138
147
  virtual_atome
139
148
  end
140
149
 
@@ -145,6 +154,7 @@ class Atome
145
154
  virtual_atome.user_proc = user_proc
146
155
  virtual_atome.value = @atome[element]
147
156
  virtual_atome
157
+ "it should contain the atome not : #{element}"
148
158
  end
149
159
 
150
160
  def create_atome(new_atome)
@@ -1,4 +1,24 @@
1
1
  # frozen_string_literal: true
2
+ def new(params, &bloc)
3
+ generator = Genesis.generator
4
+ if params.key?(:particle)
5
+ # render indicate if the particle needs to be rendered
6
+ # store tell the system if it need to store the particle value
7
+ # type help the system what type of type the particle will receive and store
8
+ generator.build_particle(params[:particle], { render: params[:render],
9
+ store: params[:store], type: params[:type] }, &bloc)
10
+ elsif params.key?(:atome)
11
+ generator.build_atome(params[:atome], &bloc)
12
+ elsif params.key?(:sanitizer)
13
+ generator.build_sanitizer(params[:sanitizer], &bloc)
14
+ elsif params.key?(:pre)
15
+ generator.build_option("pre_render_#{params[:pre]}", &bloc)
16
+ elsif params.key?(:post)
17
+ generator.build_option("post_render_#{params[:post]}", &bloc)
18
+ elsif params.key?(:browser)
19
+ generator.build_render("browser_#{params[:browser]}", &bloc)
20
+ end
21
+ end
2
22
 
3
23
  def grab(atome_to_get)
4
24
  Universe.atomes[atome_to_get]
@@ -18,7 +38,9 @@ end
18
38
 
19
39
  # the method below generate Atome method creation at Object level
20
40
  def create_method_at_object_level(element)
21
- Object.define_method element do |params = nil, &user_proc|
41
+
42
+ Object.define_method element do |params, &user_proc|
22
43
  grab(:view).send(element, params, &user_proc)
23
44
  end
45
+
24
46
  end
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
+ #
2
3
 
3
- class Atome
4
+ module Matrix
4
5
  def content(items = nil)
5
- if items.instance_of?(Array)
6
+ if items.instance_of?(Array)
6
7
  items.each do |item|
7
8
  content(item)
8
9
  end
@@ -19,18 +20,17 @@ class Atome
19
20
  @cell_content ||= {}
20
21
  @cell_content[i_found] = { width_ratio: 1, height_ratio: 1, top_ratio: 1, left_ratio: 1 }
21
22
  # alert @cell_content
22
- items.parents([self.id])
23
+ items.parents([id])
23
24
  else
24
25
  @cell_content
25
26
  end
26
-
27
27
  end
28
28
 
29
29
  def cells(cell_nb)
30
30
  collector_object = collector({})
31
31
  collected_atomes = []
32
32
  cell_nb.each do |cell_found|
33
- atome_found = grab ("#{id}_#{cell_found}")
33
+ atome_found = grab("#{id}_#{cell_found}")
34
34
  collected_atomes << atome_found
35
35
  end
36
36
  collector_object.data(collected_atomes)
@@ -38,8 +38,7 @@ class Atome
38
38
  end
39
39
 
40
40
  def cell(cell_nb)
41
- cell_found = grab ("#{id}_#{cell_nb}")
42
- cell_found
41
+ grab("#{id}_#{cell_nb}")
43
42
  end
44
43
 
45
44
  def columns(column_requested, &proc)
@@ -81,7 +80,7 @@ class Atome
81
80
  cells_to_alter = cells_in_column[value[0]..value[1]]
82
81
  cells_to_alter.each_with_index do |cell_nb, index|
83
82
  current_cell = grab("#{id.value}_#{cell_nb}")
84
- if index == 0
83
+ if index.zero?
85
84
  current_cell.height(cell_height * cells_to_alter.length + @margin * (cells_to_alter.length - 1))
86
85
  else
87
86
  current_cell.hide(true)
@@ -97,7 +96,7 @@ class Atome
97
96
 
98
97
  cells_to_alter.each_with_index do |cell_nb, index|
99
98
  current_cell = grab("#{id.value}_#{cell_nb}")
100
- if index == 0
99
+ if index.zero?
101
100
  current_cell.width(cell_width * cells_to_alter.length + @margin * (cells_to_alter.length - 1))
102
101
  else
103
102
  current_cell.hide(true)
@@ -105,7 +104,6 @@ class Atome
105
104
  end
106
105
  end
107
106
  end
108
-
109
107
  end
110
108
 
111
109
  def divide(params)
@@ -141,7 +139,6 @@ class Atome
141
139
  end
142
140
  end
143
141
  end
144
-
145
142
  end
146
143
 
147
144
  # def override(params)
@@ -168,7 +165,7 @@ class Atome
168
165
  def format_matrix(matrix_id, matrix_width, matrix_height, nb_of_rows, nb_of_cols, margin, exceptions = {})
169
166
  cell_width = (matrix_width - margin * (nb_of_cols + 1)) / nb_of_cols
170
167
  cell_height = (matrix_height - margin * (nb_of_rows + 1)) / nb_of_rows
171
- ratio=cell_height/cell_width
168
+ ratio = cell_height / cell_width
172
169
  i = 0
173
170
  nb_of_rows.times do |row_index|
174
171
  nb_of_cols.times do |col_index|
@@ -176,14 +173,14 @@ class Atome
176
173
  x = (col_index + 1) * margin + col_index * cell_width
177
174
  y = (row_index + 1) * margin + row_index * cell_height
178
175
  current_cell = grab("#{matrix_id}_#{i}")
179
- puts "===> #{current_cell}"
176
+ # puts "===> #{current_cell}"
180
177
  current_cell.children.each do |child|
181
- puts "=>#{cell_width}"
182
- grab(child).width(cell_width)
183
- grab(child).height(cell_width)
178
+ # puts "=>#{cell_width}"
179
+ grab(child).width(cell_width) if grab(child)
180
+ grab(child).height(cell_width) if grab(child)
184
181
  end
185
- current_cell.width= cell_width
186
- current_cell.height= cell_height
182
+ current_cell.width = cell_width
183
+ current_cell.height = cell_height
187
184
  current_cell.left(x)
188
185
  current_cell.top(y)
189
186
  i += 1
@@ -194,43 +191,52 @@ class Atome
194
191
 
195
192
  number_of_cells = nb_of_rows * nb_of_cols
196
193
  # columns exceptions
197
- if exceptions
198
- fusion({ columns: exceptions[:columns_fusion] }) if exceptions[:columns_fusion]
199
- fusion({ rows: exceptions[:rows_fusion] }) if exceptions[:rows_fusion]
200
- divide({ columns: exceptions[:columns_divided] }) if exceptions[:columns_divided]
201
- divide({ rows: exceptions[:rows_divided] }) if exceptions[:rows_divided]
202
- end
194
+ return unless exceptions
203
195
 
196
+ fusion({ columns: exceptions[:columns_fusion] }) if exceptions[:columns_fusion]
197
+ fusion({ rows: exceptions[:rows_fusion] }) if exceptions[:rows_fusion]
198
+ divide({ columns: exceptions[:columns_divided] }) if exceptions[:columns_divided]
199
+ divide({ rows: exceptions[:rows_divided] }) if exceptions[:rows_divided]
204
200
  end
205
201
 
206
202
  def apply_style(current_cell, style)
207
203
  current_cell.set(style)
208
204
  end
205
+ def matrix_sanitizer(params)
206
+ default_params = {
209
207
 
208
+ id: :my_table, left: 33, top: 33, width: 369, height: 369, smooth: 8, color: :gray,
209
+ columns: { count: 4 },
210
+ rows: { count: 4 },
211
+ cells: { particles: { margin: 9, color: :lightgray, smooth: 9, shadow: { blur: 9, left: 3, top: 3 } }
212
+ }
213
+ }
214
+ default_params.merge(params)
215
+ end
210
216
  def matrix(params = {}, &bloc)
211
-
212
- if params[:columns]
213
- columns_data = params.delete(:columns)
214
- else
215
- columns_data= { count: 4 }
216
- end
217
-
218
- if params[:rows]
219
- rows_data = params.delete(:rows)
220
- else
221
- rows_data= { count: 4 }
222
- end
223
-
224
- if params[:cells]
225
- cells_data = params.delete(:cells)
226
- else
227
- cells_data= { particles: { margin: 9, color: :lightgray } }
228
- end
229
- cells_color=cells_data[:particles].delete(:color)
230
- cells_color_id= color(cells_color).id.value
231
-
232
- cells_shadow=cells_data[:particles].delete(:shadow)
233
- cells_shadow_id= shadow(cells_shadow).id.value
217
+ params= matrix_sanitizer(params)
218
+ columns_data = if params[:columns]
219
+ params.delete(:columns)
220
+ else
221
+ { count: 4 }
222
+ end
223
+
224
+ rows_data = if params[:rows]
225
+ params.delete(:rows)
226
+ else
227
+ { count: 4 }
228
+ end
229
+
230
+ cells_data = if params[:cells]
231
+ params.delete(:cells)
232
+ else
233
+ { particles: { margin: 9, color: :lightgray } }
234
+ end
235
+ cells_color = cells_data[:particles].delete(:color)
236
+ cells_color_id = color(cells_color).id.value
237
+
238
+ cells_shadow = cells_data[:particles].delete(:shadow)
239
+ cells_shadow_id = shadow(cells_shadow).id.value
234
240
 
235
241
  exceptions_data = params.delete(:exceptions)
236
242
  default_renderer = Essentials.default_params[:render_engines]
@@ -251,12 +257,12 @@ class Atome
251
257
  columns = columns_data[:count]
252
258
  rows = rows_data[:count]
253
259
  margin = cells_data[:particles].delete(:margin)
254
- the_matrix.instance_variable_set("@columns", columns)
255
- the_matrix.instance_variable_set("@rows", rows)
256
- the_matrix.instance_variable_set("@margin", margin)
257
- the_matrix.instance_variable_set("@cell_style", cells_data[:particles])
258
- the_matrix.instance_variable_set("@matrix_width", matrix_width)
259
- the_matrix.instance_variable_set("@matrix_height", matrix_height)
260
+ the_matrix.instance_variable_set('@columns', columns)
261
+ the_matrix.instance_variable_set('@rows', rows)
262
+ the_matrix.instance_variable_set('@margin', margin)
263
+ the_matrix.instance_variable_set('@cell_style', cells_data[:particles])
264
+ the_matrix.instance_variable_set('@matrix_width', matrix_width)
265
+ the_matrix.instance_variable_set('@matrix_height', matrix_height)
260
266
 
261
267
  rows = rows_data[:count]
262
268
  columns = columns_data[:count]
@@ -279,7 +285,6 @@ class Atome
279
285
  columns_divided: columns_divided_exceptions,
280
286
  rows_fusion: rows_fusion_exceptions,
281
287
  rows_divided: rows_divided_exceptions }
282
- the_matrix.instance_variable_set("@exceptions", exceptions)
283
288
  # @exceptions = {
284
289
  # columns_fusion: columns_fusion_exceptions,
285
290
  # columns_divided: columns_divided_exceptions,
@@ -291,9 +296,8 @@ class Atome
291
296
  columns_fusion: {},
292
297
  columns_divided: {},
293
298
  rows_fusion: {},
294
- rows_divided: {},
299
+ rows_divided: {}
295
300
  }
296
- the_matrix.instance_variable_set("@exceptions", exceptions)
297
301
  # @exceptions = {
298
302
  # columns_fusion: {},
299
303
  # columns_divided: {},
@@ -301,6 +305,7 @@ class Atome
301
305
  # rows_divided: {},
302
306
  # }
303
307
  end
308
+ the_matrix.instance_variable_set('@exceptions', exceptions)
304
309
 
305
310
  # let's create the matrix background
306
311
  # current_matrix = grab(:view).box({ id: matrix_id })
@@ -310,7 +315,7 @@ class Atome
310
315
  number_of_cells = rows * columns
311
316
  number_of_cells.times do |index|
312
317
  current_cell = grab(matrix_id).box({ id: "#{matrix_id}_#{index}" })
313
- the_matrix.instance_variable_set("@cell_style", cells_data[:particles])
318
+ the_matrix.instance_variable_set('@cell_style', cells_data[:particles])
314
319
  current_cell.attached([cells_shadow_id])
315
320
  current_cell.attached([cells_color_id])
316
321
  apply_style(current_cell, cells_data[:particles])
@@ -330,10 +335,10 @@ class Atome
330
335
  # puts index
331
336
  #
332
337
  end
333
- current_cell = self.box({ id: "#{id}_#{index}" })
338
+ current_cell = box({ id: "#{id}_#{index}" })
334
339
  apply_style(current_cell, @cell_style)
335
340
  end
336
- @columns = @columns + nb
341
+ @columns += nb
337
342
  ########## old algo
338
343
  # nb_of_cells_to_adds = nb * @rows
339
344
  # prev_nb_of_cells = @columns * @rows
@@ -355,10 +360,10 @@ class Atome
355
360
  # puts index
356
361
  #
357
362
  end
358
- current_cell = self.box({ id: "#{id}_#{index}" })
363
+ current_cell = box({ id: "#{id}_#{index}" })
359
364
  apply_style(current_cell, @cell_style)
360
365
  end
361
- @rows = @rows + nb
366
+ @rows += nb
362
367
  ########## old algo
363
368
  # nb_of_cells_to_adds = nb * @columns
364
369
  # prev_nb_of_cells = @columns * @rows
@@ -387,12 +392,15 @@ class Atome
387
392
  (0...num_rows).each do |row|
388
393
  result << (index + row * num_columns)
389
394
  end
390
- return result
395
+ result
391
396
  else
392
397
  start_index = index * num_columns
393
398
  end_index = start_index + num_columns - 1
394
- return (start_index..end_index).to_a
399
+ (start_index..end_index).to_a
395
400
  end
396
401
  end
402
+ end
397
403
 
404
+ class Atome
405
+ include Matrix
398
406
  end