atome 0.5.6.4.5 → 0.5.6.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b69a163445e2951c51c54eb1b65684a98173f755e39df75e7d481d74c745174b
4
- data.tar.gz: 3fd395704a55b4944f183a596bd1decabc72cedff93f79bfb35efe7782d202d0
3
+ metadata.gz: 851b897d4aa5b30db58c4ac2b6b9cf7398e1dc478e6e66f2a0d9e5ab181ae999
4
+ data.tar.gz: e0c43d5d928acf4ece30d315227c759f070c5206ed4488b82e29f1565dcf906b
5
5
  SHA512:
6
- metadata.gz: a743dc6eee1c2f35c15a2b839c0eadb11b27c0829c2ac38fa281cf252a27066673509ea95d932e940f3a8997ccf92737f150033042a46b4a16b3a33bee303780
7
- data.tar.gz: 480441e90a518f5172dc60c82ea18331dfb95f828bb1e870654690848447e211824ab9fbe32abc5c07717d78375b1b200a7f3f74f66a6590b7fd5c78df209481
6
+ metadata.gz: a0b3f00737041ea0256b1955313f4c3ba462707558bb9459cd7cc39ccc7869692122c1edef2585eb69626c7a622329305fb01cbbe80fe7a11a2c489fce6a6a62
7
+ data.tar.gz: f7edd0ce4311f84b60ab3ef1e336a7a60ae3a215f09f93de1e1c41937b392e6a54206f0a6f71bca8c3bdcd79db2ce0b89eb2ed891af00e67d19bfbcef3eef368
data/lib/atome/atome.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  class Atome
5
5
  include Essentials
6
6
 
7
- def aid(_v=nil)
7
+ def aid(_v = nil)
8
8
  @aid
9
9
  end
10
10
 
@@ -22,36 +22,36 @@ class Atome
22
22
  # alert "atome found : #{ grab(new_atome[:id])}"
23
23
  # grab(new_atome[:id])
24
24
  # else
25
- # the keys :renderers, :type and :id should be placed in the first position in the hash
26
- @history = {}
27
- # @language = :english
28
- # @callback = {}
29
- @tag = {}
30
- @selected = false
31
- #@metrics = {}
25
+ # the keys :renderers, :type and :id should be placed in the first position in the hash
26
+ @history = {}
27
+ # @language = :english
28
+ # @callback = {}
29
+ @tag = {}
30
+ @selected = false
31
+ #@metrics = {}
32
32
  @unit = {}
33
- @apply = []
34
- @collect = {}
35
- @collect = {}
36
- @int8= {}
37
- @css = {}
38
- @aid = identity_generator
39
- Universe.add_to_atomes( @aid, self)
40
- @id = new_atome[:id] || @aid
41
- Universe.id_to_aid(@id,@aid)
42
- @type = new_atome[:type] || :element
43
- @attached = []
44
- @category = []
45
- # @display = { mode: :default }
46
- # @backup={} # mainly used to restore particle when using grid /table /list display mode
47
- @html = HTML.new(@id, self)
48
- @headless = Headless.new(@id, self)
49
- # now we store the proc in a an atome's property called :bloc
50
- new_atome[:code] = atomes_proc if atomes_proc
51
- # we reorder the hash
52
- reordered_atome =reorder_particles(new_atome)
53
- # FIXME : try to remove the condition below (it crash in the method : def generator ... in genesis.rb)
54
- collapse(reordered_atome)
33
+ @apply = []
34
+ @collect = {}
35
+ @int8 = {}
36
+ @css = {}
37
+ @aid = identity_generator
38
+ Universe.add_to_atomes(@aid, self)
39
+ @id = new_atome[:id] || @aid
40
+ Universe.id_to_aid(@id, @aid)
41
+ @type = new_atome[:type] || :element
42
+ @attached = []
43
+ @affect = []
44
+ @category = []
45
+ # @display = { mode: :default }
46
+ # @backup={} # mainly used to restore particle when using grid /table /list display mode
47
+ @html = HTML.new(@id, self)
48
+ @headless = Headless.new(@id, self)
49
+ # now we store the proc in a an atome's property called :bloc
50
+ new_atome[:code] = atomes_proc if atomes_proc
51
+ # we reorder the hash
52
+ reordered_atome = reorder_particles(new_atome)
53
+ # FIXME : try to remove the condition below (it crash in the method : def generator ... in genesis.rb)
54
+ collapse(reordered_atome)
55
55
  # end
56
56
 
57
57
  end
@@ -111,8 +111,8 @@ class Object
111
111
  ordered_part = ordered_keys.map { |k| [k, hash_to_reorder[k]] }.to_h
112
112
  other_part = hash_to_reorder.reject { |k, _| ordered_keys.include?(k) }
113
113
  # merge the parts to obtain an re-ordered hash
114
- reordered_hash = ordered_part.merge(other_part)
115
- reordered_hash
114
+ ordered_part.merge(other_part)
115
+ # reordered_hash
116
116
  end
117
117
 
118
118
  def delete (atomes)
@@ -120,8 +120,7 @@ class Object
120
120
  end
121
121
 
122
122
  def identity_generator
123
-
124
- "#{Universe.app_identity}_#{Universe.counter}".to_sym
123
+ "a_#{Universe.app_identity}_#{Universe.counter}".to_sym
125
124
  end
126
125
 
127
126
  def hook(a_id)
@@ -35,7 +35,8 @@ new({ sanitizer: :color }) do |params|
35
35
  params
36
36
  end
37
37
  # new({ post: :color }) do
38
- # Atome.global_monitoring(self, [:red, :blue, :blue, :alpha, :left, :right, :diffusion], [:variable1, :variable2])
38
+ #
39
+ # # Atome.global_monitoring(self, [:red, :blue, :blue, :alpha, :left, :right, :diffusion], [:variable1, :variable2])
39
40
  # end
40
41
  new({ atome: :image })
41
42
  new({ sanitizer: :image }) do |params|
@@ -54,7 +55,6 @@ new({ post: :image }) do
54
55
  instance_variable_set("@width", compute({ particle: :width })[:value])
55
56
  instance_variable_set("@height", compute({ particle: :height })[:value])
56
57
  end
57
-
58
58
  new({ atome: :video })
59
59
  new({ sanitizer: :video }) do |params|
60
60
  unless params.instance_of? Hash
@@ -75,6 +75,13 @@ new({ atome: :shadow }) do |params|
75
75
  end
76
76
  params
77
77
  end
78
+ new({ atome: :border }) do |params|
79
+ if params
80
+ attach_value = params.delete(:affect)
81
+ params[:affect] = attach_value
82
+ end
83
+ params
84
+ end
78
85
  new({ atome: :raw })
79
86
  new({ atome: :shape })
80
87
  new({ atome: :code })
@@ -117,7 +124,6 @@ end
117
124
  new({ atome: :machine })
118
125
  new({ atome: :paint })
119
126
  new({ atome: :vector })
120
-
121
127
  new({ atome: :matrix })
122
128
  new({ atome: :atomized, type: :hash })
123
129
 
@@ -100,7 +100,7 @@ class Genesis
100
100
 
101
101
  # we historicize all write action below
102
102
  # we add the changes to the stack that must be synchronised
103
- Universe.historicize(@id, :write, element, params)
103
+ Universe.historicize(@aid, :write, element, params)
104
104
  computed_params
105
105
  elsif params || params == false
106
106
  "send a valid password to write #{element} value"
@@ -150,7 +150,7 @@ class Genesis
150
150
  # end
151
151
  # TODO : add category for atome( material/physical vs modifier : color, shadow, .. vs shape, image ..)
152
152
  # then add condition same things fo code in presets/atome atome_common
153
- if %i[color shadow paint].include?(element)
153
+ if %i[color shadow paint border].include?(element)
154
154
  # we do the same for apply to be able to retrieve 'color' and other atome that apply instead of being attached
155
155
  @apply.each do |attached_atome|
156
156
  collected_atomes << attached_atome if grab(attached_atome).type.to_sym == element.to_sym
@@ -2,9 +2,13 @@
2
2
 
3
3
  new({ particle: :smooth, category: :effect, type: :int })
4
4
 
5
-
6
5
  new({ particle: :blur, category: :effect, type: :int }) do |params|
7
- # alert params
8
- { value: params, affect: :self } unless params.instance_of?(Hash)
9
- # params
10
- end
6
+ if affect.nil?
7
+ affect_to = affect
8
+ else
9
+ affect_to = [:self]
10
+ end
11
+ val= { value: params, affect: affect_to } unless params.instance_of?(Hash)
12
+ val
13
+ end
14
+
@@ -2,9 +2,9 @@
2
2
  def detach_child(child)
3
3
  return unless child.attach
4
4
 
5
- parent = grab(child.attach)
6
- parent.attached.delete(@id)
7
-
5
+ parent = grab(child.attach)
6
+ parent.attached.delete(@id)
7
+
8
8
  end
9
9
 
10
10
  # def detach_from_parent(parent_found, child_found)
@@ -50,14 +50,14 @@ new({ sanitizer: :attached }) do |children_ids|
50
50
  end
51
51
 
52
52
  new({ particle: :apply, category: :hierarchy, type: :string, render: false, store: false }) do |parents_ids, &user_proc|
53
- # TODO: optimize the 2 lines below:
54
- # html.reset_background
53
+
55
54
  @apply ||= []
56
55
  parents_ids = [parents_ids] unless parents_ids.instance_of?(Array)
57
56
  parents_ids.each do |parent_id|
58
57
  @apply.delete(parent_id)
59
58
  @apply << parent_id
60
59
  end
60
+ puts affect
61
61
  parents_ids = @apply
62
62
  children_ids = [id]
63
63
  parents_ids.each do |parent_id|
@@ -66,34 +66,27 @@ new({ particle: :apply, category: :hierarchy, type: :string, render: false, stor
66
66
  parent_found.instance_variable_set('@affect', []) unless parent_affect.instance_of? Array
67
67
  affect_element = parent_found.instance_variable_get('@affect')
68
68
  children_ids.each do |child_id|
69
- # affect_element << child_id unless affect_element.include?(child_id)
70
69
  affect_element.delete(child_id)
71
- # affect_element.push(child_id)
72
70
  affect_element << child_id
73
71
  child_found = grab(child_id)
74
72
  child_found&.render(:apply, parent_found, &user_proc)
75
73
  end
76
74
  end
77
75
  @apply = parents_ids
78
-
79
76
  parents_ids
80
77
  end
81
78
 
82
79
  new({ particle: :affect, category: :hierarchy, type: :string, render: false }) do |children_ids, &user_proc|
83
80
  children_ids = [children_ids] unless children_ids.instance_of? Array
84
81
  children_ids.each do |child_id|
85
- # params[:affect].each do |affected|
86
- # end
87
-
88
82
  child_found = grab(child_id)
89
- # alert "must exist : #{child_found.id}"
90
- # puts "correct condition below #{id}"
91
- #FIXME : found why it crash when removing the conditon below
83
+ # FIXME : found why it crash when removing the condition below
92
84
  unless child_found.id == :black_matter
93
- child_found.remove({all: :paint})
85
+ child_found.remove({ all: :paint })
94
86
  end
95
- child_found&.apply([id], &user_proc)
87
+ child_found.apply([id], &user_proc)
96
88
  end
89
+
97
90
  children_ids
98
91
  end
99
92
 
@@ -58,6 +58,10 @@ new({ post: :remove }) do |params|
58
58
  shadow.each do |atome_id_found|
59
59
  @apply.delete(atome_id_found)
60
60
  end
61
+ when :border
62
+ border.each do |atome_id_found|
63
+ @apply.delete(atome_id_found)
64
+ end
61
65
  else
62
66
  params.each do |particle, value|
63
67
  case particle
@@ -92,4 +96,7 @@ new({ sanitizer: :definition }) do |params|
92
96
  end
93
97
 
94
98
  new({ particle: :gradient, category: :material, type: :int })
95
- new({ particle: :border, category: :material, type: :int })
99
+
100
+ new({ particle: :thickness, category: :material, type: :int })
101
+ new({ particle: :pattern, category: :material, type: :string })
102
+ # new({ particle: :border, category: :material, type: :int })
@@ -7,24 +7,64 @@ def extract_rgb_alpha(color_string)
7
7
  blue = match_data[3].to_i
8
8
  alpha = match_data[4] ? match_data[4].to_f : nil
9
9
  { red: red, green: green, blue: blue, alpha: alpha }
10
+
10
11
  end
11
12
 
12
13
  new({ particle: :red, category: :property, type: :string }) do
14
+ # alert :ok
13
15
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
14
16
  self
15
17
  end
18
+ # FIXME we have to apply both at post and after to make it work
19
+ # used to refresh all affected atomes
20
+ new({after: :red}) do |params|
21
+ a=affect.dup # FIXME we have to dup else some items in the array array other duplicated
22
+ a.each do |atome_to_refresh|
23
+ grab(atome_to_refresh).apply(id)
24
+ end
25
+ params
26
+ end
27
+
28
+
16
29
  new({ particle: :green, category: :property, type: :string }) do
17
30
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
18
31
  self
19
32
  end
33
+
34
+ # used to refresh all affected atomes
35
+ new({after: :green}) do |params|
36
+ a=affect.dup # FIXME we have to dup else some items in the array array other duplicated
37
+ a.each do |atome_to_refresh|
38
+ grab(atome_to_refresh).apply(id)
39
+ end
40
+ params
41
+ end
42
+
20
43
  new({ particle: :blue, category: :property, type: :string }) do
21
44
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
22
45
  self
23
46
  end
47
+
48
+ # used to refresh all affected atomes
49
+ new({after: :blue}) do |params|
50
+ a=affect.dup # FIXME we have to dup else some items in the array array other duplicated
51
+ a.each do |atome_to_refresh|
52
+ grab(atome_to_refresh).apply(id)
53
+ end
54
+ params
55
+ end
24
56
  new({ particle: :alpha, category: :property, type: :string }) do
25
57
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
26
58
  self
27
59
  end
60
+ # used to refresh all affected atomes
61
+ new({after: :alpha}) do |params|
62
+ a=affect.dup # FIXME we have to dup else some items in the array array other duplicated
63
+ a.each do |atome_to_refresh|
64
+ grab(atome_to_refresh).apply(id)
65
+ end
66
+ params
67
+ end
28
68
  new({ particle: :diffusion, category: :property, type: :string }) do
29
69
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
30
70
  self
@@ -26,8 +26,52 @@ new ({ sanitizer: :password }) do |params|
26
26
  end
27
27
 
28
28
  new({ read: :password }) do |params|
29
- params = Black_matter.password if params.nil?
30
- params[:read][:atome] = Black_matter.password[:read][:atome] unless @authorisations[:write][:atome]
31
- params[:write][:atome] = Black_matter.password[:write][:atome] unless @authorisations[:write][:atome]
29
+ # TODO : check if we have to reactive the lines below
30
+ # params = Black_matter.password if params.nil?
31
+ # params[:read][:atome] = Black_matter.password[:read][:atome] unless @authorisations[:write][:atome]
32
+ # params[:write][:atome] = Black_matter.password[:write][:atome] unless @authorisations[:write][:atome]
33
+
32
34
  params
33
35
  end
36
+
37
+ # def get_all_local_storage_items
38
+ # Création d'un hash pour stocker les paires clé/valeur de localStorage
39
+ storage_items = {}
40
+
41
+ # Obtention du nombre d'éléments dans le localStorage
42
+ # storage= JS.global[:localStorage]
43
+ # # storage=storage.to_s
44
+ # storage_array= storage.to_a
45
+ # # alert storage_array.length
46
+ # storage_items={}
47
+ # storage_array.each_with_index do |_i, index|
48
+ # key = JS.global[:localStorage].key(index)
49
+ # #
50
+ # # # Récupération de la valeur associée à cette clé
51
+ # value = JS.global[:localStorage].getItem(key)
52
+ # #
53
+ # # # Stockage de la paire clé/valeur dans le hash
54
+ # storage_items[key] = value
55
+ # end
56
+ # puts storage_items
57
+
58
+ # alert Native(storage_length).class
59
+ # Itération sur tous les éléments de localStorage
60
+ # (0...storage_length).each do |i|
61
+ # # Récupération de la clé pour l'élément actuel
62
+ # key = JS.global[:localStorage].key(i)
63
+ #
64
+ # # Récupération de la valeur associée à cette clé
65
+ # value = JS.global[:localStorage].getItem(key)
66
+ #
67
+ # # Stockage de la paire clé/valeur dans le hash
68
+ # storage_items[key] = value
69
+ # end
70
+ #
71
+ # # Retour du hash contenant toutes les paires clé/valeur de localStorage
72
+ # storage_items
73
+ # end
74
+ #
75
+ # # Appel de la fonction pour récupérer et afficher le contenu de localStorage
76
+ # all_items = get_all_local_storage_items
77
+ # puts all_items
@@ -90,3 +90,9 @@ new({ particle: :center, category: :spatial, type: :hash }) do |params|
90
90
  params = { x: 0, y: 0, dynamic: true } if params == true
91
91
  params
92
92
  end
93
+ new ({ particle: :increment, category: :spatial, type: :hash }) do |params|
94
+ params.each do |particle, value|
95
+ prev_value=send(particle)
96
+ send(particle, value+prev_value)
97
+ end
98
+ end
@@ -3,7 +3,6 @@
3
3
  # now let's get the default render engine
4
4
 
5
5
  # Lets create the U.I.
6
-
7
6
  default_render = Essentials.default_params[:render_engines]
8
7
  Atome.new(
9
8
  { renderers: [], id: :eDen, type: :element, tag: { system: true } }
@@ -90,7 +89,8 @@ Atome.new({ renderers: default_render, id: machine_id, type: :machine, password:
90
89
  # user
91
90
  user_password = { global: :star_win, read: { atome: :star_wars }, write: { atome: :star_wars } }
92
91
 
93
- human({ id: :anonymous, login: true, password: user_password, data: { birthday: '10/05/1996' }, selection: [], attach: :user_view })
92
+ # human({ id: :anonymous, login: true, password: user_password, data: { birthday: '10/05/1996' }, selection: [], attach: :user_view })
93
+ human({ id: identity_generator, login: true, password: user_password, data: { birthday: '10/05/1996' }, selection: [], attach: :user_view })
94
94
 
95
95
  Universe.current_machine = machine_id
96
96
  # the constant A is used to access alla atomes methods
@@ -146,7 +146,7 @@ def atome_genesis
146
146
  end
147
147
  end
148
148
 
149
- def init_database # this method is call from JS (atome/communication)
149
+ def init_database # this method is call from JS (atome/communication) at WS connection
150
150
  # we init the db file eDen
151
151
  A.message({ action: :init_db, data: { database: :eDen } }) do |_db_state|
152
152
  end
@@ -184,6 +184,11 @@ def init_database # this method is call from JS (atome/communication)
184
184
  end
185
185
  end
186
186
 
187
+ # now we send localstorage content to the server
188
+ puts "now we send localstorage send_localstorage_content to the server"
189
+ send_localstorage_content
190
+ # A.message({ action: :localstorage, data: get_localstorage_content }) do |_db_state|
191
+ # end
187
192
  end
188
193
 
189
194
  def user_login
@@ -193,6 +198,7 @@ def user_login
193
198
  puts "email received : #{email}"
194
199
  end
195
200
  message({ action: :authorization, data: { password: password } }) do |pass|
196
- puts "password recieved : #{pass}"
201
+ puts "password received : #{pass}"
197
202
  end
198
203
  end
204
+ # Universe.allow_history=true
@@ -37,7 +37,8 @@ module Essentials
37
37
  apply: [:text_color],
38
38
  width: :auto, height: :auto, language: :english },
39
39
  drm: { type: :drm, attach: :black_matter },
40
- shadow: { type: :shadow, red: 0, green: 0, blue: 0, alpha: 0 },
40
+ shadow: { type: :shadow, red: 0, green: 0, blue: 0, alpha: 1, blur: 3, left: 3, top: 3 },
41
+ border: { type: :border, red: 0, green: 0, blue: 0, alpha: 0, pattern: :solid, thickness: 6 },
41
42
  color: { type: :color, red: 0, green: 0, blue: 0, alpha: 1}
42
43
  }
43
44
 
@@ -6,6 +6,22 @@ require 'json'
6
6
  class Atome
7
7
  class << self
8
8
 
9
+
10
+ def sync(params, &bloc)
11
+ alert :server_sync
12
+ # params = { data: params } unless params.instance_of? Hash
13
+ # # params[:user] = 'dfghg4df5gdfgh654'
14
+ # # params[:pass] = 'gfhkzrhgzr4h98948'
15
+ # # instance_variable_set('@message_code', {}) unless instance_variable_get('@message_code')
16
+ # # store_proc= instance_variable_get('@message_code')
17
+ # message_id= "msg_#{Universe.messages.length}"
18
+ # params[:message_id]=message_id
19
+ # # store_proc[mmessage_id]=bloc
20
+ # Universe.store_messages({msg_nb:message_id, proc: bloc })
21
+ # html.send_message(params)
22
+
23
+ end
24
+
9
25
  def file_handler(parent, content, bloc)
10
26
  grab(parent).instance_exec(content, &bloc)
11
27
  end
@@ -302,11 +318,16 @@ class Atome
302
318
  end
303
319
 
304
320
  def refresh
321
+ # we get the current color because they will be removed
322
+ # prev_color=color
323
+ # alert color.class
305
324
  particles_found = to_hash
306
325
  particles_found.each do |particle_found, value_found|
307
326
  send(particle_found, value_found)
308
327
  end
309
-
328
+ color.each do |col|
329
+ apply(col)
330
+ end
310
331
  end
311
332
 
312
333
  def each(&proc)
@@ -398,6 +419,56 @@ class Atome
398
419
  # Digest::SHA256.hexdigest(string)
399
420
  # end
400
421
  end
422
+ def get_localstorage_content
423
+ storage= JS.global[:localStorage]
424
+ storage_array= storage.to_a
425
+ storage_items={}
426
+ storage_array.each_with_index do |_i, index|
427
+ key = JS.global[:localStorage].key(index)
428
+ value = JS.global[:localStorage].getItem(key)
429
+ storage_items[key] = value
430
+ end
431
+ storage_items
432
+ end
433
+
434
+ def sanitize_data_for_json(data)
435
+ data=data.gsub('"', '\\"')
436
+ # case data
437
+ # when String
438
+ # data.gsub('"', '\\"')
439
+ # when Hash
440
+ # data.transform_values { |value| sanitize_data(value) }
441
+ # when Array
442
+ # data.map { |value| sanitize_data(value) }
443
+ # else
444
+ # data
445
+ # end
446
+ data
447
+ end
448
+
449
+ def send_localstorage_content
450
+ storage= JS.global[:localStorage]
451
+ storage_array= storage.to_a
452
+ # storage_items={}
453
+ storage_array.each_with_index do |_i, index|
454
+ key = JS.global[:localStorage].key(index)
455
+ value = sanitize_data_for_json(JS.global[:localStorage].getItem(key))
456
+ # storage_items[key] = value
457
+ # puts key
458
+ # puts value
459
+ # A.message({ action: :localstorage, data: {key => value} }) do |_db_state|
460
+ # # puts _db_state
461
+ # end
462
+ end
463
+ # A.message({ action: :end_localstorage, data: '' }) do |_db_state|
464
+ # puts _db_state
465
+ # end
466
+ end
467
+
468
+ def to_sym
469
+ puts "sanitizer temp patch when an atome is passed instead of an id"
470
+ @id
471
+ end
401
472
  end
402
473
 
403
474
 
@@ -11,17 +11,18 @@ class Universe
11
11
  @sanitizers = {}
12
12
  @specificities = {}
13
13
  @messages = {}
14
-
14
+ @increment=0
15
15
  @categories = %w[atome communication effect event geometry hierarchy identity material
16
16
  property security spatial time utility ]
17
17
  @history = {}
18
18
  @users = {}
19
19
  @help = {}
20
20
  @example = {}
21
-
21
+ @allow_history= false
22
+ # @historicize=false
22
23
  class << self
23
24
  attr_reader :atomes,:atomes_ids, :renderer_list, :atome_list, :particle_list, :classes, :counter, :atomes_specificities
24
-
25
+ attr_accessor :allow_history
25
26
  def messages
26
27
  @messages
27
28
  end
@@ -236,7 +237,13 @@ class Universe
236
237
  end
237
238
 
238
239
  def historicize(id, operation, element, params)
239
- @history[@history.length] = { id => { operation => { element => params } }, sync: false, time: Time.now }
240
+ if @allow_history
241
+ operation_timing= Time.now.strftime("%Y%m%d%H%M%S%3N")+@increment.to_s
242
+ @increment+=1
243
+ @increment=@increment%100
244
+ JS.global[:localStorage].setItem(operation_timing,"{ #{id} => { #{operation} => { #{element} => #{params} } }, sync: false }")
245
+ @history[@history.length] = { operation_timing => { id => { operation => { element => params } }, sync: false, time: Time.now } }
246
+ end
240
247
  end
241
248
 
242
249
  def story(filter)
@@ -26,7 +26,7 @@ class Atome
26
26
  # condition to handle color/shadow/paint atomes that shouldn't be attach to view
27
27
  # TODO : add category for atome( material/physical vs modifier : color, shadow, .. vs shape, image ..)
28
28
  # then add condition same things fo code in genesis new_atome
29
- if %i[color shadow paint].include?(atome_preset)
29
+ if %i[color shadow paint border].include?(atome_preset)
30
30
  unless params[:affect]
31
31
  params[:affect] = if @id == :view
32
32
  [:black_matter]
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.4.5'
5
+ VERSION = '0.5.6.5.1'
6
6
  end
@@ -21,9 +21,31 @@ new({ renderer: :html, method: :smooth, type: :string }) do |value, _user_proc|
21
21
  end
22
22
 
23
23
  new({ renderer: :html, method: :blur, type: :integer }) do |params, _user_proc|
24
- if params[:affect] == :back
24
+ if params[:affect] == :back || params[:affect] == :back
25
25
  html.backdropFilter(:blur, "#{params[:value]}px")
26
26
  else
27
27
  html.filter(:blur, "#{params[:value]}px")
28
28
  end
29
29
  end
30
+
31
+
32
+ new({ renderer: :html, method: :blur, type: :integer, specific: :shadow }) do |params, _user_proc|
33
+ if params[:affect] == :back
34
+ html.backdropFilter(:blur, "#{params[:value]}px")
35
+ else
36
+ html.filter(:blur, "#{params[:value]}px")
37
+ end
38
+ # now we refresh if needed for dynamic refresh od affected atomes
39
+ affect(affect)
40
+ end
41
+
42
+ # new({ particle: :blur, category: :effect, type: :int , specific: :shadow}) do |params|
43
+ # alert :cool
44
+ # if affect.nil?
45
+ # affect_to = affect
46
+ # else
47
+ # affect_to = [:self]
48
+ # end
49
+ # val= { value: params, affect: affect_to } unless params.instance_of?(Hash)
50
+ # val
51
+ # end
@@ -38,7 +38,6 @@ new({ renderer: :html, method: :apply, type: :string }) do |parent_found, _user_
38
38
  alpha = parent_found.alpha
39
39
  html.style(:backgroundColor, "rgba(#{red}, #{green}, #{blue}, #{alpha})")
40
40
  when :paint
41
-
42
41
  # if when found colors when use it for the gradient , else whe use the colors within the current atome
43
42
  # gradient_found = params[:colors] || @apply
44
43
  # we get all the paint atomes applied to the current atome
@@ -75,6 +74,17 @@ new({ renderer: :html, method: :apply, type: :string }) do |parent_found, _user_
75
74
  # full_gradient_to_apply=gradients_to_apply.join(',')
76
75
  full_gradient_to_apply = gradients_to_apply.last
77
76
  html.style(:background, full_gradient_to_apply)
77
+ when :border
78
+ border.each do |border_id_found|
79
+ border_found = grab(border_id_found)
80
+ red = border_found.red * 255
81
+ green = border_found.green * 255
82
+ blue = border_found.blue * 255
83
+ alpha = border_found.alpha
84
+ thickness = border_found.thickness
85
+ pattern = border_found.pattern
86
+ html.style(:border, "#{pattern} #{thickness}px rgba(#{red},#{green},#{blue},#{alpha})")
87
+ end
78
88
  else
79
89
  #
80
90
  end
@@ -93,7 +103,7 @@ new({ renderer: :html, method: :apply, type: :string, specific: :text }) do |par
93
103
  alpha = shadow_found.alpha
94
104
  left = shadow_found.left
95
105
  top = shadow_found.top
96
- blur = shadow_found.blur
106
+ blur = shadow_found.blur[:value] # new correct behavior all atome's value should now be get using :value,here to resolve conflict with blur and back blur
97
107
  inset = :inset if shadow_found.invert
98
108
  if shadow_found.option == :natural
99
109
  shadows_to_apply[:filter] << "drop-shadow(#{left}px #{top}px #{blur}px rgba(#{red}, #{green}, #{blue}, #{alpha}))"
@@ -1450,21 +1450,24 @@ class HTML
1450
1450
  when :all
1451
1451
  case v
1452
1452
  when :paint
1453
- style(:background, 'black')
1453
+ style(:background, 'none')
1454
1454
  # style('box-shadow', 'none')
1455
1455
  # style('text-shadow', 'none')
1456
1456
  when :color
1457
1457
  when :shadow
1458
1458
  style('box-shadow', 'none')
1459
1459
  style('text-shadow', 'none')
1460
+ style("filter", 'none')
1460
1461
  end
1461
1462
  end
1462
1463
  end
1463
1464
  else
1464
1465
  @original_atome.apply.delete(params)
1465
- style(:background, 'black')
1466
+ style(:background, 'none')
1466
1467
  style('box-shadow', 'none')
1467
1468
  style('text-shadow', 'none')
1469
+ style("boxShadow", 'none')
1470
+ style("filter", 'none')
1468
1471
  @original_atome.apply(@original_atome.apply)
1469
1472
  end
1470
1473
  # alert "remove : #{params} , type: #{@original_atome.type}"
@@ -52,16 +52,32 @@ new({ method: :remove, renderer: :html, type: :string }) do |object_id_to_remove
52
52
  end
53
53
  end
54
54
 
55
+ # new({ method: :border, type: :hash, renderer: :html }) do |value, _user_proc|
56
+ # thickness = value[:thickness] || 5
57
+ # type = value[:pattern] || :solid
58
+ #
59
+ # if value[:color].instance_of? Atome
60
+ # color_found = value[:color]
61
+ # else
62
+ # color_found = grab('black_matter').color(value[:color])
63
+ # end
64
+ #
65
+ # red = color_found.red * 255
66
+ # green = color_found.green * 255
67
+ # blue = color_found.blue * 255
68
+ # alpha = color_found.alpha
69
+ #
70
+ # html.style(:border, "#{type} #{thickness}px rgba(#{red},#{green},#{blue},#{alpha})")
71
+ # end
72
+ new({ method: :thickness, type: :integer, renderer: :html}) do |params|
73
+ # now we refresh if needed for dynamic refresh od affected atomes
74
+ # html.style(:border, "#{type} #{thickness}px rgba(#{red},#{green},#{blue},#{alpha})")
75
+ affect(affect)
76
+ end
55
77
 
56
- new({ method: :border, type: :hash, renderer: :html }) do |value, _user_proc|
57
- thickness = value[:thickness] || 5
58
- type = value[:pattern] || :solid
59
- color = if value[:color]
60
- color_found = value[:color]
61
- "#{color_found.red * 255},#{color_found.green * 255},#{color_found.blue * 255},#{color_found.alpha} "
62
- else
63
- "0,0,0,1"
64
- end
65
-
66
- html.style(:border, "#{type} #{thickness}px rgba(#{color})")
78
+ # end
79
+ new({ method: :pattern, type: :integer, renderer: :html}) do |params|
80
+ # now we refresh if needed for dynamic refresh od affected atomes
81
+ # html.style(:border, "#{type} #{thickness}px rgba(#{red},#{green},#{blue},#{alpha})")
82
+ affect(affect)
67
83
  end
@@ -22,33 +22,6 @@ new({ renderer: :html, method: :edit }) do |params|
22
22
  html.update_data(params)
23
23
  end
24
24
 
25
- new({ method: :border, type: :hash, renderer: :html }) do |value, _user_proc|
26
- thickness = value[:thickness] || 5
27
- type = value[:pattern] || :solid
28
- # color = if value[:color]
29
- # color_found = value[:color]
30
- # "#{color_found.red * 255},#{color_found.green * 255},#{color_found.blue * 255},#{color_found.alpha} "
31
- # else
32
- # "0,0,0,1"
33
- # end
34
- if value[:color].instance_of? Atome
35
- color_found= value[:color]
36
- else
37
- color_found=grab('black_matter').color(value[:color])
38
- end
39
-
40
- # alert "atome found 2 : #{color_found}"
41
- red = color_found.red* 255
42
- green = color_found.green* 255
43
- blue = color_found.blue* 255
44
- alpha = color_found.alpha
45
- # alert "rgba(#{red},#{green},#{blue},#{alpha})"
46
- # color_found= "#{1 * 255},#{color_found.green * 255},#{0 * 255},#{0.3} "
47
-
48
- html.style(:border, "#{type} #{thickness}px rgba(#{red},#{green},#{blue},#{alpha})")
49
- # html.style(:border, "#{type} #{thickness}px rgba(#{color_found})")
50
- # html.style(:border, "solid 12px rgba(255, 255, 120, 0,3)")
51
- end
52
25
 
53
26
  new({ method: :clean, renderer: :html, type: :hash }) do |params|
54
27
  html.table_clean(params)
@@ -9,6 +9,7 @@ new({ method: :top, type: :integer, renderer: :html }) do |params|
9
9
  unit = @unit[:top] || :px if params.is_a? Numeric
10
10
  js[:style][:top] = "#{params}#{unit}"
11
11
  end
12
+
12
13
  new({ method: :bottom, type: :integer, renderer: :html }) do |params|
13
14
  unit = @unit[:bottom] || :px if params.is_a? Numeric
14
15
  js[:style][:bottom] = "#{params}#{unit}"
@@ -20,7 +21,10 @@ new({ method: :right, type: :integer, renderer: :html }) do |params|
20
21
  js[:style][:right] = "#{params}#{unit}"
21
22
  end
22
23
 
23
- new({ method: :top, type: :integer, renderer: :html, specific: :shadow })
24
+ new({ method: :top, type: :integer, renderer: :html, specific: :shadow }) do
25
+ # now we refresh if needed for dynamic refresh od affected atomes
26
+ affect(affect)
27
+ end
24
28
 
25
29
  # new({ method: :top, type: :integer, renderer: :html, specific: :text }) do |params|
26
30
  # unit = @unit[:left] || :px
@@ -33,7 +37,10 @@ new({ method: :top, type: :integer, renderer: :html, specific: :shadow })
33
37
 
34
38
  new({ method: :left, type: :integer, specific: :color, renderer: :html })
35
39
 
36
- new({ method: :left, type: :integer, renderer: :html, specific: :shadow })
40
+ new({ method: :left, type: :integer, renderer: :html, specific: :shadow }) do
41
+ # now we refresh if needed for dynamic refresh od affected atomes
42
+ affect(affect)
43
+ end
37
44
 
38
45
  new({ method: :top, type: :integer, specific: :color, renderer: :html })
39
46
 
@@ -1,6 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ b=circle({left: 333})
4
+ b.blur(6)
3
5
 
6
+ image(:red_planet)
7
+ b2=box({color: {alpha: 0.1, red: 1, green: 0, blue: 0.2}, left: 99, top: 99, width: 99, height: 99})
8
+ b2.drag(true)
9
+ b2.border({ thickness: 0.3, color: :gray, pattern: :solid })
10
+ b2.smooth(12)
11
+ b2.shadow({
12
+ invert: true,
13
+ id: :s4,
14
+ left: 2, top: 2, blur: 9,
15
+ # option: :natural,
16
+ red: 0, green: 0, blue: 0, alpha: 0.3
17
+ })
4
18
 
5
- b=circle
6
- b.blur(20)
19
+ b2.shadow({
20
+ # invert: true,
21
+ id: :s5,
22
+ left: 2, top: 2, blur: 9,
23
+ # option: :natural,
24
+ red: 0, green: 0, blue: 0, alpha: 0.6
25
+ })
26
+ b2.blur({affect: :back, value: 15})
@@ -1,28 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
-
4
- col=color({red: 1, green: 0.2, id: :the_col})
5
- c=circle
6
- b=box({left: 333})
7
- c2=circle({top: 190, width: 99, height: 99})
3
+ # col=color({red: 1, green: 0.2, id: :the_col})
4
+ c = circle({ id: :the_circle })
5
+ b = box({ left: 333, id: :the_box })
6
+ c2 = circle({ top: 190, width: 99, height: 99, id: :dont_break })
8
7
  # let's add the border
9
- c2.border({ thickness: 5, color: :blue, pattern: :dotted })
10
- c.border({ thickness: 5, color: col, pattern: :dotted })
11
- b.border({ thickness: 5, color: col, pattern: :dotted })
12
-
13
8
  wait 1 do
14
- c2.border({ thickness: 5, color: :green, pattern: :dotted })
15
- c.border({ thickness: 5, color: :green, pattern: :dotted })
16
- b.border({ thickness: 5, color: :green, pattern: :dotted })
9
+ c2.shadow({
10
+ # id: :s1,
11
+ # affect: [:the_circle],
12
+ left: 9,
13
+ top: 3,
14
+ blur: 9,
15
+ invert: false,
16
+ red: 0, green: 0, blue: 0, alpha: 1
17
+ })
18
+ c2.border({ thickness: 5, red: 1, green: 0, blue: 0, alpha: 1, pattern: :dotted, id: :borderline })
17
19
  end
20
+ c.border({ thickness: 5, red: 1, green: 1, blue: 0, alpha: 1, pattern: :dotted })
21
+ b.border({ thickness: 5, red: 0, green: 1, blue: 0, alpha: 1, pattern: :dotted })
18
22
 
23
+ wait 2 do
24
+ c2.border({ thickness: 5, red: 1, green: 1, blue: 0, alpha: 1, pattern: :solid })
25
+ c.border({ thickness: 5, red: 1, green: 1, blue: 0, alpha: 1, pattern: :dotted })
26
+ b.border({ thickness: 3, red: 1, green: 1, blue: 0, alpha: 1, pattern: :dotted })
27
+ end
28
+ #
19
29
  b.touch(true) do
20
30
 
21
- b.border({ thickness: 5, color: { red: 1, green: 0 }, pattern: :dotted })
22
- puts " no new atome added!, number of atomes: #{Universe.atomes.length}"
31
+ b.border({ thickness: 5, red: 1, green: 1, blue: 1, alpha: 1, pattern: :dotted, id: :the_door })
32
+ puts " no new atome added!, number of atomes: #{Universe.atomes.length}"
33
+ b.apply([:the_door])
34
+ c.apply([:the_door])
35
+ c2.apply([:the_door])
36
+ wait 3 do
37
+ # if the_door (border) is change all affect atomes are refreshed
38
+ grab(:the_door).red(0)
39
+ grab(:the_door).thickness(20)
40
+ grab(:the_door).pattern(:solid)
41
+ end
23
42
  end
43
+
24
44
  # wait 6 do
25
- # iamge(:red_planet)
45
+ # image(:red_planet)
26
46
  # end
27
47
 
28
48
  # # frozen_string_literal: true
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # see import for drag and drop import
3
4
  b = box({ drag: true })
4
5
  b.import(true) do |content|
5
6
  puts "add code here, content: #{content}"
@@ -36,4 +36,5 @@ the_text.left(333)
36
36
 
37
37
  the_text.paint({ gradient: [col_1.id, col_2.id], direction: :left , id: :painted_love })
38
38
 
39
+ # #TODO : gradient on text!
39
40
 
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ cc=color({red: 1, blue: 0.1,id: :the_col})
4
+ b=box({ left: 12, id: :the_first_box, apply: cc.id })
5
+ c=circle({ left: 99, top: 99 })
6
+
7
+ wait 1 do
8
+ c.increment({left: 33, top: 99})
9
+ b.increment({left: 33, top: 99})
10
+ wait 1 do
11
+ c.increment({width: 33, top: -22})
12
+ b.increment({width: 33, top: -9})
13
+ cc.increment({red: -0.5})
14
+ wait 1 do
15
+ cc.increment({blue: 1})
16
+ end
17
+ # Atome.sync(:ok)
18
+ end
19
+ end
20
+
21
+ # wait 3 do
22
+ # color(:red)
23
+ # end
@@ -22,12 +22,12 @@ def matrix(id, horizontal_nb, vertical_nb, spacing, size)
22
22
  end
23
23
  box_width = available_width / horizontal_nb
24
24
  box_height = available_height / vertical_nb
25
-
25
+ background=box({id: :background, width: 666, height: 666, color:{alpha: 0}})
26
26
  vertical_nb.times do |y|
27
27
  horizontal_nb.times do |x|
28
28
  id_generated = "#{id}_#{x}_#{y}"
29
29
  matrix_cells << id_generated
30
- new_box = box({ id: id_generated })
30
+ new_box = background.box({ id: id_generated })
31
31
  new_box.width(box_width)
32
32
  new_box.height(box_height)
33
33
  new_box.left((box_width + spacing) * x + spacing)
@@ -121,21 +121,33 @@ module Molecule
121
121
 
122
122
  end
123
123
  end
124
-
124
+ c= circle({left: 399})
125
125
  test_cell.touch(true) do
126
- alert :ok
127
126
  test_cell.alternate([{ width: 33, color: :red }, { width: 66, color: :orange }])
128
127
  # puts "=> #{Universe.atomes.length}"
129
128
  # puts test_cell.color
130
129
  # if test_cell.data==true
131
130
  # test_cell.data(false)
132
- col_1 = color(:black)
133
- test_cell.paint({ gradient: [col_1, col_1], direction: :left })
134
- grab(:red_col).delete(true)
135
- test_cell.color(:green)
131
+ # col_1 = color(:black)
132
+
133
+ @current_matrix.paint({ gradient: [col_1.id, col_1.id], direction: :top })
134
+ other_col=test_cell.color(:white)
135
+ c.paint({ gradient: [col_1, col_2], direction: :left })
136
+ test_cell.paint({ gradient: [col_1, other_col], direction: :left })
137
+ # test_cell
138
+ # grab(:red_col).delete(true)
139
+ # test_cell.color(:green)
136
140
  # else
137
141
  # test_cell.data(true)
138
142
  # test_cell.color(:blue)
139
143
  # end
140
144
 
141
- end
145
+ end
146
+ wait 1 do
147
+ @current_matrix.width(33)
148
+ end
149
+ @current_matrix.drag(true)
150
+ wait 2 do
151
+ grab(:background).left(666)
152
+ grab(:background).drag(true)
153
+ end
@@ -34,14 +34,27 @@ wait 2 do
34
34
  end
35
35
 
36
36
 
37
- the_text = text({ data: 'hello for al the people in front of their machine', center: true, top: 222, width: 777, component: { size: 66 } })
38
-
37
+ the_text = text({ data: 'text with shadow!', center: true, top: 222, width: 777, component: { size: 66 }, id: :my_text })
39
38
 
40
39
 
41
40
  the_text.shadow({
42
- id: :s4,
43
- left: 20, top: 0, blur: 9,
41
+ id: :my_shadow,
42
+ left: 6, top: 6, blur: 6,
44
43
  option: :natural,
45
- red: 0, green: 1, blue: 0, alpha: 1
44
+ red: 0, green: 0, blue: 0, alpha: 1
46
45
  })
47
46
 
47
+ the_text.left(255)
48
+ the_text.top(66)
49
+ the_text.color(:red)
50
+
51
+ wait 1 do
52
+ text_shadow= grab(:my_shadow)
53
+ text_shadow.alpha(0.5)
54
+ text_shadow.left(120)
55
+ text_shadow.blur({ value: 1 })
56
+
57
+ # grab(:my_text).refresh(true)
58
+
59
+ end
60
+
@@ -78,6 +78,13 @@ class EDen
78
78
  end
79
79
  end
80
80
 
81
+ def localstorage(data, message_id)
82
+ # return test
83
+ # ws.send(return_message.to_json)
84
+ return { return: 'localstorage content received', authorized: true, message_id: message_id }
85
+
86
+ end
87
+
81
88
  def init_db(_data, message_id)
82
89
  unless File.exist?("eden.sqlite3")
83
90
  Sequel.connect("sqlite://eden.sqlite3")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6.4.5
4
+ version: 0.5.6.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Eric Godard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-29 00:00:00.000000000 Z
11
+ date: 2024-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: artoo
@@ -568,6 +568,7 @@ files:
568
568
  - vendor/assets/application/examples/hypertext.rb
569
569
  - vendor/assets/application/examples/image.rb
570
570
  - vendor/assets/application/examples/import.rb
571
+ - vendor/assets/application/examples/increment.rb
571
572
  - vendor/assets/application/examples/infos.rb
572
573
  - vendor/assets/application/examples/int8.rb
573
574
  - vendor/assets/application/examples/keyboard.rb