mk_semi_lattice 0.5.0 → 0.5.1

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: 81c0f885a735fa3302dec2cf7f1cc5fc74153aeec11369dda12fe6e6b5c6e0ac
4
- data.tar.gz: 04ba5d37247addf1d758b60058cb4e0452f42f6ac36e7550c6a86e5822dde1d7
3
+ metadata.gz: 033ace70dffbcfd3491030fab05752a39887c4f12d8b7e7990601d166edd9b04
4
+ data.tar.gz: 867903e8bbba30252779d938c4d3831be54a4a9fa387c4bc208d15096dffcd78
5
5
  SHA512:
6
- metadata.gz: 6f44b6a0f1b96b6098e5beceb15967055381bfa272f365c4de3853f4831c49ccacf2d87fd0172482aee8a20b780a403a47c6034b081fd39307e83ac4edb0b904
7
- data.tar.gz: 8bc9931f25f6f0a7b46f9884af815203e823fc29567bc551fdd04be1e90a600129b363695040c713e6100a89bdd08389c576f77c9caa68cceb75d6738c7bf7ea
6
+ metadata.gz: 2de03e16de7fe635ffb0111e85fb38d216f000e98af453a1f0d964873e5b1a745773c5fadbe11110bfc9909b030afe97201bf1b8e9d799e4c005eff009eff2d3
7
+ data.tar.gz: b0a765451fe1fb430dc83d5c758500a3b975a6781d279549fd06f44519e5c71354e65221ba390ac809306ff881783ac541a2bc9ba062862ac94d619882cd5415
@@ -0,0 +1,53 @@
1
+ <canvas id="myCanvas" width="600" height="200" style="border:1px solid #ccc; cursor:pointer;"></canvas>
2
+
3
+ <script>
4
+ const canvas = document.getElementById('myCanvas');
5
+ const ctx = canvas.getContext('2d');
6
+
7
+ // 1. ボタン情報の定義(画像パス、座標、サイズ、リンク先)
8
+ const buttons = [
9
+ {
10
+ src: 'button1.png', // 画像のパス
11
+ x: 50, y: 50, // 配置するX, Y座標
12
+ width: 100, height: 100, // 画像のサイズ
13
+ link: 'https://example.com' // リンク先URL
14
+ },
15
+ {
16
+ src: 'button2.png',
17
+ x: 200, y: 50,
18
+ width: 100, height: 100,
19
+ link: 'https://example.com'
20
+ }
21
+ ];
22
+
23
+ // 2. 画像を描画する関数
24
+ buttons.forEach(btn => {
25
+ const img = new Image();
26
+ img.src = btn.src;
27
+ img.onload = () => {
28
+ ctx.drawImage(img, btn.x, btn.y, btn.width, btn.height);
29
+ };
30
+ });
31
+
32
+ // 3. クリックイベントの設定
33
+ canvas.addEventListener('click', (event) => {
34
+ // Canvas上の正確なクリック座標を取得
35
+ const rect = canvas.getBoundingClientRect();
36
+ const clickX = event.clientX - rect.left;
37
+ const clickY = event.clientY - rect.top;
38
+
39
+ // 4. 当たり判定と画面遷移
40
+ buttons.forEach(btn => {
41
+ if (
42
+ clickX >= btn.x &&
43
+ clickX <= btn.x + btn.width &&
44
+ clickY >= btn.y &&
45
+ clickY <= btn.y + btn.height
46
+ ) {
47
+ // 範囲内をクリックした場合、指定URLへジャンプ
48
+ window.location.href = btn.link;
49
+ }
50
+ });
51
+ });
52
+ </script>
53
+
@@ -99,6 +99,30 @@ module ManageYaml
99
99
  end
100
100
  InitEnv::Log.event("exited", parent_dir: parent_dir)
101
101
  end
102
+
103
+ def to_semi_lattice
104
+ semi_lattice = SemiLattice.new
105
+ node_map = {}
106
+
107
+ @data['nodes'].each do |node_data|
108
+ id = node_data['id']
109
+ name = node_data['name']
110
+ type = node_data['type']
111
+ file_path = node_data['file_path']
112
+ icon_path = node_data['src'] # :srcを:icon_pathに渡す
113
+
114
+ node = semi_lattice.add_node(name, type, file_path, icon_path)
115
+ node_map[id] = node
116
+ end
117
+
118
+ @data['edges'].each do |edge_data|
119
+ from_id = edge_data['from']
120
+ to_id = edge_data['to']
121
+ edge = semi_lattice.add_edge(node_map[from_id], node_map[to_id])
122
+ end
123
+
124
+ semi_lattice
125
+ end
102
126
  end
103
127
 
104
128
  class MkDirYaml
@@ -6,6 +6,7 @@ EDGE_COLOR = 'black' # 標準色に戻す
6
6
 
7
7
  module SLComponents
8
8
  # 日本語対応フォントの優先順位で選択 for win11, なければ省略
9
+ PROJECT_ROOT = File.expand_path('../..', __dir__)
9
10
 
10
11
  class NodeShape
11
12
  attr_accessor :x, :y, :name, :label, :fixed, :linked, :dx, :dy, :type, :file_path
@@ -47,10 +48,12 @@ module SLComponents
47
48
  class Icon < NodeShape
48
49
  def setup_shape
49
50
  p ["setup @icon_path", @icon_path]
50
- icon_path = @icon_path && File.exist?(@icon_path) ? @icon_path : './icons/file.png'
51
+ default_icon_path = '.semi_lattice/icons/file.png'
52
+ icon_path = @icon_path && File.exist?(@icon_path) ? @icon_path : default_icon_path
53
+ p ["icon_path", File.expand_path(icon_path)]
51
54
  @image = Image.new(
52
55
  icon_path,
53
- x: @x-28, y: @y-20, width: 56, height: 36, z: @z
56
+ x: @x-60.48, y: @y-38.88, width: 120.96, height: 77.76, z: @z
54
57
  )
55
58
  end
56
59
 
@@ -59,19 +62,19 @@ module SLComponents
59
62
  end
60
63
 
61
64
  def x=(x)
62
- @image.x = x - 28
65
+ @image.x = x - 60.48
63
66
  end
64
67
 
65
68
  def y=(y)
66
- @image.y = y - 20
69
+ @image.y = y - 38.88
67
70
  end
68
71
  end
69
72
 
70
73
  class FolderIcon < NodeShape
71
74
  def setup_shape
72
75
  @image = Image.new(
73
- './.semi_lattice/icons/folder.png',
74
- x: @x-28, y: @y-20, width: 56, height: 36, z: @z
76
+ '.semi_lattice/icons/folder.png',
77
+ x: @x-67.2, y: @y-43.2, width: 134.4, height: 86.4, z: @z
75
78
  )
76
79
  end
77
80
 
@@ -80,19 +83,19 @@ module SLComponents
80
83
  end
81
84
 
82
85
  def x=(x)
83
- @image.x = x - 28
86
+ @image.x = x - 67.2
84
87
  end
85
88
 
86
89
  def y=(y)
87
- @image.y = y - 20
90
+ @image.y = y - 43.2
88
91
  end
89
92
  end
90
93
 
91
94
  class Document < NodeShape
92
95
  def setup_shape
93
96
  @image = Image.new(
94
- './.semi_lattice/icons/document.png',
95
- x: @x-28, y: @y-20, width: 38, height: 56, z: @z
97
+ '.semi_lattice/icons/document.png',
98
+ x: @x-33.6, y: @y-24, width: 45.6, height: 67.2, z: @z
96
99
  )
97
100
  end
98
101
 
@@ -101,11 +104,11 @@ module SLComponents
101
104
  end
102
105
 
103
106
  def x=(x)
104
- @image.x = x - 28
107
+ @image.x = x - 33.6
105
108
  end
106
109
 
107
110
  def y=(y)
108
- @image.y = y - 20
111
+ @image.y = y - 24
109
112
  end
110
113
  end
111
114
 
@@ -212,9 +215,9 @@ module SLComponents
212
215
 
213
216
  # テキスト生成(共通化)
214
217
  if font_path && File.exist?(font_path)
215
- @text = Text.new(label, x: x-28, y: y-10, size: 18, color: 'black', font: font_path, z: 11)
218
+ @text = Text.new(label, x: x-28, y: y+35, size: 14, color: 'black', font: font_path, z: 11)
216
219
  else
217
- @text = Text.new(label, x: x-28, y: y-10, size: 18, color: 'black', z: 11)
220
+ @text = Text.new(label, x: x-28, y: y+35, size: 14, color: 'black', z: 11)
218
221
  end
219
222
 
220
223
  # アイコン生成
@@ -222,7 +225,7 @@ module SLComponents
222
225
  when 'dir_icon'
223
226
  FolderIcon.new(x: x, y: y, color: NODE_COLOR, z: 10)
224
227
  when 'dir'
225
- Folder.new(x: x, y: y, color: NODE_COLOR, z: 10)
228
+ FolderIcon.new(x: x, y: y, color: NODE_COLOR, z: 10)
226
229
  when 'document'
227
230
  Document.new(x: x, y: y, color: NODE_COLOR, z: 10)
228
231
  when 'icon'
@@ -249,8 +252,8 @@ module SLComponents
249
252
  @circle.color = c # これ以降でcomponentをupdate
250
253
  @circle.x = @x
251
254
  @circle.y = @y
252
- @text.x = @x - 28
253
- @text.y = @y
255
+ @text.x = @x - @text.width / 2
256
+ @text.y = @y + 35
254
257
  end
255
258
  end
256
259
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MkSemiLattice
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mk_semi_lattice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeto R. Nishitani
@@ -121,8 +121,6 @@ files:
121
121
  - exe/hc
122
122
  - exe/mk_semi_lattice
123
123
  - exe/mk_sl
124
- - lib/.semi_lattice/icons/document.png
125
- - lib/.semi_lattice/icons/folder.png
126
124
  - lib/abbrev_checker/abbrev_check.rb
127
125
  - lib/abbrev_checker/abbrev_sample.tgz
128
126
  - lib/abbrev_checker/abbrev_yamls/command/dir_tree.yaml
@@ -155,10 +153,12 @@ files:
155
153
  - lib/mk_light_table/readme.org
156
154
  - lib/mk_light_table/style.css
157
155
  - lib/mk_light_table/template.org
156
+ - lib/mk_link_canvas/sample.html
158
157
  - lib/mk_semi_lattice.rb
159
158
  - lib/mk_semi_lattice/.semi_lattice/dir_node_edge.yaml
160
159
  - lib/mk_semi_lattice/.semi_lattice/dir_tree.yaml
161
160
  - lib/mk_semi_lattice/.semi_lattice/icons/document.png
161
+ - lib/mk_semi_lattice/.semi_lattice/icons/file.png
162
162
  - lib/mk_semi_lattice/.semi_lattice/icons/folder.png
163
163
  - lib/mk_semi_lattice/.semi_lattice/semi_lattice.yaml
164
164
  - lib/mk_semi_lattice/docs/images/mk_semi_lattice.001.png
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
253
  - !ruby/object:Gem::Version
254
254
  version: '0'
255
255
  requirements: []
256
- rubygems_version: 3.6.7
256
+ rubygems_version: 4.0.17
257
257
  specification_version: 4
258
258
  summary: make semi lattice graph from directory structure
259
259
  test_files: []
Binary file