atome 0.5.4.1.2 → 0.5.4.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4b330e878ce2169698bf9cf0cb0910503b2600e875abf3d458e87cbd4cb7c8c
4
- data.tar.gz: 0be22a13c09c3f280049579fb6c0f4d7010073d4880bb7ae0cb99e79a750da40
3
+ metadata.gz: 5ea8cce9faff92d47920bfeb8bdd678e0c1c19db73d7446b43c8f8053cbb32f9
4
+ data.tar.gz: cc515d8140cbda0d54b4a9faf1bbe13a03bc8a19ce500965480ab5a66f1cd951
5
5
  SHA512:
6
- metadata.gz: ee294cb99cf5d7b0d34eed58c43a0a1b4309d16fd9c0c3ccba9efe06fd079858d32a7fa0c3562376ce35d076bbef7e14f045f3bcb55a7a27814d55990409785a
7
- data.tar.gz: e6c748de46620aa1eb7b2fd5325bfefe66132992e78a1e2f3ad2a670f34e96e0166fa695ad5aa435fd3d3a1433b48c398582c093c0ed0593e85ba172aa73bead
6
+ metadata.gz: 1b6a8825e9546c41f81fe46018c57824aa2bb46b176a1cf2c4a3d8c1b63ba19f5ba85abddbb3ed790ef9d555968c0e4d90238c3280b6c5d6c799b0d6017bcd1d
7
+ data.tar.gz: 9c8496f6d15528eef09246d2454847210019fd282a6baca7e505076923e6527fb9ea09f54c9f942985324e0a09264380c4e632fbe748d50e24d00d61caf1df5a
data/CHANGELOG.md CHANGED
@@ -4,4 +4,9 @@
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
@@ -4,10 +4,10 @@ new({ particle: :attach })
4
4
  new({ sanitizer: :attach }) do |parents_ids|
5
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]
@@ -31,10 +31,10 @@ end
31
31
  new({ particle: :attached })
32
32
  new({ sanitizer: :attached }) do |children_ids|
33
33
  puts "=> attached now! : #{children_ids}<="
34
- children_ids = children_ids if children_ids.instance_of? Atome
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
@@ -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 } }
@@ -9,16 +9,16 @@ 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
12
+ # if @definition
13
+ # alert "why we never pass here??????"
14
+ # else
15
15
  @browser_type = :div
16
16
  id_found = @atome[:id]
17
17
  DOM do
18
18
  div(id: id_found).atome
19
19
  end.append_to(BrowserHelper.browser_document[:user_view])
20
20
  @browser_object = BrowserHelper.browser_document[id_found]
21
- end
21
+ # end
22
22
 
23
23
  end
24
24
 
@@ -34,9 +34,13 @@ generator.build_render(:browser_color) do |_value|
34
34
  green_found = @atome[:green]
35
35
  alpha_found = @atome[:alpha]
36
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
+ 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
40
44
  @browser_object = BrowserHelper.browser_document[id_found]
41
45
  end
42
46
 
@@ -15,25 +15,36 @@ 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
20
+ # get the content the <style> tag
21
+ color_class=self.color.last
22
+ # alert color_class.class
23
+ # content_style = tag_style.inner_html
24
+ # color_value = content_style[/background-color:\s*([^;}]+)/, 1]
25
+ `
26
+ let parser = new DOMParser();
27
+ var divElement = document.querySelector('#'+#{vector_id});
28
+ divElement.style.removeProperty('background-color');
29
+ divElement.style.backgroundColor = 'transparent';
30
+ // select the first svg tag inside the div
31
+ let foundSVG = divElement.querySelector('svg');
32
+ let elements = foundSVG.getElementsByTagName("path");
33
+ Array.from(elements).forEach(el => {
34
+ el.classList.add(#{color_class});
35
+ });
36
+ `
37
+ end
38
+
18
39
  def self.browser_attach_style(parents, _html_object, atome)
19
40
  # we test if the atome has a deinition ( it means hold some vectors infomations)
20
41
  if grab(parents).atome[:definition]
21
42
  tag_style = $document[atome[:id]]
22
- # get the content the <style> tag
23
- content_style = tag_style.inner_html
43
+ # # get the content the <style> tag
44
+ # content_style = tag_style.inner_html
24
45
  # 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
- `
46
+ colorize_vector(parents, tag_style)
47
+
37
48
  else
38
49
  browser_document[parents].add_class(atome[:id])
39
50
 
@@ -50,8 +61,34 @@ Array.from(elements).forEach(el => {
50
61
  end
51
62
 
52
63
  def self.browser_attached_style(children, _html_object, atome)
64
+ if atome[:definition]
65
+ children.each do |child|
66
+ tag_style = $document[child]
67
+
68
+ colorize_vector(atome[:id], tag_style)
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
85
+
86
+ else
87
+ # alert atome.class
88
+ browser_document[atome[:id]].add_class(children)
89
+ end
90
+ # browser_document[atome[:id]].add_class(children)
53
91
 
54
- browser_document[atome[:id]].add_class(children)
55
92
  end
56
93
 
57
94
  def self.value_parse(value)
@@ -3,7 +3,11 @@
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
+ `
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
+ `
7
11
  end
8
12
 
9
13
  def self.browser_colorize_shadow(color_updated, atome)
@@ -15,9 +15,6 @@ 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
18
 
22
19
  generator.build_render(:browser_attach) do |parents_found|
23
20
  # puts "parents_found : #{parents_found}, #{parents_found.class}"
@@ -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
 
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.3'
5
5
  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.3
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-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arduino_firmata