atome 0.5.7.1.4 → 0.5.7.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,14 +45,14 @@ class HTML
45
45
  def add_font_to_css(params)
46
46
  font_path = params[:path]
47
47
  font_name = params[:name]
48
- str_to_eval = <<STRDELIM
49
- var styleSheet = document.styleSheets[0];
50
- styleSheet.insertRule(`
51
- @font-face {
52
- font-family: '#{font_name}';
53
- src: url('../medias/fonts/#{font_path}/#{font_name}.ttf') format('truetype');
54
- }`, styleSheet.cssRules.length);
55
- STRDELIM
48
+ str_to_eval = <<~STRDELIM
49
+ var styleSheet = document.styleSheets[0];
50
+ styleSheet.insertRule(`
51
+ @font-face {
52
+ font-family: '#{font_name}';
53
+ src: url('../medias/fonts/#{font_path}/#{font_name}.ttf') format('truetype');
54
+ }`, styleSheet.cssRules.length);
55
+ STRDELIM
56
56
  JS.eval(str_to_eval)
57
57
  end
58
58
 
@@ -1303,37 +1303,30 @@ STRDELIM
1303
1303
  end
1304
1304
  end
1305
1305
 
1306
+
1306
1307
  # animation below
1307
1308
  def animate(animation_properties)
1308
- command = <<~JS
1309
- var target_div = document.getElementById('#{@id}');
1310
- window.currentAnimation = popmotion.animate({
1311
- from: #{animation_properties[:from]},
1312
- to: #{animation_properties[:to]},
1313
- duration: #{animation_properties[:duration]},
1314
- onUpdate: function(v) {
1315
- atomeJsToRuby("puts x= "+v)
1316
- atomeJsToRuby("grab('#{@id}').left("+v+")")
1317
- },
1318
- onComplete: function() {
1319
- window.currentAnimation = null;
1320
- atomeJsToRuby("puts :complete")
1321
- }
1322
- });
1309
+ prop= animation_properties[:particle]
1310
+ command = <<~JS
1311
+ var target_div = document.getElementById('#{@id}');
1312
+ window.currentAnimation = popmotion.animate({
1313
+ from: #{animation_properties[ :from]},
1314
+ to: #{animation_properties[:to]},
1315
+ duration: #{animation_properties[:duration]},
1316
+ onUpdate: function(v) {
1317
+ atomeJsToRuby("grab('#{@id}').animation_callback('#{prop}', "+v+")")
1318
+ atomeJsToRuby("grab('#{@id}').#{prop}("+v+")")
1319
+ },
1320
+ onComplete: function(v) {
1321
+ window.currentAnimation = null;
1322
+ atomeJsToRuby("grab('#{@id}').animation_callback('#{prop}_end')")
1323
+ }
1324
+ });
1323
1325
  JS
1324
1326
  JS.eval(command)
1325
1327
  end
1326
1328
 
1327
- def play_animation(properties)
1328
- puts 'change for standard method : action'
1329
- required_keys = [:from, :to, :duration]
1330
- unless properties.is_a?(Hash) && (required_keys - properties.keys).empty?
1331
- raise ArgumentError, 'Properties must be a hash with :from, :to, and :duration keys'
1332
- end
1333
-
1334
- animate(properties)
1335
1329
 
1336
- end
1337
1330
 
1338
1331
  def stop_animation
1339
1332
  JS.eval('if (window.currentAnimation) window.currentAnimation.stop();')
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ b=box
4
+ margin = 12
5
+ b2=box({top: below(b, margin)})
6
+ b3=box({top: below(b2, margin)})
7
+ b4=box({top: below(b3, margin)})
8
+ box({top: below(b4, margin)})
9
+ i=0
10
+ while i< 10 do
11
+ b2=box({top: below(b, margin)})
12
+ i+=1
13
+ end
14
+
15
+ b = circle(left: 66)
16
+ margin = 12
17
+ i = 0
18
+
19
+ while i < 10 do
20
+ b = circle({top: below(b, margin), left: 66})
21
+ i += 1
22
+ end
@@ -87,5 +87,33 @@
87
87
 
88
88
  b=box({id: :the_box})
89
89
 
90
- b.animate({ to: 90 })
90
+ b.animate({ to: 333, particle: :width, duration: 3000}) do |val|
91
+ puts "width +#{val}"
92
+ end
93
+
94
+ b.animate({ to: 456, particle: :left, duration: 5000}) do |val|
95
+ puts "left +#{val}"
96
+ end
97
+
98
+ b.animate({ end: :left}) do |val|
99
+ puts "left ended"
100
+ end
101
+
102
+ b.animate({ to: 69, particle: :smooth, duration: 10000}) do |val|
103
+ puts "smooth +#{val}"
104
+ end
105
+
106
+ b.animate({ end: :smooth}) do |val|
107
+ puts " cool smooth end now!!!"
108
+ end
109
+
110
+ b.animate({ to: 90, particle: :rotate, duration: 10000}) do |val|
111
+ puts "rotate +#{val}"
112
+ end
113
+
114
+ b.animate({ to: 222, particle: :top, duration: 10000}) do |val|
115
+ puts "top +#{val}"
116
+ end
117
+
118
+
91
119
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
- #
3
- # # audio tag
4
- a = audio({ path: 'medias/audios/clap.wav', id: :audioElement })
2
+
3
+ # audio tag
4
+ a = audio({ path: 'medias/audios/clap.wav', id: :basic_audio })
5
5
  b=box({id: :playButton})
6
6
  b.text(:audio_tag)
7
7
  a.left(333)
@@ -10,26 +10,21 @@ b.touch(:down) do
10
10
  end
11
11
 
12
12
 
13
- #
14
- #
13
+
15
14
  ### Web Audio
16
- # Initialisation des variables globales
15
+ audio({ path: 'medias/audios/clap.wav', id: :audioElement })
17
16
  @audio_context = JS.eval('return new AudioContext()')
18
17
  @audio_element = JS.global[:document].getElementById('audioElement')
19
18
  @track = @audio_context.createMediaElementSource(@audio_element)
20
19
 
21
- # Ajout d'un nœud de gain (volume)
22
20
  @gain_node = @audio_context.createGain()
23
- @gain_node[:gain][:value] = 0.5 # Réduit le volume à 50%
24
- #
25
- # # Connexion de la chaîne
26
- @track.connect(@gain_node) # Connecte la source au nœud de gain
27
- @gain_node.connect(@audio_context[:destination]) # Connecte le nœud de gain à la sortie
21
+ @gain_node[:gain][:value] = 0.5
22
+
23
+ @track.connect(@gain_node)
24
+ @gain_node.connect(@audio_context[:destination])
28
25
 
29
26
  def play_audio
30
- # Réactive l'AudioContext s'il est suspendu
31
27
  @audio_context[:resume].to_s if @audio_context[:state].to_s == 'suspended'
32
- # Joue l'audio
33
28
  @audio_element.play
34
29
  end
35
30
  b2=box({left: 166})
@@ -45,7 +40,6 @@ bb.text(:wadjs)
45
40
  init_code = "window.snare = new Wad({source : 'medias/audios/clap.wav'});"
46
41
  JS.eval(init_code)
47
42
 
48
- # Code JavaScript pour jouer le son et l'arrêter après 300 ms, dans un bloc indépendant
49
43
  play_code = <<~STRDEL
50
44
  window.snare.play();
51
45
  setTimeout(function() {
@@ -53,17 +47,7 @@ play_code = <<~STRDEL
53
47
  }, 300);
54
48
  STRDEL
55
49
 
56
- # Exécution du bloc indépendant pour jouer et arrêter le son
57
- # JS.eval(play_code)
58
- # snare=JS.eval("return new Wad({source : 'medias/audios/clap.wav'})")
59
- # js_code=<<STRDEL
60
- # snare = #{snare};
61
- # snare =new Wad({source : 'medias/audios/clap.wav'})
62
- # snare.play();
63
- # setTimeout(() => {
64
- # snare.stop();
65
- # }, "300");
66
- # STRDEL
50
+
67
51
  bb.touch(:down) do
68
52
  JS.eval(play_code)
69
53
  end
@@ -1,158 +1,204 @@
1
- # # frozen_string_literal: true
1
+ # frozen_string_literal: true
2
+
3
+
4
+ ########################### Test check and verification below ############################
5
+
6
+ new({ tool: :blur }) do |params|
7
+
8
+ active_code = lambda {
9
+ puts :alteration_tool_code_activated
10
+ }
11
+
12
+ inactive_code = lambda { |param|
13
+ puts :alteration_tool_code_inactivated
14
+ }
15
+ pre_code = lambda { |params|
16
+ puts "pre_creation_code,atome_touched: #{:params}"
17
+
18
+ }
19
+ post_code = lambda { |params|
20
+ puts "post_creation_code,atome_touched: #{:params}"
21
+
22
+ }
23
+
24
+ zone_spe = lambda { |current_tool|
25
+ puts "current tool is : #{:current_tool} now creating specific zone"
26
+ # b = box({ width: 33, height: 12 })
27
+ # b.text({ data: :all })
28
+
29
+ }
30
+
31
+ {
32
+ activation: active_code,
33
+ inactivation: inactive_code,
34
+ alteration: { width: 22, blur: 3 },
35
+ pre: pre_code,
36
+ post: post_code,
37
+ zone: zone_spe,
38
+ icon: :color,
39
+ int8: { french: :couleur, english: :color, german: :colorad } }
40
+
41
+ end
42
+
43
+ new({ tool: :box }) do |params|
44
+
45
+ active_code = lambda {
46
+ puts :creation_tool_code_activated
47
+ }
48
+
49
+ inactive_code = lambda { |atomes_treated|
50
+ puts :creation_tool_code_inactivated
51
+
52
+ }
53
+ pre_creation_code = lambda { |params|
54
+ puts "pre_creation_code : atome_touched : #{:params} "
55
+
56
+ }
57
+
58
+ post_creation_code = lambda { |params|
59
+ puts "post_creation_code,atome_touched: #{:params}"
60
+ }
61
+
62
+ { creation: { box: { color: :blue, width: 66, height: 66 } },
63
+ activation: active_code,
64
+ inactivation: inactive_code,
65
+ pre: pre_creation_code,
66
+ post: post_creation_code,
67
+ int8: { french: :formes, english: :shape, german: :jesaispas } }
68
+
69
+ end
70
+
71
+
72
+ new({ tool: :project }) do
73
+ active_code = lambda {
74
+
75
+ alert :get_projects_now
76
+ # if Atome.selection.instance_of? Array
77
+ # end
78
+ # Atome.selection.each do |atome_id_to_treat|
79
+ # # # # reinit first to avoid multiple drag event
80
+ # # # grab(atome_id_to_treat).drag(false)
81
+ # end
82
+ # drag_remove
83
+ # puts :alteration_tool_code_activated
84
+ }
85
+ { activation: active_code }
86
+ end
87
+
88
+ new({tool: :test}) do
89
+ active_code = lambda {
90
+ b=grab(:view).box({})
91
+ b.touch(true) do
92
+ alert :kool
93
+ end
94
+ }
95
+ # active_code=:tito
96
+ { activation: active_code }
97
+ end
98
+
99
+
100
+ Universe.tools_root= {tools: [:blur, :box, :test],toolbox: { orientation: :ew, left:9 , bottom: 9, spacing: 9} }
101
+ # Universe.tools_root=[:test]
102
+ Atome.init_intuition
103
+
104
+ wait 1 do
105
+ grab(:blur_tool_icon).color(:red)
106
+ wait 1 do
107
+ grab(:box_tool_icon).color(:red)
108
+ wait 1 do
109
+ grab(:test_tool_icon).color(:red)
110
+ end
111
+ end
112
+ end
113
+
114
+
115
+ # ################### check below
116
+
117
+ # b = box({ left: 123, top: 66, selected: false, id: :the_box, color: :green })
118
+ # b.touch(:down) do
119
+ # puts " on touch : #{Universe.allow_localstorage}"
120
+ # end
121
+ # b.resize(true) do
122
+ # puts :good!
123
+ # end
124
+ # the_circ = circle({ left: 123, top: 120, selected: false, id: :the_circle })
2
125
  #
3
- # # m = table({ renderers: [:html], attach: :view, id: :my_test_box, type: :table, apply: [:shape_color],
4
- # # left: 333, top: 0, width: 900, smooth: 15, height: 900, overflow: :scroll, option: { header: false },
5
- # # component: {
6
- # # # border: { thickness: 5, color: :blue, pattern: :dotted },
7
- # # # overflow: :auto,
8
- # # # color: "red",
9
- # # shadow: {
10
- # # id: :s4,
11
- # # left: 20, top: 0, blur: 9,
12
- # # option: :natural,
13
- # # red: 0, green: 0, blue: 0, alpha: 1
14
- # # },
15
- # # height: 5,
16
- # # width: 12,
17
- # # component: { size: 12, color: :black }
18
- # # },
19
- # # # data: [
20
- # # # { titi: :toto },
21
- # # # { dfgdf: 1, name: 'Alice', age: 30, no: 'oko', t: 123, r: 654 },
22
- # # # { id: 2, name: 'Bob', age: 22 },
23
- # # # { dfg: 4, name: 'Vincent', age: 33, no: grab(:my_circle) },
24
- # # # { dfgd: 3, name: 'Roger', age: 18, no: image(:red_planet), now: :nothing }
25
- # # #
26
- # # # ]
27
- # # })
28
- # b=box({top: 120})
29
- # box({top: 190, id: :the_box})
126
+ # the_circ.touch(:down) do |params|
127
+ # puts " down : params: #{params}, id: #{the_circ.id}"
128
+ # end
30
129
  #
31
- # b.touch(true) do
32
- # a=JS.eval("return performance.now()")
33
- # z=Time.now
34
- # circle
35
- # columns = []
130
+ # the_circ.touch(:up) do
131
+ # puts "up :kool"
132
+ # end
133
+ # the_circ.drag(true) do
134
+ # puts "drag : now"
135
+ # end
36
136
  #
37
- # 96.times do
38
- # line = {}
39
- # 128.times do |index|
40
- # line[:"vel#{index}"] = nil
137
+ # bb = box({ left: 333, width: 120, selected: false, id: :big_box })
138
+ #
139
+ # b = box({ id: :the_big_boxy })
140
+
141
+ #################@
142
+ # text({ data: :hello, selected: true, left: 120, id: :texting, blur: 12 })
143
+ # text({data: :hello, left: 120, id: :texting})
144
+ # Universe.tools.each_with_index do |(tool_name, bloc), index|
145
+ # Atome.instance_exec(&bloc) if bloc.is_a?(Proc)
146
+ # # alert "#{tool_name} : #{tool_content}"
147
+ # # alert b.id
148
+ # end
149
+
150
+ # wait 2 do
151
+ # # c.preset( {:box=>{:width=>39, :height=>39, :apply=>[:box_color], :left=>0, :top=>0}} )
152
+ # c.preset( :box )
153
+ # end
154
+ # b=box({left: 333, top: 333})
155
+ # b.touch(true) do
156
+ # alert Atome.selection
157
+ # end
158
+ # grab(:the_texting).color(:white)
159
+ # grab(:the_texting).left(33)
160
+ # grab(:the_texting).top(133)
161
+ # grab(:the_texting).width(133)
162
+ # grab(:the_texting).top(133)
163
+ # grab(:the_texting).data(:kool)
164
+ # grab(:the_texting).type(:text)
165
+ # grab(:the_texting).rotate(:text)
166
+
167
+ # b=box
168
+ # b.touch(true) do
169
+ # puts :ok
170
+ # # alert b.instance_variable_get('@touch')
171
+ # # alert b.instance_variable_get('@touch_code')
172
+ # b.touch(false)
173
+ # wait 3 do
174
+ # puts :ready
175
+ # b.touch(true) do
176
+ # puts :kool
41
177
  # end
42
- # columns << line
178
+ # # alert b.touch
179
+ # # alert b.instance_variable_get('@touch')
180
+ # # alert b.instance_variable_get('@touch_code')
43
181
  # end
44
- # columns.each_with_index do |a, index|
45
- # b= box({left: index*30, width: 12})
46
- # # b.touch(true) do
47
- # # alert b.id
48
- # # end
182
+ # end
183
+
184
+ # A.html.record
185
+
186
+ # A.html.record
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+ # edition = "M257.7 752c2 0 4-0.2 6-0.5L431.9 722c2-0.4 3.9-1.3 5.3-2.8l423.9-423.9c3.9-3.9 3.9-10.2 0-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2c-1.9 11.1 1.5 21.9 9.4 29.8 6.6 6.4 14.9 9.9 23.8 9.9z m67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"
195
+ #
196
+ # v = vector({left: 99, data: { path: { d: edition, id: :p1, stroke: :black, 'stroke-width' => 37, fill: :red } } })
197
+ # v2 = vector({top: 66,data: { circle: { cx: 300, cy: 300, r: 340, id: :p2, stroke: :blue, 'stroke-width' => 35, fill: :yellow } } } )
198
+ # wait 1 do
199
+ # v.color(:blue)
200
+ # wait 1 do
201
+ # v2.color(:blue)
49
202
  # end
50
- # z2=Time.now
51
- # x=JS.eval("return performance.now();")
52
- # alert "#{x.to_f-a.to_f} : #{(z2-z)*1000}"
53
- #
54
203
  # end
55
- #
56
- #
57
- # # m.data(columns)
58
- # # # tests
59
- # # m.color(:orange)
60
- # # m.border({ thickness: 5, color: :blue, pattern: :dotted })
61
- # #
62
- # # m.get({ cell: [1, 2]}).class
63
- # # wait 2 do
64
- # # m.insert({ cell: [2, 2], content: 999 })
65
- # # m.insert({ row: 1 })
66
- # # wait 1 do
67
- # # m.remove({ row: 2 })
68
- # # end
69
- # # wait 2 do
70
- # # m.remove({ column: 1 })
71
- # # end
72
- # # wait 3 do
73
- # # m.insert({ column: 3 })
74
- # # end
75
- # #
76
- # # wait 4 do
77
- # # m.sort({ column: 1, method: :alphabetic })
78
- # # puts 1
79
- # # wait 1 do
80
- # # puts 2
81
- # # m.sort({ column: 2, method: :numeric })
82
- # # wait 1 do
83
- # # puts 3
84
- # # m.sort({ column: 3, method: :numeric })
85
- # # wait 1 do
86
- # # puts 4
87
- # # m.sort({ column: 1, method: :numeric })
88
- # # end
89
- # # end
90
- # # end
91
- # # end
92
- # #
93
- # # end
94
- # #
95
- # # # cell.fusion() # to be implemented later
96
- #
97
- #
98
- # # b=box({width: 1200, height: 900, color: {alpha: 0},top: -50})
99
- # # grab(:black_matter).image({id: :kb,path: 'medias/images/utils/keyboard.svg', width: 66, left: 55})
100
- # # # grab(:black_matter).image({id: :planet,path: 'medias/images/red_planet.png', width: 66,height: 66, left: 555, top: 180})
101
- # # b.fill([atome: :kb, repeat: {x: 8, y: 1}])
102
- # # b.drag(true)
103
- # #
104
- # #
105
- # # b2=box({width: 1200, height: 298, top: -100})
106
- # # grab(:black_matter).image({id: :notes,path: 'medias/images/utils/notes.svg', width: 166, left: 55})
107
- # # # grab(:black_matter).image({id: :planet,path: 'medias/images/red_planet.png', width: 66,height: 66, left: 555, top: 180})
108
- # # b2.fill([atome: :notes, repeat: {x: 8, y: 5}])
109
- # # b2.drag(true)
110
- #
111
- #
112
- # JS.eval("
113
- # // Fonction pour créer les divs
114
- # function createDivs() {
115
- # // Démarrer le chronomètre
116
- # const startTime = performance.now();
117
- #
118
- # const view = document.getElementById('view');
119
- # //view.innerHTML = ''; // Nettoyer le contenu précédent de 'view' si nécessaire
120
- #
121
- # // Boucle pour créer 98 divs sur l'axe X
122
- # for (let i = 0; i < 98; i++) {
123
- # const xDiv = document.createElement('div');
124
- # xDiv.style.display = 'flex';
125
- # xDiv.style.flexDirection = 'column';
126
- # xDiv.style.margin = '2px'; // Marge entre les divs de l'axe X
127
- #
128
- # // Boucle pour créer 128 divs sur l'axe Y
129
- # for (let j = 0; j < 128; j++) {
130
- # const yDiv = document.createElement('div');
131
- # yDiv.style.width = '10px'; // Largeur de chaque div sur l'axe Y
132
- # yDiv.style.height = '10px'; // Hauteur de chaque div sur l'axe Y
133
- # yDiv.style.border = '1px solid black'; // Bordure pour rendre les divs visibles
134
- # yDiv.style.boxSizing = 'border-box'; // Inclure la bordure dans les dimensions
135
- # xDiv.appendChild(yDiv);
136
- # }
137
- #
138
- # view.appendChild(xDiv);
139
- # }
140
- #
141
- # // Arrêter le chronomètre
142
- # const endTime = performance.now();
143
- # const timeTaken = endTime - startTime;
144
- #
145
- # // Afficher le temps écoulé en console
146
- # alert(`Temps écoulé pour créer les divs : ${timeTaken.toFixed(2)} ms`);
147
- # }
148
- #
149
- # // Ajouter un écouteur d'événements au div 'the_box'
150
- # document.getElementById('the_box').addEventListener('click', createDivs);
151
- # ``
152
- #
153
- # ")
154
204
 
155
- new({particle: :merge})
156
- a=box
157
- c=box
158
- d=a.merge(c)