js+css实现 (仿ComfyUI)节点编辑器代码

代码语言:html

所属分类:拖放

代码描述:js+css实现 (仿ComfyUI)节点编辑器代码,可拖拽连线

代码标签: js css实现 仿 ComfyUI 节点 编辑器 代码

下面为部分代码预览,完整代码请点击下载或在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>3D 节点编辑器 (仿 ComfyUI)</title>
    <style>
        /* --- 基础样式 --- */
        body, html {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            background-color: #202020; /* 深色背景 */
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            overflow: hidden;
            user-select: none;
        }

        /* --- 画布容器 --- */
        #canvas-container {
            position: relative;
            width: 100%;
            height: 100%;
            /* 网格背景 */
            background-image: 
                linear-gradient(#2a2a2a 1px, transparent 1px),
                linear-gradient(90deg, #2a2a2a 1px, transparent 1px);
            background-size: 20px 20px;
        }

        /* --- SVG连线层 (位于节点下方) --- */
        #connections-layer {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none; /* 让鼠标事件穿透SVG层,直达节点 */
            z-index: 0;
        }

        path {
            fill: none;
            stroke: #a0a0a0;
            stroke-width: 2px;
            pointer-events: auto; /* 线条本身可以响应事件(如右键删除) */
        }
        
        path:hover {
            stroke: #e0e0e0;
            stroke-width: 3px;
            cursor: pointer;
        }

        /* --- 节点样式 (立体感核心) --- */
        .node {
            position: absolute;
           .........完整代码请登录后点击上方下载按钮下载查看

网友评论0