vue实现可视化画布画板可粘贴导入图片文字svg图标裁剪代码

代码语言:html

所属分类:其他

代码描述:vue实现可视化画布画板可粘贴导入图片文字svg图标裁剪代码

代码标签: vue 可视化 画布 画板 粘贴 导入 图片 文字 svg 图标 裁剪 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>无限画布编辑器</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { overflow: hidden; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; background: #1a1a2e; user-select: none; }

#toolbar {
    position: fixed; top: 0; left: 0; right: 0; height: 48px; z-index: 1000;
    background: rgba(20, 20, 40, 0.95); backdrop-filter: blur(12px);
    display: flex; align-items: center; padding: 0 12px; gap: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 2px 20px rgba(0,0,0,0.3);
}
.tool-btn {
    padding: 6px 14px; border: 1px solid rgba(255,255,255,0.1); border-radius: 8px;
    background: rgba(255,255,255,0.05); color: #ccc; cursor: pointer; font-size: 13px;
    transition: all 0.2s; display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.tool-btn:hover { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.2); }
.tool-btn.active { background: rgba(79,140,255,0.25); color: #6baaff; border-color: rgba(79,140,255,0.4); }
.tool-btn svg { width: 16px; height: 16px; fill: currentColor; }
.separator { width: 1px; height: 24px; background: rgba(255,255,255,0.1); margin: 0 6px; }

#canvas-container {
    position: fixed; top: 48px; left: 0; right: 0; bottom: 0;
    overflow: hidden; cursor: grab; background: #16213e;
    background-image: radial-gradient(circle, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 30px 30px;
}
#canvas-container.grabbing { cursor: grabbing; }

#canvas-world { position: absolute; top: 0; left: 0; transform-origin: 0 0; }

.canvas-element {
    position: absolute; cursor: move; min-width: 20px; min-height: 20px;
}
.canvas-element.selected {
    outline: 2px solid #4f8cff; outline-offset: 2px;
}
.canvas-element .resize-handle {
    position: absolute; width: 10px; height: 10px; background: #4f8cff;
    border: 2px solid #fff; border-radius: 50%; display: none; z-index: 10;
}
.canvas-element.selected .resize-handle { display: block; }
.resize-handle.tl { top: -5px; left: -5px; cursor: nw-resize; }
.resize-handle.tr { top: -5px; right: -5px; cursor: ne-resize; }
.resize-handle.bl { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-handle.br { bottom: -5px; right: -5px; cursor: se-resize; }
.resize-handle.ml { top: 50%; left: -5px; transform: translateY(-50%); cursor: w-resize; }
.resize-handle.mr { top: 50%; right: -5px; transform: translateY(-50%); cursor: e-resize; }
.resize-handle.mt { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-handle.mb { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }

.canvas-element img {
    width: 100%; height: 100%; object-fit: contain; pointer-events: none; display: block;
}
.canvas-element .text-content {
    min-width: 60px; min-height: 24px; padding: 8px 12px; color: #fff;
    font-size: 16px; outline: none; word-break: break-word; white-space: pre-wrap;
    background: transparent; line-height: 1.5;
}
.canvas-element .svg-content { width: 100%; height: 100%; }
.canvas-element .svg-content svg { width: 100%; height: 100%; }

#crop-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7); z-index: 2000; display: none;
    justify-content: center; align-items: center; flex-direction: column;
}
#crop-overlay.show { display: flex; }
#crop-container {
    position: relative; max-width: 80vw; max-height: 70vh;
    border: 2px solid #4f8cff; overflow: hidden;
}
#crop-container img { max-width: 80vw; max-height: 70vh; display: block; }
#crop-selection {
    position: absolute; border: 2px dashed #fff;
    background: rgba(79,140,255,0.15); cursor: crosshair;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}
#crop-toolbar {
    margin-top: 16px; display: flex; gap: 10px;
}
#crop-toolbar button {
    padding: 8px 24px.........完整代码请登录后点击上方下载按钮下载查看

网友评论0