atome 0.5.4.1.2 → 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: a4b330e878ce2169698bf9cf0cb0910503b2600e875abf3d458e87cbd4cb7c8c
4
- data.tar.gz: 0be22a13c09c3f280049579fb6c0f4d7010073d4880bb7ae0cb99e79a750da40
3
+ metadata.gz: 1cd2344c47f76ea286f9a43141167d453be88717f538f71be93cbb43dd37487b
4
+ data.tar.gz: 26af922e7831e2a363adf36baa7112bde11e1b2cf7cc460a74ed04e348d7d46f
5
5
  SHA512:
6
- metadata.gz: ee294cb99cf5d7b0d34eed58c43a0a1b4309d16fd9c0c3ccba9efe06fd079858d32a7fa0c3562376ce35d076bbef7e14f045f3bcb55a7a27814d55990409785a
7
- data.tar.gz: e6c748de46620aa1eb7b2fd5325bfefe66132992e78a1e2f3ad2a670f34e96e0166fa695ad5aa435fd3d3a1433b48c398582c093c0ed0593e85ba172aa73bead
6
+ metadata.gz: '0847ca30e88fc3c5cb33fa43dd030022b01fa5646455c13f706681516de240a29e5dabb0b9a25a4f714c37a28b87b9523ddddc70989fb7e2618082054a55a51d'
7
+ data.tar.gz: 6c8ddbb6432e002be2c4eea459bab8ef5a8e7b620789005889e272851a9912ebe88c785f01fc2d7bbed9923ad81aa90e23fea988ae71b817036937f1021428e4
data/CHANGELOG.md CHANGED
@@ -4,4 +4,15 @@
4
4
  - add vector preset, with support for svg format
5
5
 
6
6
  ## [0.5.4.1.2] - 2023-05-20
7
- - added changelog for rubygems
7
+ - added changelog for rubygems
8
+
9
+ ## [0.5.4.1.3] - 2023-05-21
10
+ -version updated to '0.5.4.1.3'
11
+ vector now remove background-color if it exist
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,12 +2,12 @@
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
- parents_ids = parents_ids if parents_ids.instance_of? Atome
7
+ # parents_ids = parents_ids if parents_ids.instance_of? Atome
8
8
  parents_ids = [parents_ids] unless parents_ids.instance_of?(Array)
9
9
  parents_ids.each do |parents_id|
10
- parents_id = parents_id if parents_id.instance_of? Atome
10
+ # parents_id = parents_id if parents_id.instance_of? Atome
11
11
  parents_found = grab(parents_id)
12
12
  # TODO : factorise the code below
13
13
  current_type = atome[:type]
@@ -30,11 +30,11 @@ end
30
30
 
31
31
  new({ particle: :attached })
32
32
  new({ sanitizer: :attached }) do |children_ids|
33
- puts "=> attached now! : #{children_ids}<="
34
- children_ids = children_ids if children_ids.instance_of? Atome
33
+ # puts "=> attached now! : #{children_ids}<="
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|
37
- child_id = child_id if child_id.instance_of? Atome
37
+ # child_id = child_id if child_id.instance_of? Atome
38
38
  child_found = grab(child_id)
39
39
  parents_found = @atome[:id]
40
40
  # TODO : factorise the code below
@@ -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
@@ -50,10 +50,15 @@ new({ particle: :remove_classes }) do |value|
50
50
  # Universe.classes.delete(value)
51
51
  Universe.classes[value].delete(id)
52
52
  end
53
- new ({particle: :opacity})
54
-
53
+ new ({ particle: :opacity })
55
54
 
56
55
  # vector shape
57
- new({particle: :definition})
56
+ new({ particle: :definition })
57
+
58
+ new({ browser: :definition, type: :string })
58
59
 
59
- new({ browser: :definition, type: :string })
60
+ new({ sanitizer: :definition }) do |params|
61
+ # we remove the unwanted svg tags
62
+ params = params.gsub(/<svg[^>]*>|<\/svg>/, '')
63
+ params
64
+ end
@@ -60,6 +60,11 @@ Atome.new(
60
60
  red: 0.5, green: 0.5, blue: 0.5, alpha: 1 } }
61
61
  )
62
62
 
63
+ Atome.new(
64
+ { color: { renderers: default_render, id: :invisible_color, type: :color,tag: ({persistent: true}),
65
+ red: 0, green: 0, blue: 0, alpha: 1 } }
66
+ )
67
+
63
68
  Atome.new(
64
69
  { color: { renderers: default_render, id: :text_color, type: :color,tag: ({persistent: true}),
65
70
  red: 0.3, green: 0.3, blue: 0.3, alpha: 1 } }
@@ -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
+
@@ -9,41 +9,72 @@ def parents(_val) end
9
9
  generator = Genesis.generator
10
10
 
11
11
  generator.build_render(:browser_shape) do
12
- if @definition
13
- alert :poil
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]
21
- end
12
+ # if @definition
13
+ # alert "why we never pass here??????"
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]
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}{background-color: rgba(#{red_found * 255},
38
- #{green_found * 255},#{blue_found * 255},#{alpha_found})}</style>")
39
- # # 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
40
71
  @browser_object = BrowserHelper.browser_document[id_found]
41
72
  end
42
73
 
43
74
  generator.build_render(:browser_shadow) do |_value|
44
75
  @browser_type = :style
45
76
  id_found = @atome[:id]
46
- type_found = @atome[:type]
77
+ # type_found = @atome[:type]
47
78
  # we remove previous unused style tag
48
79
  BrowserHelper.browser_document[id]&.remove
49
80
  red_found = @atome[:red]
@@ -54,12 +85,38 @@ generator.build_render(:browser_shadow) do |_value|
54
85
  left = @atome[:left]
55
86
  top = @atome[:top]
56
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]
57
119
 
58
- BrowserHelper.browser_document.head << Browser.DOM("<style atome='#{type_found}'
59
- id='#{id_found}'>.#{id_found}{box-shadow: #{left}px #{top}px #{blur}px #{inset} rgba(#{red_found * 255},
60
- #{green_found * 255},#{blue_found * 255},#{alpha_found})}</style>")
61
- # TODO/ use the code below to modify the style tag
62
- @browser_object = BrowserHelper.browser_document[id_found]
63
120
  end
64
121
 
65
122
  generator.build_render(:browser_image) do |_user_prc|
@@ -15,30 +15,40 @@ module BrowserHelper
15
15
  html_object.append_to(browser_document[parents])
16
16
  end
17
17
 
18
+ def self.add_class_to_vector(vector_id, color_id)
19
+ # TODO : Create a class instead of modifying the vector
20
+ # get the content the <style> tag
21
+ # color_class=self.color.last
22
+ # alert color_class
23
+ # alert color_class.class
24
+ # content_style = tag_style.inner_html
25
+ # color_value = content_style[/background-color:\s*([^;}]+)/, 1]
26
+ `
27
+ let parser = new DOMParser();
28
+ var divElement = document.querySelector('#'+#{vector_id});
29
+ // divElement.style.removeProperty('background-color');
30
+ //divElement.style.backgroundColor = 'transparent';
31
+ // select the first svg tag inside the div
32
+ let foundSVG = divElement.querySelector('svg');
33
+ let elements = foundSVG.getElementsByTagName("path");
34
+ Array.from(elements).forEach(el => {
35
+ el.classList.add(#{color_id});
36
+ });
37
+ `
38
+ end
39
+
18
40
  def self.browser_attach_style(parents, _html_object, atome)
19
- # 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)
20
42
  if grab(parents).atome[:definition]
21
- tag_style = $document[atome[:id]]
22
- # get the content the <style> tag
23
- content_style = tag_style.inner_html
24
- # extract the color value
25
- color_value = content_style[/background-color:\s*([^;}]+)/, 1]
26
- `
27
- let parser = new DOMParser();
28
- var divElement = document.querySelector('#'+#{parents});
29
- // select the first svg tag inside the div
30
- let foundSVG = divElement.querySelector('svg');
31
- let elements = foundSVG.getElementsByTagName("path");
32
- Array.from(elements).forEach(el => {
33
- el.setAttribute("fill", #{color_value});
34
- el.setAttribute("stroke", #{color_value});
35
- });
36
- `
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])
37
49
  else
38
50
  browser_document[parents].add_class(atome[:id])
39
-
40
51
  end
41
-
42
52
  end
43
53
 
44
54
  def self.browser_attached_div(children, _html_object, atome)
@@ -50,7 +60,33 @@ Array.from(elements).forEach(el => {
50
60
  end
51
61
 
52
62
  def self.browser_attached_style(children, _html_object, atome)
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
+ children.each do |child|
66
+ # tag_style = $document[child]
67
+ # alert "(#{atome[:id]}, #{child})"
68
+ add_class_to_vector(atome[:id], child)
69
+ # get the content the <style> tag
70
+ # content_style = tag_style.inner_html
71
+ # # extract the color value
72
+ # color_value = content_style[/background-color:\s*([^;}]+)/, 1]
73
+ # `
74
+ # let parser = new DOMParser();
75
+ # var divElement = document.querySelector('#'+#{atome[:id]});
76
+ # // select the first svg tag inside the div
77
+ # let foundSVG = divElement.querySelector('svg');
78
+ # let elements = foundSVG.getElementsByTagName("path");
79
+ # Array.from(elements).forEach(el => {
80
+ # el.setAttribute("fill", #{color_value});
81
+ # el.setAttribute("stroke", #{color_value});
82
+ # });
83
+ # `
84
+ end
53
85
 
86
+ else
87
+ # alert "class added : #{children}"
88
+ # browser_document[atome[:id]].add_class(children)
89
+ end
54
90
  browser_document[atome[:id]].add_class(children)
55
91
  end
56
92
 
@@ -3,16 +3,63 @@
3
3
  # for browser rendering
4
4
  module BrowserHelper
5
5
  def self.browser_colorize_color(color_updated, atome)
6
- `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.backgroundColor = #{color_updated}`
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
+
7
33
  end
8
34
 
9
35
  def self.browser_colorize_shadow(color_updated, atome)
36
+ "new shadow color is : #{color_updated}"
37
+ puts "=====> #{color_updated} : #{atome}"
10
38
  left = atome[:left]
11
39
  top = atome[:top]
12
40
  blur = atome[:blur]
13
41
  direction = atome[:direction]
14
- shadow_updated = "#{left}px #{top}px #{blur}px #{color_updated} #{direction}"
15
- `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
+ # }
16
63
  end
17
64
 
18
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,23 +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
- # generator.build_render(:browser_family) do |parents_found|
19
- # BrowserHelper.send("browser_attach_#{@browser_type}", parents_found, @browser_object, @atome)
20
- # end
21
-
22
18
  generator.build_render(:browser_attach) do |parents_found|
23
19
  # puts "parents_found : #{parents_found}, #{parents_found.class}"
24
20
  parents_found.each do |parent_found|
@@ -29,7 +25,8 @@ end
29
25
 
30
26
  generator.build_render(:browser_attached) do |children_found|
31
27
  children_found.each do |child_found|
32
- # 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}"
33
30
  children_browser_type = grab(child_found).instance_variable_get('@browser_type')
34
31
  BrowserHelper.send("browser_attached_#{children_browser_type}", children_found, @browser_object, @atome)
35
32
  end
@@ -41,6 +38,21 @@ generator.build_render(:browser_detached) do |values, _user_proc|
41
38
  value = value.value if value.instance_of? Atome
42
39
  if grab(value).instance_variable_get('@browser_type') == :style
43
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
+
44
56
  else
45
57
  BrowserHelper.browser_document[value]&.remove
46
58
  end
@@ -15,7 +15,6 @@ end
15
15
 
16
16
  generator.build_render(:green) do |value|
17
17
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
18
- self
19
18
  red = @atome[:red] * 255
20
19
  green = (@atome[:green] = value) * 255
21
20
  blue = @atome[:blue] * 255
@@ -49,11 +48,6 @@ generator.build_render(:alpha) do |value|
49
48
  end
50
49
 
51
50
  generator.build_render(:visual) do |value|
52
- # value = if value[:size].instance_of?(String)
53
- # value[:size]
54
- # else
55
- # "#{value[:size]}px"
56
- # end
57
51
  value = BrowserHelper.value_parse(value[:size])
58
52
  browser_object.style['font-size'] = value
59
53
  end
@@ -99,7 +93,8 @@ new ({ browser: :definition }) do |value|
99
93
  `
100
94
 
101
95
  var divElement = document.querySelector('#'+#{target});;
102
-
96
+ divElement.style.removeProperty('background-color');
97
+ divElement.style.backgroundColor = 'transparent';
103
98
  // select the first svg tag inside the div
104
99
  var svgElement = divElement.querySelector('svg');
105
100
 
@@ -111,6 +106,8 @@ if (svgElement) {
111
106
 
112
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>'
113
108
  let svgContainer = document.getElementById(#{target});
109
+ svgContainer.style.removeProperty('background-color');
110
+ svgContainer.style.backgroundColor = 'transparent';
114
111
  let parser = new DOMParser();
115
112
  let svgDoc = parser.parseFromString(svg_content, "image/svg+xml");
116
113
  let importedSVG = svgDoc.getElementsByTagName("svg")[0];
@@ -121,4 +118,4 @@ if (svgElement) {
121
118
  svgContainer.appendChild(importedSVG);
122
119
 
123
120
  `
124
- 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.2'
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
@@ -5,29 +5,35 @@
5
5
  # left: 0, right: 0, top: 0, bottom: 0, width: 30, height: 30, overflow: :hidden, tag: {system: false}
6
6
  # } })
7
7
 
8
- b=vector
9
-
8
+ b=box({left: 300})
9
+ b.drag(true)
10
10
  edition = <<~STR
11
11
  <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"/>
12
12
  STR
13
- b.definition(edition)
13
+ v=b.vector({left: 0, top: 0})
14
+
15
+ v.definition(edition)
14
16
  wait 1 do
15
- b.color(:yellow)
17
+ v.color(:yellow)
16
18
  end
17
19
  copy = <<~STR
20
+ <svg class="svg-icon" style="width: 1em; height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;"
21
+ viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg">
18
22
  <path id="p1" d="M672 832 224 832c-52.928 0-96-43.072-96-96L128 160c0-52.928 43.072-96 96-96l448 0c52.928 0 96 43.072 96 96l0 576C768 788.928 724.928 832 672 832zM224 128C206.368 128 192 142.368 192 160l0 576c0 17.664 14.368 32 32 32l448 0c17.664 0 32-14.336 32-32L704 160c0-17.632-14.336-32-32-32L224 128z"/>
19
23
  <path id="p2" d="M800 960 320 960c-17.664 0-32-14.304-32-32s14.336-32 32-32l480 0c17.664 0 32-14.336 32-32L832 256c0-17.664 14.304-32 32-32s32 14.336 32 32l0 608C896 916.928 852.928 960 800 960z"/>
20
24
  <path id="p3" d="M544 320 288 320c-17.664 0-32-14.336-32-32s14.336-32 32-32l256 0c17.696 0 32 14.336 32 32S561.696 320 544 320z"/>
21
25
  <path id="p4" d="M608 480 288.032 480c-17.664 0-32-14.336-32-32s14.336-32 32-32L608 416c17.696 0 32 14.336 32 32S625.696 480 608 480z"/>
22
26
  <path id="p5" d="M608 640 288 640c-17.664 0-32-14.304-32-32s14.336-32 32-32l320 0c17.696 0 32 14.304 32 32S625.696 640 608 640z"/>
27
+ </svg>
23
28
  STR
24
29
 
25
30
 
26
31
  wait 2 do
27
- b.definition(copy)
32
+ v.definition(copy)
28
33
  end
29
34
 
30
35
  wait 3 do
31
- b.color(:orange)
32
- b.width(33)
36
+ v.color(:orange)
37
+ v.width(33)
38
+ v.height(33)
33
39
  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.2
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-20 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