mirror of
https://gitee.com/coder-xiaomo/algorithm-visualization
synced 2025-01-10 11:48:18 +08:00
添加水印
This commit is contained in:
parent
52ba2c7088
commit
bed6c2b5c8
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -6,5 +6,6 @@
|
||||
"**/.gitignore",
|
||||
"**/.vscode/**",
|
||||
"**/lib/**"
|
||||
]
|
||||
],
|
||||
"liveServer.settings.port": 80
|
||||
}
|
@ -7,3 +7,17 @@ text {
|
||||
svg {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* 元素鼠标悬浮样式 */
|
||||
svg g:hover > rect {
|
||||
fill: #ffafb6;
|
||||
}
|
||||
|
||||
/* 右下角水印样式 */
|
||||
svg #watermark-r-b{
|
||||
opacity: 0.2;
|
||||
transition: 0.2s;
|
||||
}
|
||||
svg #watermark-r-b:hover{
|
||||
opacity: 0.8;
|
||||
}
|
1
src/assets/image/logo-small.svg
Normal file
1
src/assets/image/logo-small.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 19 KiB |
@ -133,6 +133,13 @@ class Shape {
|
||||
}
|
||||
|
||||
|
||||
// 添加一个图片水印
|
||||
addWatermark(id, { imageSrc }) {
|
||||
var primaryCanvas = workSpace.primaryCanvas
|
||||
return primaryCanvas.append("image", id)
|
||||
.attr("xlink:href", imageSrc)
|
||||
}
|
||||
|
||||
// 绘制一个链表
|
||||
getLinkedListFragment(id, nodes) {
|
||||
var settings = this.workSpace.settings
|
||||
|
@ -72,6 +72,33 @@ function initArray(elementId, listData) {
|
||||
|
||||
console.log(fragment)
|
||||
workSpace.primaryCanvas.html("")
|
||||
|
||||
// 添加水印 居中
|
||||
var watermarkWidth = settings.outerSize.height * 0.65
|
||||
shape.addWatermark(elementId, {
|
||||
imageSrc: "./assets/image/logo-small.svg",
|
||||
})
|
||||
.attr('id', 'watermark-c-c')
|
||||
.attr('x', settings.outerSize.width / 2)
|
||||
.attr('y', settings.outerSize.height / 2)
|
||||
.style('width', watermarkWidth + 'px')
|
||||
.style('height', watermarkWidth + 'px')
|
||||
.style('transform', `translate(-${watermarkWidth / 2}px, -${watermarkWidth / 2}px)`)
|
||||
.style('opacity', '0.015')
|
||||
.style('transition', '0.2s')
|
||||
|
||||
// 添加水印 右下角
|
||||
var watermarkWidth = 60
|
||||
shape.addWatermark(elementId, {
|
||||
imageSrc: "./assets/image/logo-small.svg",
|
||||
})
|
||||
.attr('id', 'watermark-r-b')
|
||||
.attr('x', settings.outerSize.width)
|
||||
.attr('y', settings.outerSize.height)
|
||||
.style('width', watermarkWidth + 'px')
|
||||
.style('height', watermarkWidth + 'px')
|
||||
.style('transform', 'translate(-80px, -80px)')
|
||||
|
||||
workSpace.primaryCanvas.node().appendChild(fragment)
|
||||
document.getElementById(elementId).customAttr = fragment.customAttr
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user