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 +4 -4
- data/lib/mk_light_table/mk_light_table_link.key +0 -0
- data/lib/mk_link_canvas/sample.html +53 -0
- data/lib/mk_semi_lattice/manage_yaml/mk_semi_lattice_yaml.rb +24 -0
- data/lib/mk_semi_lattice/sl_components.rb +20 -17
- data/lib/mk_semi_lattice/version.rb +1 -1
- metadata +4 -4
- data/lib/.semi_lattice/icons/folder.png +0 -0
- /data/lib/{.semi_lattice/icons/document.png → mk_semi_lattice/.semi_lattice/icons/file.png} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 033ace70dffbcfd3491030fab05752a39887c4f12d8b7e7990601d166edd9b04
|
|
4
|
+
data.tar.gz: 867903e8bbba30252779d938c4d3831be54a4a9fa387c4bc208d15096dffcd78
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2de03e16de7fe635ffb0111e85fb38d216f000e98af453a1f0d964873e5b1a745773c5fadbe11110bfc9909b030afe97201bf1b8e9d799e4c005eff009eff2d3
|
|
7
|
+
data.tar.gz: b0a765451fe1fb430dc83d5c758500a3b975a6781d279549fd06f44519e5c71354e65221ba390ac809306ff881783ac541a2bc9ba062862ac94d619882cd5415
|
|
Binary file
|
|
@@ -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
|
-
|
|
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-
|
|
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 -
|
|
65
|
+
@image.x = x - 60.48
|
|
63
66
|
end
|
|
64
67
|
|
|
65
68
|
def y=(y)
|
|
66
|
-
@image.y = y -
|
|
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
|
-
'
|
|
74
|
-
x: @x-
|
|
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 -
|
|
86
|
+
@image.x = x - 67.2
|
|
84
87
|
end
|
|
85
88
|
|
|
86
89
|
def y=(y)
|
|
87
|
-
@image.y = y -
|
|
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
|
-
'
|
|
95
|
-
x: @x-
|
|
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 -
|
|
107
|
+
@image.x = x - 33.6
|
|
105
108
|
end
|
|
106
109
|
|
|
107
110
|
def y=(y)
|
|
108
|
-
@image.y = y -
|
|
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
|
|
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
|
|
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
|
-
|
|
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 -
|
|
253
|
-
@text.y = @y
|
|
255
|
+
@text.x = @x - @text.width / 2
|
|
256
|
+
@text.y = @y + 35
|
|
254
257
|
end
|
|
255
258
|
end
|
|
256
259
|
|
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.
|
|
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:
|
|
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
|
|
File without changes
|