atome 0.5.4.1.3 → 0.5.4.1.7

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: 5ea8cce9faff92d47920bfeb8bdd678e0c1c19db73d7446b43c8f8053cbb32f9
4
- data.tar.gz: cc515d8140cbda0d54b4a9faf1bbe13a03bc8a19ce500965480ab5a66f1cd951
3
+ metadata.gz: 1cd2344c47f76ea286f9a43141167d453be88717f538f71be93cbb43dd37487b
4
+ data.tar.gz: 26af922e7831e2a363adf36baa7112bde11e1b2cf7cc460a74ed04e348d7d46f
5
5
  SHA512:
6
- metadata.gz: 1b6a8825e9546c41f81fe46018c57824aa2bb46b176a1cf2c4a3d8c1b63ba19f5ba85abddbb3ed790ef9d555968c0e4d90238c3280b6c5d6c799b0d6017bcd1d
7
- data.tar.gz: 9c8496f6d15528eef09246d2454847210019fd282a6baca7e505076923e6527fb9ea09f54c9f942985324e0a09264380c4e632fbe748d50e24d00d61caf1df5a
6
+ metadata.gz: '0847ca30e88fc3c5cb33fa43dd030022b01fa5646455c13f706681516de240a29e5dabb0b9a25a4f714c37a28b87b9523ddddc70989fb7e2618082054a55a51d'
7
+ data.tar.gz: 6c8ddbb6432e002be2c4eea459bab8ef5a8e7b620789005889e272851a9912ebe88c785f01fc2d7bbed9923ad81aa90e23fea988ae71b817036937f1021428e4
data/CHANGELOG.md CHANGED
@@ -9,4 +9,10 @@
9
9
  ## [0.5.4.1.3] - 2023-05-21
10
10
  -version updated to '0.5.4.1.3'
11
11
  vector now remove background-color if it exist
12
- vector now use class instead of a local style
12
+ vector now use class instead of a local style
13
+
14
+
15
+ ## [0.5.4.1.7] - 2023-05-25
16
+
17
+ remove "shape :pre" and move the condition when using :definition to atome_common , because of a bug that remove all
18
+ attached atome
@@ -32,6 +32,15 @@ new({ sanitizer: :shadow }) do |params|
32
32
  new_params
33
33
  end
34
34
  new({ atome: :shape })
35
+ # new({ pre: :shape }) do |params|
36
+ # if params[:definition]
37
+ # # if it is a vector we reorder tha params
38
+ # attached = params.delete(:attached)
39
+ # params = params.merge({ attached: attached })
40
+ # end
41
+ #
42
+ # params
43
+ # end
35
44
  new({ atome: :code })
36
45
  new({ atome: :audio })
37
46
  new({ atome: :element })
@@ -2,7 +2,7 @@
2
2
 
3
3
  new({ particle: :attach })
4
4
  new({ sanitizer: :attach }) do |parents_ids|
5
- puts "=> attach it! : #{parents_ids} <="
5
+ # puts "=> attach it! : #{parents_ids} <="
6
6
 
7
7
  # parents_ids = parents_ids if parents_ids.instance_of? Atome
8
8
  parents_ids = [parents_ids] unless parents_ids.instance_of?(Array)
@@ -30,7 +30,7 @@ end
30
30
 
31
31
  new({ particle: :attached })
32
32
  new({ sanitizer: :attached }) do |children_ids|
33
- puts "=> attached now! : #{children_ids}<="
33
+ # puts "=> attached now! : #{children_ids}<="
34
34
  # children_ids = children_ids if children_ids.instance_of? Atome
35
35
  children_ids = [children_ids] unless children_ids.instance_of?(Array)
36
36
  children_ids.each do |child_id|
@@ -55,7 +55,6 @@ new({ sanitizer: :attached }) do |children_ids|
55
55
  end
56
56
 
57
57
  new({ particle: :detached, store: false })
58
-
59
58
  new({ sanitizer: :detached }) do |values|
60
59
  if values.instance_of? Array
61
60
  values.each do |value|
@@ -69,6 +68,9 @@ new({ sanitizer: :detached }) do |values|
69
68
  values
70
69
  end
71
70
 
71
+
72
+
73
+ new({ particle: :real })
72
74
  new({ particle: :type })
73
75
  new({ particle: :id })
74
76
  new({ sanitizer: :id }) do |params|
@@ -1,21 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- new({ particle: :red }) do
4
- # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
5
- self
6
- end
7
- new({ particle: :green }) do
8
- # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
9
- self
10
- end
11
- new({ particle: :blue }) do
12
- # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
13
- self
14
- end
15
- new({ particle: :alpha }) do
16
- # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
17
- self
18
- end
3
+ # new({ particle: :red }) do
4
+ # # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
5
+ # self
6
+ # end
7
+ # new({ particle: :green }) do
8
+ # # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
9
+ # self
10
+ # end
11
+ # new({ particle: :blue }) do
12
+ # # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
13
+ # self
14
+ # end
15
+ # new({ particle: :alpha }) do
16
+ # # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
17
+ # self
18
+ # end
19
19
  new({ particle: :diffusion }) do
20
20
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
21
21
  self
@@ -2,6 +2,16 @@
2
2
 
3
3
  # use to sanitize and secure user input
4
4
  module Essentials
5
+ corp = <<~STR
6
+ <g transform="matrix(0.0267056,0,0,0.0267056,18.6376,20.2376)">
7
+ <g id="shapePath1" transform="matrix(4.16667,0,0,4.16667,-377.307,105.632)">
8
+ <path d="M629.175,81.832C740.508,190.188 742.921,368.28 634.565,479.613C526.209,590.945 348.116,593.358 236.784,485.002C125.451,376.646 123.038,198.554 231.394,87.221C339.75,-24.111 517.843,-26.524 629.175,81.832Z" style="fill:rgb(201,12,125);"/>
9
+ </g>
10
+ <g id="shapePath2" transform="matrix(4.16667,0,0,4.16667,-377.307,105.632)">
11
+ <path d="M1679.33,410.731C1503.98,413.882 1402.52,565.418 1402.72,691.803C1402.91,818.107 1486.13,846.234 1498.35,1056.78C1501.76,1313.32 1173.12,1490.47 987.025,1492.89C257.861,1502.39 73.275,904.061 71.639,735.381C70.841,653.675 1.164,647.648 2.788,737.449C12.787,1291.4 456.109,1712.79 989.247,1706.24C1570.67,1699.09 1982.31,1234 1965.76,683.236C1961.3,534.95 1835.31,407.931 1679.33,410.731Z" style="fill:rgb(201,12,125);"/>
12
+ </g>
13
+ </g>
14
+ STR
5
15
  @default_params = {
6
16
  # Warning : type must be define first
7
17
  render_engines: [:browser],
@@ -19,7 +29,7 @@ module Essentials
19
29
  left: 100, top: 100, clones: [], preset: :box },
20
30
  vector: { type: :shape, width: 99, height: 99,
21
31
  attach: [:view],
22
- left: 100, top: 100, clones: [], preset: :vector },
32
+ left: 100, top: 100, clones: [], preset: :vector , definition: corp},
23
33
  circle: { type: :shape, width: 99, height: 99, smooth: '100%',
24
34
  attached: :circle_color, attach: [:view],
25
35
  left: 100, top: 100, clones: [], preset: :circle },
@@ -13,29 +13,44 @@ class Atome
13
13
  essential_params[:renderers] = essential_params[:renderers] || @atome[:renderers]
14
14
  essential_params[:id] = params[:id] || identity_generator(atome_type)
15
15
  essential_params[:attach] = params[:attach] || [@atome[:id]] || [:view]
16
+ if params[:definition]
17
+ # if it is a vector we reorder tha params
18
+ attached = params.delete(:attached)
19
+ params = params.merge({ attached: attached })
20
+ end
21
+
22
+
16
23
  essential_params.merge(params)
17
24
  end
18
25
 
19
26
  def box(params = {}, &bloc)
20
27
  atome_type = :box
21
28
  params = atome_common(atome_type, params)
22
- Atome.new({ atome_type => params }, &bloc)
29
+ # b= send(params[:type],params , &bloc)
30
+ Atome.new({ atome_type => params }, &bloc)
31
+
23
32
  end
24
33
 
25
- def vector(params = {}, &bloc)
26
- atome_type = :vector
34
+
35
+
36
+ def circle(params = {}, &bloc)
37
+ atome_type = :circle
27
38
  params = atome_common(atome_type, params)
39
+ # send(params[:type],params , &bloc)
28
40
  Atome.new({ atome_type => params }, &bloc)
29
41
  end
30
42
 
31
- def circle(params = {}, &bloc)
32
- atome_type = :circle
33
- # puts "counter#{Universe.counter}"
34
43
 
44
+ def vector(params = {}, &bloc)
45
+ atome_type = :vector
35
46
  params = atome_common(atome_type, params)
36
- # puts "params ==> #{params} : #{Universe.counter}"
37
-
47
+ # send(params[:type],params, &bloc )
38
48
  Atome.new({ atome_type => params }, &bloc)
49
+
50
+
39
51
  end
40
52
 
41
53
  end
54
+
55
+
56
+
@@ -12,42 +12,69 @@ generator.build_render(:browser_shape) do
12
12
  # if @definition
13
13
  # alert "why we never pass here??????"
14
14
  # else
15
- @browser_type = :div
16
- id_found = @atome[:id]
17
- DOM do
18
- div(id: id_found).atome
19
- end.append_to(BrowserHelper.browser_document[:user_view])
20
- @browser_object = BrowserHelper.browser_document[id_found]
15
+ @browser_type = :div
16
+ id_found = @atome[:id]
17
+ DOM do
18
+ div(id: id_found).atome
19
+ end.append_to(BrowserHelper.browser_document[:user_view])
20
+ @browser_object = BrowserHelper.browser_document[id_found]
21
21
  # end
22
22
 
23
23
  end
24
24
 
25
25
  generator.build_render(:browser_color) do |_value|
26
+ puts " @atome[:id] : #{@atome[:id]}"
26
27
  @browser_type = :style
27
28
  # puts "1 - for the id : #{id} the browser type is ::::> #{@browser_type}"
28
29
  id_found = @atome[:id]
29
- type_found = @atome[:type]
30
+ # type_found = @atome[:type]
30
31
  # we remove previous unused style tag
31
32
  BrowserHelper.browser_document[id]&.remove
32
33
  red_found = @atome[:red]
33
34
  blue_found = @atome[:blue]
34
35
  green_found = @atome[:green]
35
36
  alpha_found = @atome[:alpha]
36
- BrowserHelper.browser_document.head << Browser.DOM("<style atome='#{type_found}'
37
- id='#{id_found}'>.#{id_found}{
38
- background-color: rgba(#{red_found * 255},#{green_found * 255},#{blue_found * 255},#{alpha_found});
39
- fill: rgba(#{red_found * 255},#{green_found * 255},#{blue_found * 255},#{alpha_found}),
40
- stroke: rgba(#{red_found * 255},#{green_found * 255},#{blue_found * 255},#{alpha_found})}</style>")
41
- # document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.fill = #{color_updated}
42
- # document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.stroke = #{color_updated}
43
- # # TODO: use the code below to modify the style tag
37
+ ########################### old code ###########################
38
+ # BrowserHelper.browser_document.head << Browser.DOM("<style atome='#{type_found}'
39
+ # id='#{id_found}'>.#{id_found}{
40
+ # poil
41
+ # //background-color: rgba(#{red_found * 255},#{green_found * 255},#{blue_found * 255},#{alpha_found});
42
+ # //fill: rgba(#{red_found * 255},#{green_found * 255},#{blue_found * 255},#{alpha_found}),
43
+ # //stroke: rgba(#{red_found * 255},#{green_found * 255},#{blue_found * 255},#{alpha_found})
44
+ #
45
+ # }</style>")
46
+
47
+ ########################### new code ###########################
48
+ atomic_style = BrowserHelper.browser_document['#atomic_style']
49
+
50
+ class_content = <<STR
51
+ .#{id_found} {
52
+ background-color: rgba(#{red_found * 255}, #{green_found * 255}, #{blue_found * 255}, #{alpha_found});
53
+ fill: rgba(#{red_found * 255}, #{green_found * 255}, #{blue_found * 255}, #{alpha_found});
54
+ stroke: rgba(#{red_found * 255}, #{green_found * 255}, #{blue_found * 255}, #{alpha_found});
55
+ }
56
+ STR
57
+
58
+ if atomic_style
59
+ if atomic_style.text.include?(".#{id_found}")
60
+ # if the class exist , update it's content with the new class
61
+ regex = /(\.#{id_found}\s*{)([\s\S]*?)(})/m
62
+ atomic_style.text = atomic_style.text.gsub(regex, class_content)
63
+ else
64
+ # if the class doesn't exist, add it to the end of the tag <style>
65
+ atomic_style.text += class_content
66
+ end
67
+ end
68
+ ########################### new code end ###########################
69
+
70
+ # TODO: use the code below to modify the style tag
44
71
  @browser_object = BrowserHelper.browser_document[id_found]
45
72
  end
46
73
 
47
74
  generator.build_render(:browser_shadow) do |_value|
48
75
  @browser_type = :style
49
76
  id_found = @atome[:id]
50
- type_found = @atome[:type]
77
+ # type_found = @atome[:type]
51
78
  # we remove previous unused style tag
52
79
  BrowserHelper.browser_document[id]&.remove
53
80
  red_found = @atome[:red]
@@ -58,12 +85,38 @@ generator.build_render(:browser_shadow) do |_value|
58
85
  left = @atome[:left]
59
86
  top = @atome[:top]
60
87
  inset = @atome[:direction]
88
+ ############ old code
89
+ # BrowserHelper.browser_document.head << Browser.DOM("<style atome='#{type_found}'
90
+ # id='#{id_found}'>.#{id_found}{box-shadow: #{left}px #{top}px #{blur}px #{inset} rgba(#{red_found * 255},
91
+ # #{green_found * 255},#{blue_found * 255},#{alpha_found})}</style>")
92
+ # # TODO/ use the code below to modify the style tag
93
+ # @browser_object = BrowserHelper.browser_document[id_found]
94
+
95
+ ########## new code
96
+ atomic_style = BrowserHelper.browser_document['#atomic_style']
97
+
98
+ class_content = <<STR
99
+ .#{id_found} {
100
+ box-shadow: #{left}px #{top}px #{blur}px #{inset} rgba(#{red_found * 255},#{green_found * 255},#{blue_found * 255},
101
+ #{alpha_found});
102
+ filter: drop-shadow(#{left}px #{top}px #{blur}px rgba(#{red_found * 255},#{green_found * 255},#{blue_found * 255},
103
+ #{alpha_found}));
104
+ }
105
+ STR
106
+
107
+ if atomic_style
108
+ if atomic_style.text.include?(".#{id_found}")
109
+ # if the class exist , update it's content with the new class
110
+ regex = /(\.#{id_found}\s*{)([\s\S]*?)(})/m
111
+ atomic_style.text = atomic_style.text.gsub(regex, class_content)
112
+ else
113
+ # if the class doesn't exist, add it to the end of the tag <style>
114
+ atomic_style.text += class_content
115
+ end
116
+ end
117
+ #
118
+ # @browser_object = BrowserHelper.browser_document[id_found]
61
119
 
62
- BrowserHelper.browser_document.head << Browser.DOM("<style atome='#{type_found}'
63
- id='#{id_found}'>.#{id_found}{box-shadow: #{left}px #{top}px #{blur}px #{inset} rgba(#{red_found * 255},
64
- #{green_found * 255},#{blue_found * 255},#{alpha_found})}</style>")
65
- # TODO/ use the code below to modify the style tag
66
- @browser_object = BrowserHelper.browser_document[id_found]
67
120
  end
68
121
 
69
122
  generator.build_render(:browser_image) do |_user_prc|
@@ -15,41 +15,40 @@ module BrowserHelper
15
15
  html_object.append_to(browser_document[parents])
16
16
  end
17
17
 
18
- def self.colorize_vector(vector_id, tag_style)
19
- # TODO : Create a class instead of modidfying the vector
18
+ def self.add_class_to_vector(vector_id, color_id)
19
+ # TODO : Create a class instead of modifying the vector
20
20
  # get the content the <style> tag
21
- color_class=self.color.last
21
+ # color_class=self.color.last
22
+ # alert color_class
22
23
  # alert color_class.class
23
24
  # content_style = tag_style.inner_html
24
25
  # color_value = content_style[/background-color:\s*([^;}]+)/, 1]
25
26
  `
26
27
  let parser = new DOMParser();
27
28
  var divElement = document.querySelector('#'+#{vector_id});
28
- divElement.style.removeProperty('background-color');
29
- divElement.style.backgroundColor = 'transparent';
29
+ // divElement.style.removeProperty('background-color');
30
+ //divElement.style.backgroundColor = 'transparent';
30
31
  // select the first svg tag inside the div
31
32
  let foundSVG = divElement.querySelector('svg');
32
33
  let elements = foundSVG.getElementsByTagName("path");
33
34
  Array.from(elements).forEach(el => {
34
- el.classList.add(#{color_class});
35
+ el.classList.add(#{color_id});
35
36
  });
36
37
  `
37
38
  end
38
39
 
39
40
  def self.browser_attach_style(parents, _html_object, atome)
40
- # we test if the atome has a deinition ( it means hold some vectors infomations)
41
+ # we test if the atome has a definition ( it means hold some vectors information)
41
42
  if grab(parents).atome[:definition]
42
- tag_style = $document[atome[:id]]
43
- # # get the content the <style> tag
44
- # content_style = tag_style.inner_html
45
- # extract the color value
46
- colorize_vector(parents, tag_style)
47
-
43
+ # tag_style = $document[atome[:id]]
44
+ # # # get the content the <style> tag
45
+ # # content_style = tag_style.inner_html
46
+ # # extract the color value
47
+ # alert atome[:id]
48
+ add_class_to_vector(parents, atome[:id])
48
49
  else
49
50
  browser_document[parents].add_class(atome[:id])
50
-
51
51
  end
52
-
53
52
  end
54
53
 
55
54
  def self.browser_attached_div(children, _html_object, atome)
@@ -62,10 +61,11 @@ divElement.style.backgroundColor = 'transparent';
62
61
 
63
62
  def self.browser_attached_style(children, _html_object, atome)
64
63
  if atome[:definition]
64
+ # alert "yes we arrived here :>\n\n=>#{children}, class:\n=>#{children.class} :\n\n=> #{atome} :\n\n=> #{_html_object}<:"
65
65
  children.each do |child|
66
- tag_style = $document[child]
67
-
68
- colorize_vector(atome[:id], tag_style)
66
+ # tag_style = $document[child]
67
+ # alert "(#{atome[:id]}, #{child})"
68
+ add_class_to_vector(atome[:id], child)
69
69
  # get the content the <style> tag
70
70
  # content_style = tag_style.inner_html
71
71
  # # extract the color value
@@ -84,11 +84,10 @@ divElement.style.backgroundColor = 'transparent';
84
84
  end
85
85
 
86
86
  else
87
- # alert atome.class
88
- browser_document[atome[:id]].add_class(children)
87
+ # alert "class added : #{children}"
88
+ # browser_document[atome[:id]].add_class(children)
89
89
  end
90
- # browser_document[atome[:id]].add_class(children)
91
-
90
+ browser_document[atome[:id]].add_class(children)
92
91
  end
93
92
 
94
93
  def self.value_parse(value)
@@ -3,20 +3,63 @@
3
3
  # for browser rendering
4
4
  module BrowserHelper
5
5
  def self.browser_colorize_color(color_updated, atome)
6
- `
7
- document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.backgroundColor = #{color_updated}
8
- document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.fill = #{color_updated}
9
- document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.stroke = #{color_updated}
10
- `
6
+ ########################### new code ###########################
7
+ id_found=atome[:id]
8
+ new_class_content = <<STR
9
+ .#{id_found} {
10
+ background-color: #{color_updated};
11
+ fill: #{color_updated};
12
+ stroke: #{color_updated};
13
+ }
14
+ STR
15
+
16
+ atomic_style = BrowserHelper.browser_document['#atomic_style']
17
+ # atomic_style.text = atomic_style.text.gsub(/\.#{id_found}\s*{.*?}/m, new_class_content)
18
+
19
+ regex = /(\.#{id_found}\s*{)([\s\S]*?)(})/m
20
+ atomic_style.text = atomic_style.text.gsub(regex, new_class_content)
21
+
22
+
23
+ ########################### old code ###########################
24
+ #
25
+ # puts "the code below may be updated to work with the new class handler :\n\n#{color_updated}\n\n#{atome}"
26
+ # `
27
+ # document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.backgroundColor = #{color_updated}
28
+ # document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.fill = #{color_updated}
29
+ # document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.stroke = #{color_updated}
30
+ # `
31
+ ########################### new old end ###########################
32
+
11
33
  end
12
34
 
13
35
  def self.browser_colorize_shadow(color_updated, atome)
36
+ "new shadow color is : #{color_updated}"
37
+ puts "=====> #{color_updated} : #{atome}"
14
38
  left = atome[:left]
15
39
  top = atome[:top]
16
40
  blur = atome[:blur]
17
41
  direction = atome[:direction]
18
- shadow_updated = "#{left}px #{top}px #{blur}px #{color_updated} #{direction}"
19
- `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
42
+ # shadow_updated = "#{left}px #{top}px #{blur}px #{color_updated} #{direction}"
43
+ # `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
44
+
45
+ #new code
46
+ id_found= atome[:id]
47
+ class_content = <<STR
48
+ .#{id_found} {
49
+ box-shadow: #{left}px #{top}px #{blur}px #{color_updated} #{direction};
50
+ }
51
+ STR
52
+
53
+ atomic_style = BrowserHelper.browser_document['#atomic_style']
54
+ # atomic_style.text = atomic_style.text.gsub(/\.#{id_found}\s*{.*?}/m, new_class_content)
55
+ # puts new_class_content
56
+ regex = /(\.#{id_found}\s*{)([\s\S]*?)(})/m
57
+ atomic_style.text = atomic_style.text.gsub(regex, class_content)
58
+
59
+ # .view_shadow_17 {
60
+ # box-shadow: 3px 3px 3px rgba(0,
61
+ # 0,0,1)
62
+ # }
20
63
  end
21
64
 
22
65
  def self.browser_left_color(_value, _browser_object, _atome)
@@ -4,17 +4,17 @@
4
4
  module BrowserHelper
5
5
 
6
6
  def self.browser_blur_style(_browser_object, value, atome)
7
- b_left = "#{atome[:left]}px"
8
- b_top = "#{atome[:top]}px"
9
- b_blur = "#{atome[:blur] = value}px"
10
- b_red = atome[:red] * 255
11
- b_green = atome[:green] * 255
12
- b_blue = (atome[:blue]) * 255
13
- b_direction = atome[:direction]
14
- b_alpha = atome[:alpha]
7
+ # b_left = "#{atome[:left]}px"
8
+ # b_top = "#{atome[:top]}px"
9
+ # b_blur = "#{atome[:blur] = value}px"
10
+ # b_red = atome[:red] * 255
11
+ # b_green = atome[:green] * 255
12
+ # b_blue = (atome[:blue]) * 255
13
+ # b_direction = atome[:direction]
14
+ # b_alpha = atome[:alpha]
15
15
 
16
- shadow_updated = "#{b_left} #{b_top} #{b_blur} rgba(#{b_red}, #{b_green}, #{b_blue}, #{b_alpha}) #{b_direction}"
17
- `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
16
+ # shadow_updated = "#{b_left} #{b_top} #{b_blur} rgba(#{b_red}, #{b_green}, #{b_blue}, #{b_alpha}) #{b_direction}"
17
+ # `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
18
18
  end
19
19
 
20
20
  def self.browser_blur_div(browser_object, value, _atome)
@@ -12,22 +12,63 @@ module BrowserHelper
12
12
  blue = (atome[:blue]) * 255
13
13
  direction = atome[:direction]
14
14
  alpha = atome[:alpha]
15
+ id_found = atome[:id]
16
+ real = atome[:real]
17
+ # `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
18
+ if real
19
+ drop_shadow_updated = "drop-shadow(#{ls_left} #{ls_top} #{ls_blur} rgba(#{red}, #{green}, #{blue}, #{alpha}))"
20
+ class_content = <<STR
21
+ .#{id_found} {
15
22
 
16
- shadow_updated = "#{ls_left} #{ls_top} #{ls_blur} rgba(#{red}, #{green}, #{blue}, #{alpha}) #{direction}"
17
- `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
23
+ filter: #{drop_shadow_updated};
24
+ }
25
+ STR
26
+ else
27
+ shadow_updated = "#{ls_left} #{ls_top} #{ls_blur} rgba(#{red}, #{green}, #{blue}, #{alpha}) #{direction}"
28
+ class_content = <<STR
29
+ .#{id_found} {
30
+ box-shadow: #{shadow_updated};
31
+ }
32
+ STR
33
+ end
34
+
35
+ atomic_style = BrowserHelper.browser_document['#atomic_style']
36
+
37
+ return unless atomic_style
38
+
39
+ if atomic_style.text.include?(".#{id_found}")
40
+ # if the class exist , update it's content with the new class
41
+ # alert "before :#{atomic_style.text}"
42
+ regex = /(\.#{id_found}\s*{)([\s\S]*?)(})/m
43
+ atomic_style.text = atomic_style.text.gsub(regex, class_content)
44
+ # alert "after :#{atomic_style.text}"
45
+ else
46
+ # if the class doesn't exist, add it to the end of the tag <style>
47
+ atomic_style.text += class_content
48
+ end
49
+
50
+ # alert atomic_style.text
18
51
  end
19
52
 
20
- def self.browser_top_shadow(value, _browser_object, atome)
21
- rs_left = "#{atome[:left]}px"
22
- rs_top = "#{atome[:top] = value}px"
23
- rs_blur = "#{atome[:blur]}px"
24
- red = atome[:red] * 255
25
- green = atome[:green] * 255
26
- blue = (atome[:blue]) * 255
27
- direction = atome[:direction]
28
- alpha = atome[:alpha]
53
+ # .shadow2 {
54
+ # box-shadow: 3px 9px 9px rgba(0, 0, 0, 1) inset;
55
+ # }
56
+ # .shadow2 {
57
+ # box-shadow: 3px 9px 9px rgba(0, 0, 0, 1) inset)
58
+ # }
29
59
 
30
- shadow_updated = "#{rs_left}px #{rs_top}px #{rs_blur}px rgba(#{red}, #{green}, #{blue}, #{alpha}) #{direction}"
31
- `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
60
+ def self.browser_top_shadow(value, _browser_object, atome)
61
+ # rs_left = "#{atome[:left]}px"
62
+ # rs_top = "#{atome[:top] = value}px"
63
+ # rs_blur = "#{atome[:blur]}px"
64
+ # red = atome[:red] * 255
65
+ # green = atome[:green] * 255
66
+ # blue = (atome[:blue]) * 255
67
+ # direction = atome[:direction]
68
+ # alpha = atome[:alpha]
69
+ #
70
+ # shadow_updated = "#{rs_left}px #{rs_top}px #{rs_blur}px rgba(#{red}, #{green}, #{blue}, #{alpha}) #{direction}"
71
+ # `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.boxShadow = #{shadow_updated}`
72
+ #
32
73
  end
33
74
  end
@@ -2,20 +2,19 @@
2
2
 
3
3
  generator = Genesis.generator
4
4
 
5
- generator.build_render(:browser_id) do |params|
6
- if @browser_type == :style
7
- prev_content = @browser_object.inner_html
8
- new_content = prev_content.sub(@browser_object.id, params)
9
- @browser_object.inner_html = new_content
10
- end
11
- browser_object.id = params if @atome[:id] != params
12
- end
5
+ # generator.build_render(:browser_id) do |params|
6
+ # if @browser_type == :style
7
+ # prev_content = @browser_object.inner_html
8
+ # new_content = prev_content.sub(@browser_object.id, params)
9
+ # @browser_object.inner_html = new_content
10
+ # end
11
+ # browser_object.id = params if @atome[:id] != params
12
+ # end
13
13
 
14
14
  generator.build_render(:browser_type) do |params|
15
15
  send("browser_#{params}", user_proc)
16
16
  end
17
17
 
18
-
19
18
  generator.build_render(:browser_attach) do |parents_found|
20
19
  # puts "parents_found : #{parents_found}, #{parents_found.class}"
21
20
  parents_found.each do |parent_found|
@@ -26,7 +25,8 @@ end
26
25
 
27
26
  generator.build_render(:browser_attached) do |children_found|
28
27
  children_found.each do |child_found|
29
- # puts ">>>>> modeled: browser_type #{@browser_type} parents_found #{children_found} , @browser_object, #{@browser_object}, self : #{self.id}"
28
+ # puts ">>>>> modeled: browser_type #{@browser_type} parents_fo
29
+ # und #{children_found} , @browser_object, #{@browser_object}, self : #{self.id}"
30
30
  children_browser_type = grab(child_found).instance_variable_get('@browser_type')
31
31
  BrowserHelper.send("browser_attached_#{children_browser_type}", children_found, @browser_object, @atome)
32
32
  end
@@ -38,6 +38,21 @@ generator.build_render(:browser_detached) do |values, _user_proc|
38
38
  value = value.value if value.instance_of? Atome
39
39
  if grab(value).instance_variable_get('@browser_type') == :style
40
40
  @browser_object.remove_class(value)
41
+ if definition
42
+ `
43
+ let parser = new DOMParser();
44
+ var divElement = document.querySelector('#'+#{self.id});
45
+ // divElement.style.removeProperty('background-color');
46
+ //divElement.style.backgroundColor = 'transparent';
47
+ // select the first svg tag inside the div
48
+ let foundSVG = divElement.querySelector('svg');
49
+ let elements = foundSVG.getElementsByTagName("path");
50
+ Array.from(elements).forEach(el => {
51
+ el.classList.remove(#{value});
52
+ });
53
+ `
54
+ end
55
+
41
56
  else
42
57
  BrowserHelper.browser_document[value]&.remove
43
58
  end
@@ -106,6 +106,8 @@ if (svgElement) {
106
106
 
107
107
  let svg_content='<svg style="width: 1em; height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg">'+#{value}+'</svg>'
108
108
  let svgContainer = document.getElementById(#{target});
109
+ svgContainer.style.removeProperty('background-color');
110
+ svgContainer.style.backgroundColor = 'transparent';
109
111
  let parser = new DOMParser();
110
112
  let svgDoc = parser.parseFromString(svg_content, "image/svg+xml");
111
113
  let importedSVG = svgDoc.getElementsByTagName("svg")[0];
@@ -116,4 +118,4 @@ if (svgElement) {
116
118
  svgContainer.appendChild(importedSVG);
117
119
 
118
120
  `
119
- end
121
+ end
data/lib/atome/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Atome
4
- VERSION = '0.5.4.1.3'
4
+ VERSION = '0.5.4.1.7'
5
5
  end
@@ -158,4 +158,3 @@ const Atome_canvas={}
158
158
  // });
159
159
 
160
160
 
161
-
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- c=circle
2
+
3
3
  b=circle({left: 333, id: :the_c})
4
4
  b.touch(true) do
5
5
  self.color(:blue)
@@ -1,37 +1,84 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # TODO : make this work : b.shadow({color: :red})
4
+
3
5
  b = box({ id: :the_box, left: 99, top: 99 })
4
6
 
5
7
 
6
8
 
7
9
 
8
- s = b.shadow({ renderers: [:browser], id: :shadow2, type: :shadow, attach: [],
9
- left: 3, top: 9, blur: 3, direction: :inset,
10
+ s = b.shadow({ renderers: [:browser], id: :shadow2, type: :shadow,
11
+ left: 3, top: 9, blur: 9, direction: :inset,
10
12
  red: 0, green: 0, blue: 0, alpha: 1
11
13
  })
12
14
 
15
+ s.left(16)
16
+
17
+ # s.color(:red)
18
+ # wait 1 do
19
+ # s.attach([:the_box])
20
+ # # or
21
+ # # b.children([:shadow2])
22
+ # wait 1 do
23
+ # s.blur(9)
24
+ # wait 1 do
25
+ # wait 2 do
26
+ # s.direction('')
27
+ # s.green(0.007)
28
+ # s.left(14)
29
+ # wait 1 do
30
+ # s.delete(true)
31
+ # end
32
+ # end
33
+ # s.left(44)
34
+ # s.green(0.7)
35
+ # end
36
+ # end
37
+ # end
38
+ #
39
+ # wait 3 do
40
+ # b.shadow({ blur: 33 })
41
+ # wait 2 do
42
+ # b.shadow({ blur: 3 })
43
+ # end
44
+ # end
45
+
46
+ wait 2 do
47
+ s.red(1)
48
+ end
49
+
50
+ wait 4 do
13
51
 
14
- wait 1 do
15
- s.attach([:the_box])
16
- # or
17
- # b.children([:shadow2])
18
- wait 1 do
19
- s.blur(9)
20
- wait 1 do
21
- wait 2 do
22
- s.direction('')
23
- s.green(0)
24
- s.left(14)
25
- wait 1 do
26
- s.delete(true)
27
- end
28
- end
29
- s.left(44)
30
- s.green(0.7)
31
- end
32
- end
52
+ puts "-----------> now!!!!!!"
53
+ b.shadow({ green: 1 })
54
+ # c2=color(:red)
55
+ # b.shadow.attach(c2.id)
33
56
  end
34
57
 
35
- wait 3 do
36
- b.shadow({ blur: 33 })
58
+
59
+ edition = <<~STR
60
+ <path id="p1" d="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"/>
61
+ STR
62
+ v=vector({left: 300, width: 300, height: 300, definition: edition})
63
+ # v.color(:red)
64
+ v.shadow({ renderers: [:browser], id: :shadow7, type: :shadow,
65
+ left: 3, top: 9, blur: 9, direction: :inset,
66
+ red: 0, green: 0, blue: 0, alpha: 1
67
+ })
68
+
69
+ v.shadow({ renderers: [:browser], id: :shadow8, type: :shadow, real: true,
70
+ left: 3, top: 9, blur: 9, direction: :inset,
71
+ red: 0, green: 0, blue: 0, alpha: 1
72
+ })
73
+ b=box({top: 300})
74
+
75
+ wait 4 do
76
+ b.attached(:shadow7)
77
+ v.attached(:shadow7)
78
+ end
79
+
80
+
81
+ wait 6 do
82
+ b.attached(:shadow8)
83
+ v.attached(:shadow8)
37
84
  end
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.4.1.3
4
+ version: 0.5.4.1.7
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: 2023-05-21 00:00:00.000000000 Z
11
+ date: 2023-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arduino_firmata